使用 Powershell 的 Azure 资源管理器 IP 安全限制 [英] Azure Resource Manager IP Security Restrictions using Powershell

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

问题描述

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

$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";子网掩码 = "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,以下代码可以正常工作:

$p.phpVersion = "7.0"

有人用这个方法成功设置过ipSecurityRestrictions吗?

解决方案

ipSecurityRestrictions 应该是对象数组.请尝试更改代码如下.它适合我.

$r = Get-AzureRmResource -ResourceGroupName "资源组名称" -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+= $restrictionSet-AzureRmResource -ResourceGroupName "资源组名称" -ResourceType Microsoft.Web/sites/config -ResourceName resourcename/web -ApiVersion 2016-08-01 -PropertyObject $p

之后我们可以从资源azure中得到结果(

我们也可以从azure资源中获取powershell cmd.

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

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"

Anyone successfully set ipSecurityRestrictions using this method?

解决方案

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

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

We also can get powershell cmd from the resource azure.

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

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