Use PowerShell to enable Azure Storage Account Firewall Rules

Use PowerShell to enable Azure Storage Account Firewall Rules

In this post I’ll show you how to Use PowerShell to enable Azure Storage Account Firewall Rules.

Be sure to be have AzureRM PowerShell 4.4.1 module installed.

Login to your Azure Account

Launch Powershell and start by Login to your Azure Account.

    Login-AzureRmAccount

Set Resource Group and Storage Account Name Variables

Set the following variables

    $resourceGroupName = "[THE NAME OF THE RESOURCE GROUP]"
    $storageAccountName = "[THE NAME OF THE STORAGE ACCOUNT]"

Enable the Firewall

To enable the firewall you’ll need to Deny all trafic to the storage account using the DefaultAction parameter and then allow Azure Services to connect to it with the Bypass parameter.

    Update-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $resourceGroupName -Name $storageAccountName -DefaultAction Deny -Bypass AzureServices,Metrics,Logging

To allow an IP Address or an IP Address range you can run the following commands changing the value of the IPAddressOrRange parameter:

    Add-AzureRMStorageAccountNetworkRule -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -IPAddressOrRange "79.159.46.90" 
    Add-AzureRMStorageAccountNetworkRule -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -IPAddressOrRange "79.159.46.0/24" 

Hope it helps!

Last modified December 12, 2024: new post (bf52b37)