Bash Scripts

Add list of IP’s to storage Account

# Set the storage account name
$storageAccountName = "<storage-account-name>"

# Set the resource group name
$resourceGroupName = "<resource-group-name>"

# Set the list of IP addresses to whitelist
$ipAddresses = @("<ip-address-1>", "<ip-address-2>", "<ip-address-3>")

# Get the storage account object
$storageAccount = Get-AzStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName

# Get the network rules object for the storage account
$networkRules = Get-AzStorageAccountNetworkRuleSet -ResourceGroupName $resourceGroupName -Name $storageAccountName

# Add the IP addresses to the whitelist
foreach ($ipAddress in $ipAddresses) {
  $networkRules.IPRules.Add($ipAddress)
}

# Update the storage account with the new network rules
$storageAccount | Set-AzStorageAccountNetworkRuleSet -NetworkRuleSet $networkRules

Add list of IP’s to SQL Server Firewall

Create array of IPs to be added to the firewall
IP_ARRAY=(123.456.789.0 123.456.789.1 123.456.789.2)

Loop through each IP in the array
for IP in "${IP_ARRAY[@]}"
do

Add the IP to the Azure SQL Server firewall
az sql server firewall-rule create --resource-group myResourceGroup --server myServer --name myFirewallRule --start-ip-address $IP --end-ip-address $IP
done

echo "Finished adding IPs to Azure SQL Server firewall."

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *