When managing Azure Storage Accounts, it’s essential to control access by restricting allowed IP addresses. Manually updating these restrictions can be cumbersome, especially when dealing with frequently changing IP ranges. To address this challenge, I developed a Power Automate custom connector that automates fetching and processing Azure IP ranges using Microsoft’s Azure IP Ranges and Service Tags JSON files.
While my initial use case focused on automating Azure IP Ranges and Service Tags, this solution can also be adapted to work with custom lists of IP addresses. Many of the actions in this connector, such as reducing CIDR blocks and generating IP rules, can be applied to any list of IP addresses. This allows users to integrate their own IP management workflows and leverage the Azure Management API to dynamically update firewall rules.
I collaborated with Chris Chin to refine this idea, ultimately simplifying the process of updating storage account firewall rules dynamically.
I needed to update an Azure Storage Container’s IP restrictions to allow specific Azure service IPs. The IP addresses I required were within Microsoft’s downloadable JSON file for Azure IP Ranges and Service Tags (available here). The problem?
To automate this process, I created a Power Automate custom connector that performs the following:
/30
are included.The Power Automate flow consists of the following steps:
GetDirectDownloadUrl
action.GetIPAddressesByServiceTag
action.CIDRReducer
, ensuring only /30
or smaller prefixes are included. This action also included an output for Reduced Count, so you can check to make sure your IP addresses are less than 400 at this point.GenerateIPRules
, formatting them for Azure Storage firewall.defaultAction
set to Deny
and ipRules
containing the allowed list.Overall flow diagram generated using PowerDocu
To update the storage account firewall, I used the following API request:
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}?api-version=2024-01-01
For GCC or GCCH, use:
PATCH https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}?api-version=2024-01-01
The authentication method used was App Registration, with the Storage Account Contributor
role assigned.
Before using this solution, you’ll need to set up an App Registration in Entra ID and assign it the necessary permissions on the Azure Storage Account.
Once set up, this App Registration will authenticate API calls to update storage firewall rules.
You can install this solution by downloading and importing the provided solution file or by manually using the PACONN or PAC CLI tools.
You can directly download and import the Power Platform solution file:
.zip
file.If you prefer using the PACONN CLI tool, follow these steps:
paconn
) following this guide.paconn create --api-definition apiDefinition.swagger.json --icon icon.png --script script.c
This connector includes a code file, so you must use the --script
option.
Alternatively, you can use the Power Platform CLI (PAC CLI):
pac connector create --api-definition apiDefinition.swagger.json --script-file script.c
The --script-file
option is required since this connector includes a custom script.
By leveraging Power Automate and a custom connector, I eliminated the need for manual updates to Azure Storage firewall rules. This solution dynamically fetches the latest IP ranges, optimizes CIDR blocks, and seamlessly updates the storage account via API—all without requiring user intervention.
Big thanks to Chris Chin for helping refine this approach!
Original Post http://www.richardawilson.com/2025/03/automating-azure-storage-account-ip.html