Azure 启动脚本未执行

发布于 2025-01-20 15:55:17 字数 897 浏览 5 评论 0 原文

我已经学到了如何使用Azure Cli 部署.sh脚本到Azure。但是似乎我对它们的工作方式没有清楚的了解。

我正在创建脚本,该脚本仅在Azure Web应用程序当前目录中简单地将.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/中,但由于某种原因,它永远不会。不管我怎么尝试。我认为它只是被执行然后自动删除(因为我将其指定为 startup 脚本),但是存档在那里,根本不是不算什么。

我的堆栈是.NET核心。

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

I've learned how to deploy .sh scripts to Azure with Azure CLI. But it seems like I have no clear understanding of how they work.

I'm creating the script that simply unarchives a .tgz archive in a current directory of Azure Web App, and then just deletes it. Quite simple:

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

And then I deploy the script like this:

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

Supposedly, it should appear in /home/site/wwwroot/, but for some reason it never does. No matter how I try. I thought it just gets executed and then deleted automatically (since I specified it as a startup script), but the archive is there, not unarchived at all.

My stack is .NET Core.

What am I doing wrong, and what's the right way to do what I need to do? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜泪 2025-01-27 15:55:17

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

来自,在描述Azure CLI功能时,他们说:

CLI命令使用Kudu Publish API部署软件包,可以是
完全定制。

指示,描述类型的不同值,尤其是启动

type = startup :部署应用程序服务自动使用作为
您的应用程序的启动脚本。默认情况下,脚本部署到
d:\ home \ site \ site \ scripts \< windows的源代码>
Home/site/wwwroot/startup.sh for Linux。可以指定目标路径
使用路径

注意路径的使用:

将工件部署到的绝对路径。例如,
“ /home/site/deployments/tools/driver.jar”,“ /home/site/scripts/helper.sh”。

我从未对其进行测试,我知道在接受 az webapp部署命令本身,它可能只是文档中的一个错误,但它可能会工作:

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 命令:也许可以激发任何权限问题的问题,并在日志中有一些痕迹也有帮助。

I don't know if it makes sense, but I think the problem might be that you're using the target-path parameter while you should be using path instead.

From the documentation you cited, when describing the Azure CLI functionality, they state:

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

The Kudu publish API reference indicates, when describing the different values for type and especially startup:

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

Note the use of path:

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

I never tested it, I am aware that the option is not described when taking about the az webapp deploy command itself, and it may be just an error in the documentation, but it may work:

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

Note that the path you are providing is the default one; as a consequence, you could safely delete it if required:

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

Finally, try including some debug or echo commands in your script: perhaps the problem can be motivated for any permissions issue and having some traces in the logs could be helpful as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文