Azure:Powershell:Set-AzureRmWebApp:如何设置 "alwaysOn" 属性

Azure: Powershell: Set-AzureRmWebApp: How to set the "alwaysOn" property

我是 运行 Powershell 5 并尝试使用 Set-AzureRmWebApp(而不是 Set-AzureResource 来操纵我的 Azure WebApp object ) 设置网络应用程序的 "Always On" 属性。

我的基本代码片段以名为 "myWebApp" 的 运行 网络应用程序开头,如下所示:

$name = "myWebApp"
$resourceGroupName = "myResourceGroup"
$app_settings = @{"WEBSITE_LOAD_CERTIFICATES"="*";"CommonDatabase"="Common";"WEBSITE_NODE_DEFAULT_VERSION"="0.10.32"}

$result1 = Set-AzureRmWebApp -ResourceGroupName $resourceGroupName -AppSettings $app_settings -Name $name
$result2 = Set-AzureRmResource -ResourceGroupName $resourceGroupName  -ResourceType Microsoft.Web/sites/config -ResourceName $this.name -PropertyObject $propertiesObject -ApiVersion 2015-08-01 -Force

第一个 Set-AzureRmWebApp 语句有效。它设置 $app_settings 中的所有变量,并且它们在 myWebApp 的 Azure 门户 blade 中可见。

我尝试使用 "Always On"= on 作为 属性 in $app_settings Set-AzureRmWebApp,它出现在 Azure 门户 "myWebApp" 属性中的应用程序设置 sub-list blade,但实际 属性 "Always On"在一般设置中保持关闭状态。

我在另一个网站上看到使用 Set-AzureRmResource 可以,所以我尝试了一下,但失败了。

我需要在 Powershell 中做什么才能在我的 Azure WebApp 的常规设置中设置 属性,特别是 "Always On"?

如果 WebApp 在免费服务计划层中,则不支持

"Always On"。如果 WebApp 处于免费层级,请扩展 App Service Plan。有关如何扩展应用服务的更多信息,请参阅 document Plan.Please 尝试使用 sharbag 提到的解决方案。它对我有用,我还检查了 azure 门户的 运行 结果。从解决方案中截取的代码如下:

   $ResourceGroupName = 'Your Group Name'

   $WebAppName = 'Your WebApp Name'

   $WebAppPropertiesObject = @{"siteConfig" = @{"AlwaysOn" = $true}}

    $WebAppResourceType = 'microsoft.web/sites'

    $webAppResource = Get-AzureRmResource -ResourceType $WebAppResourceType -ResourceGroupName $ResourceGroupName -ResourceName $WebAppName

    $webAppResource | Set-AzureRmResource -PropertyObject $WebAppPropertiesObject -Force

如果 WebApp 在免费层服务计划中,当我们尝试 运行 PowerShell 命令启用 "Always On" 时,我们将得到以下信息错误信息。