0

I am trying to add a list of IP addresses (using a variable) to a security rule during deployment. Azure CLI isn't accepting the values as a variable, however the same value works if added manually.

Has anyone come across a similar issue? or know of another automated way around this.

This doesn't work

$ipWhitelist = '11.11.11.11 22.22.22.22' (I have tried many combinations i.e. space or comma between the addresses etc.)

az network nsg rule update --resource-group myRG --nsg-name myNGS  -n MyRule --source-address-prefixes $ipWhitelist

Security rule XXXXXXXXX has invalid Address prefix. Value provided: 11.11.11.11 22.22.22.22
Security Rule XXXXXXXXX has invalid Address prefix. Value provided: 11.11.11.11,22.22.22.22

Variables work with single IP address

$ipWhitelist = '11.11.11.11'

So issues seems to be with variables with multiple ip addresses.

However this works fine

az network nsg rule update --resource-group myRG --nsg-name myNGS  -n MyRule --source-address-prefixes 11.11.11.11 22.22.22.22
SANM2009
  • 1,918
  • 2
  • 12
  • 30

2 Answers2

3

You could run the following Comma-separated string list on PowerShell.

$ipWhitelist = "11.11.11.11", "22.22.22.22"

az network nsg rule update --resource-group nancytest --nsg-name win-nsg  -n NRMS-Rule-103 --source-address-prefixes $ipWhitelist

enter image description here

Nancy
  • 26,865
  • 3
  • 18
  • 34
0

If it is comma separated, convert it to array.

For instance "Split" function will be converted into array of string.

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73