Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save owensengoku/32fd04c5c44eed576319034ee137b22b to your computer and use it in GitHub Desktop.
Save owensengoku/32fd04c5c44eed576319034ee137b22b to your computer and use it in GitHub Desktop.
Set firewall rule with Service Tag IP
#!bin/bash
cidrs=( $(az network list-service-tags -l "westus2" --query "values[?id=='Storage.WestUS2']" | jq -r '.[0].properties.addressPrefixes | .[]' ) )
for i in "${cidrs[@]}"
do
if [[ $i =~ .*:.* ]]
then
echo "IPv6"
else
echo "IPv4"
printf 'CIDR is:%s\n' "$i"
az storage account network-rule add --resource-group MyResourceGroup --account-name MyStorageAccount --ip-address $i
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment