Azure: Powershell: Set-AzureRmWebApp: how to set the alwaysOn property

I am running Powershell 5 and trying to manipulate my Azure WebApp object using Set-AzureRmWebApp (and NOT Set-AzureResource) to set the Always On property in the web application.

My basic code snippet starts with a running web application called "myWebApp" and looks like this:

$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 

The first Set-AzureRmWebApp statement works . It sets all the variables in $ app_settings and they become visible on the Azure blade server for myWebApp .

I tried using "Always On" = on as a property in $ app_settings using Set-AzureRmWebApp and appeared in the application settings submenu in the "myWebApp" properties on the Azure portal blade, but the actual "Always On" property remained in the general settings.

I read on another site that using Set-AzureRmResource would work, so I tried, but it failed.

What do I need to do in Powershell to set the property in the general settings of my Azure WebApp, in particular , Always On?

+5
source share
1 answer

Always On is not supported if WebApp is in the free service plan tier. If WebApp is free, increase your application service plan. For more information on how to increase your application maintenance plan, see. Try using the solution mentioned by sharbag. It works for me, and I also check the result of the execution on the azure portal. The removed code from the solution is as follows:

  $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 

enter image description here

If WebApp is in the free tier service plans, when we try to run the PowerShell command to enable Always On, we will receive the following error message.

enter image description here

+6
source

Source: https://habr.com/ru/post/1260308/


All Articles