Created
August 9, 2021 03:00
-
-
Save owensengoku/32fd04c5c44eed576319034ee137b22b to your computer and use it in GitHub Desktop.
Set firewall rule with Service Tag IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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