gpt4 book ai didi

Azure 启动脚本未执行

转载 作者:行者123 更新时间:2023-12-02 23:55:55 25 4
gpt4 key购买 nike

我学会了how to deploy .sh scripts to Azure with Azure CLI 。但我似乎不太清楚它们是如何工作的。

我正在创建一个脚本,该脚本只需在 Azure Web App 的当前目录中取消存档 .tgz 存档,然后将其删除。很简单:

New-Item ./startup.sh
Set-Content ./startup.sh '#!/bin/sh'
Add-Content ./startup.sh 'tar zxvf archive.tgz; rm-rf ./archive.tgz'

然后我像这样部署脚本:

az webapp deploy --resource-group Group 
--name Name
--src-path ./startup.sh
--target-path /home/site/wwwroot/startup.sh
--type=startup

按理说,它应该出现在 /home/site/wwwroot/ 中,但由于某种原因它从未出现过。不管我怎么努力。我以为它只是被执行,然后自动删除(因为我将其指定为启动脚本),但存档就在那里,根本没有取消存档。

我的堆栈是 .NET Core。

我做错了什么,做我需要做的事情的正确方法是什么?谢谢。

最佳答案

我不知道这是否有意义,但我认为问题可能是您正在使用 target-path参数,而你应该使用 path相反。

来自documentation you cited ,在描述 Azure CLI 功能时,他们指出:

The CLI command uses the Kudu publish API to deploy the package and can befully customized.

Kudu publish API reference表示,在描述类型的不同值时,尤其是 startup :

type=startup: Deploy a script that App Service automatically uses as thestartup script for your app. By default, the script is deployed toD:\home\site\scripts\<name-of-source> for Windows andhome/site/wwwroot/startup.sh for Linux. The target path can be specifiedwith path.

注意 path 的使用:

The absolute path to deploy the artifact to. For example,"/home/site/deployments/tools/driver.jar", "/home/site/scripts/helper.sh".

我从未测试过它,我知道在考虑 az webapp deploy command itself 时没有描述该选项,这可能只是文档中的一个错误,但它可能有效:

az webapp deploy --resource-group Group 
--name Name
--src-path ./startup.sh
--path /home/site/wwwroot/startup.sh
--type=startup

请注意,您提供的路径是默认路径;因此,如果需要,您可以安全地删除它:

az webapp deploy --resource-group Group 
--name Name
--src-path ./startup.sh
--type=startup

最后,尝试包含一些调试或 echo脚本中的命令:也许该问题可能是由任何权限问题引起的,并且在日志中进行一些跟踪也可能会有所帮助。

关于Azure 启动脚本未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71829306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com