我有一个PS脚本,其中包含类似的内容,可以在Web App上设置IP限制。这很好用,但是我们的PROD Web App有一个暂存插槽。如何在所有插槽中设置相同的限制?不幸的是,门户网站尚不支持此功能。
# Update IP restrictions if modified
$WebAppConfig.properties.ipSecurityRestrictions = $ArrayList
$WebAppConfig | Set-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $WebApp/web -ApiVersion $APIVersion -Force | Out-Null
非常感谢!
答案 0 :(得分:1)
请尝试以下脚本,我的Web应用程序名为joywebapp2
,插槽名为slot1
,如果您有多个插槽,脚本会将该插槽设置为与Webapp相同的IpSecurityRestrictions
,只需使用循环即可。
$IpSecurityRestrictions = (Get-AzureRmWebApp -ResourceGroupName joywebapp -Name joywebapp2).SiteConfig.IpSecurityRestrictions
$slot = Get-AzureRmWebAppSlot -ResourceGroupName joywebapp -Name joywebapp2 -Slot slot1
$slot.SiteConfig.ipSecurityRestrictions = $IpSecurityRestrictions
$slot | Set-AzureRmWebAppSlot
更新:
如果要使用Az
模块,则命令应如下所示。
$IpSecurityRestrictions = (Get-AzWebApp -ResourceGroupName joywebapp -Name joywebapp2).SiteConfig.IpSecurityRestrictions
$slot = Get-AzWebAppSlot -ResourceGroupName joywebapp -Name joywebapp2 -Slot slot1
$slot.SiteConfig.ipSecurityRestrictions = $IpSecurityRestrictions
$slot | Set-AzWebAppSlot