8

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 of the web app.

My basic code snippet starts with a running web app named "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 in the Azure Portal blade for myWebApp.

I tried using "Always On"= on as a property in $app_settings with Set-AzureRmWebApp, and it appeared in the App Settings sub-list in the properties of "myWebApp" on the Azure portal blade, but the actual property "Always On" in the general settings remained off.

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

What do I need to do in Powershell to set a property in the General Settings of my Azure WebApp, specifically "Always On"?

Jay Godse
  • 15,163
  • 16
  • 84
  • 131
  • Possible duplicate of [Is it possible to enable Always On for Azure websites through management/resource management APIs?](http://stackoverflow.com/questions/26756644/is-it-possible-to-enable-always-on-for-azure-websites-through-management-resourc) – Sharbag Nov 24 '16 at 23:55
  • Look there: http://stackoverflow.com/a/36811987/1275334 – Sharbag Nov 24 '16 at 23:55

1 Answers1

12

"Always On" is not supported if WebApp is in a free Service Plan tier. If the WebApp is in a free tier, please scale up the App Service Plan. Please refer to the document for more info about how to scale up the App Service Plan.Please have a try to use the solution that sharbag mentioned. It is worked for me and I also check the run result from the azure portal. Snipped code from the solution is as followings:

   $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 the WebApp in a free tier service plan, when we try to run the PowerShell command to enable "Always On" then we will get the following error message.

enter image description here

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • 1
    I am on a paid plan. It is just formatting that properties hash which doesn't seem to be documented anywhere. – Jay Godse Nov 25 '16 at 15:32
  • 2
    Using `Set-AzWebApp` in v 4.2.0, I was getting `A parameter cannot be found that matches parameter name 'AlwaysOn'`. Changing `Get-AzureRmResource` to `Get-AzResource`, this answer worked for me. – JsAndDotNet Jun 10 '20 at 10:29