Azure Resource Manager IP Security Restrictions using Powershell

前端 未结 2 554
醉话见心
醉话见心 2020-12-11 04:23

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

2条回答
  •  粉色の甜心
    2020-12-11 05:01

    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.

提交回复
热议问题