使用Powershell的Azure Resource Manager IP安全限制 [英] Azure Resource Manager IP Security Restrictions using Powershell

查看:95
本文介绍了使用Powershell的Azure Resource Manager IP安全限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Powershell设置IP安全限制.我的语法没有返回任何错误,但是设置没有改变. "ipSecurityRestrictions"属性是一个哈希表.

I'm trying to use Powershell to set IP Security Restrictions. My syntax is not returning any errors, but settings are not changing. The "ipSecurityRestrictions" property is a hashtable.

$r = Get-AzureRmResource -ResourceGroupName *resource-group-name* -ResourceType Microsoft.Web/sites/config -ResourceName resourcename/web -ApiVersion 2016-08-01
$p = $r.Properties
$p.ipSecurityRestrictions = @{ ipAddress = "0.0.0.0"; subnetMask = "0.0.0.0" }
Set-AzureRmResource -ResourceGroupName *resource-group-name* -ResourceType Microsoft.Web/sites/config -ResourceName resourcename/web -ApiVersion 2016-08-01 -PropertyObject $p

这不是权限问题,并且没有返回错误.要更改非哈希表的属性(例如phpVersion),以下代码可以正常工作:

It's not a permissions issue, and there are no errors returned. To change a property that is not a hashtable, such as the phpVersion the following code is working fine:

$p.phpVersion = "7.0"

任何人都可以使用此方法成功设置ipSecurityRestrictions吗?

Anyone successfully set ipSecurityRestrictions using this method?

推荐答案

ipSecurityRestrictions应该是对象数组.请尝试如下更改代码.它对我来说正常工作.

ipSecurityRestrictions should be object array. Please have a try to change code as following. It works correctly for me.

$r = Get-AzureRmResource -ResourceGroupName "Resoucegroup name" -ResourceType Microsoft.Web/sites/config -ResourceName resourcename/web -ApiVersion 2016-08-01

$p = $r.Properties
$p.ipSecurityRestrictions = @()
$restriction = @{}
$restriction.Add("ipAddress","0.0.0.0")
$restriction.Add("subnetMask","0.0.0.0")
$p.ipSecurityRestrictions+= $restriction

Set-AzureRmResource -ResourceGroupName  "Resoucegroup name" -ResourceType Microsoft.Web/sites/config -ResourceName resourcename/web -ApiVersion 2016-08-01 -PropertyObject $p

之后,我们可以从天蓝色的资源中获取结果 ( https://resources.azure.com ).

After that we can get the result from the resources azure (https://resources.azure.com).

我们还可以从资源天蓝色中获得powershell cmd.

We also can get powershell cmd from the resource azure.

这篇关于使用Powershell的Azure Resource Manager IP安全限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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