首页 文章

如何按计划重新启动Azure Web App

提问于
浏览
1

我想每天06:00重启我的Azure Web App .

我找到了Azure App Services: Automate Application restart using Web Job的参考资料

但是,这篇文章中有一些错误 .

  • Save-AzureProfile => Save-AzureRmContext

  • Select-AzureRmProfile => Import-AzureRmContext

修好后,在本地运行,这是完美的 .

当我在Azure Web App上创建Web作业时,会出现错误

InvalidOperation

看起来它不支持Stop-AzureRmWebApp

有解决方案吗?

1 回答

  • 0

    我测试了它在我身边 . blob提供的PowerShell代码在我这方面运行良好 . 以下是我所做的详细步骤 .

    步骤1.创建名为TestRestartWebApp的文件夹 . 步骤2.生成配置文件到该文件夹 .

    Save-AzureRmProfile -Path "D:\TestRestartWebApp\azureprofile.json"
    

    步骤3.在该文件夹中创建名为run.ps1的PS文件 .

    enter image description here

    第4步 . 以下是我在run.ps1中输入的代码 .

    $ProgressPreference= "SilentlyContinue"
    Select-AzureRmProfile -Path "azureprofile.json"
    Select-AzureRmSubscription -SubscriptionId 'my subscription id'
    Stop-AzureRmWebApp -Name 'my web app name' -ResourceGroupName 'my resource group name'
    

    步骤5.压缩此文件夹并使用压缩文件创建WebJob .

    在上面的步骤之后,我可以在WebJob仪表板中看到日志 . Web App已停止 .

    enter image description here

    请仔细检查您的步骤,您和我之间是否有任何差异 . 您是否在run.ps1文件中为配置文件设置了正确的路径 .

相关问题