Azure:Powershell:Set-AzureRmWebApp:如何设置& quot; alwaysOn& quot;财产 [英] Azure: Powershell: Set-AzureRmWebApp: How to set the "alwaysOn" property

查看:52
本文介绍了Azure:Powershell:Set-AzureRmWebApp:如何设置& quot; alwaysOn& quot;财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Powershell 5,并尝试使用 Set-AzureRmWebApp (和NOT Set-AzureResource)来操纵我的Azure WebApp对象来设置Web应用程序的始终打开"属性.

我的基本代码段以一个正在运行的名为"myWebApp" 的Web应用程序开头,如下所示:

  $ 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/站点/配置-ResourceName $ this.name -PropertyObject $ propertiesObject -ApiVersion 2015-08-01 -Force 

第一个 Set-AzureRmWebApp 语句有效.它在 $ app_settings 中设置所有变量,并且这些变量在 myWebApp 的Azure门户刀片中可见.

我尝试通过Set-AzureRmWebApp将"Always On" = on 用作 $ app_settings 中的属性,它出现在属性的应用程序设置"子列表中在Azure门户刀片服务器上使用"myWebApp",但常规设置中的实际属性"Always On"始终处于关闭状态.

我在另一个站点上读到,使用 Set-AzureRmResource 可以工作,所以我尝试了一下,但是失败了.

我需要在Powershell中做什么以在Azure WebApp的常规设置"中设置属性,特别是始终在线" ?

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

解决方案

始终在线" .如果WebApp是免费的,请按比例增加App Service Plan.请参考

如果WebApp处于免费服务计划中,则当我们尝试运行PowerShell命令以启用始终在线" 时,我们将收到以下错误消息.

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"?

解决方案

"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

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.

这篇关于Azure:Powershell:Set-AzureRmWebApp:如何设置& quot; alwaysOn& quot;财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆