我有一个带有自定义启动命令“sh/home/custom_startup.sh”的 Azure Linux Web 应用程序。每当我通过 Visual Studio 重新部署应用程序时,启动命令都会更改为“dotnet App.dll”之类的内容。我不希望出现这种行为,因为目前我需要在每次部署后手动更改启动命令并重新启动应用程序。
有什么想法吗?
最佳答案
必须将自定义启动命令添加到发布配置文件中。将其添加到“Properties\PublishProfiles\Your.pubxml”:
<AppServiceStartupCommand>sh /home/custom_startup.sh</AppServiceStartupCommand>
多年来发布行为发生了变化。
- 在 2020 年之前,重新部署 Azure Linux Web 应用不会覆盖其启动命令。我们可以写例如在 Azure 门户中输入“sh/home/custom_startup.sh”,然后就不用管它了。
- 2021 年,重新部署 Azure Linux Web 应用开始用“dotnet YourEntryPoint.dll”覆盖其启动命令。这解决了一些问题,因为运行时无法始终检测到入口程序集。然而,这导致了 OP 的问题 - 我们无法自动执行自定义启动命令。
- 解决方案是一个名为 AppServiceStartupCommand 的新 .pubxml 属性,但名为 it was released in 2022 。
关于visual-studio - Azure Webapp 启动命令在部署后重置(Visual Studio -> 发布),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66584656/