Azure Resource Manager IP Security Limitations Using Powershell

I am trying to use Powershell to set IP security restrictions. My syntax does not return any errors, but the settings do not change. The ipSecurityRestrictions property is a hash table.

$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 

This is not a problem, and there are no errors. To change a property that is not a hash table, such as phpVersion, the following code works:

 $p.phpVersion = "7.0" 

Has anyone successfully installed ipSecurityRestrictions using this method?

+5
source share
1 answer

ipSecurityRestrictions should be an array of objects. Try changing the code as follows. It works right 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 

enter image description here

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

enter image description here

We can also get powershell cmd from the azure resource.

enter image description here

+4
source

Source: https://habr.com/ru/post/1262330/


All Articles