Configuring Azure Storage Firewall Rules
This lesson explains the rule types, the exceptions, and how the firewall relates to private endpoints.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the public network access options.
- Choose among the source rule types.
- Compare service endpoints with private endpoints.
- Configure firewall rules from the command line.
Public network access settings
By default, a storage account accepts connections from any network, provided that the request is authorized. The Networking page gives three positions: enabled from all networks, enabled from selected virtual networks and IP addresses, or disabled. The choice of selected networks turns on firewall rules, and enabling them blocks all incoming requests by default, except those that a rule admits. It is therefore wise to add exceptions before making the change, or to make the change during a planned window.
Firewall rules apply to all protocols, including REST and SMB. Requests are refused with error 403 if they come from a disallowed source. As with Key Vault, the portal can then show a message that access to the data is blocked, even for an Owner, because the browser's address is not allowed.
Rule types
Four kinds of source can be admitted. The following table compares them, moving from the broadest to the most precise control.
| Source | How it is identified | Typical use |
|---|---|---|
| IP network rule | A public IPv4 address or CIDR range | An on-premises network with a fixed public address |
| Virtual network rule | A subnet with the Microsoft.Storage service endpoint | Workloads in Azure subnets |
| Resource instance rule | A specific Azure resource type and name, with its managed identity | One Azure service, such as a named Azure AI Search service |
| Trusted Azure services | A listed set of first-party services | Services such as Azure Backup or Azure Monitor |
IP rules do not accept private addresses from RFC 1918, or small ranges of /31 and /32 in CIDR notation; those must be listed as individual addresses. A service endpoint sends a subnet's traffic to Azure Storage along the Microsoft backbone, and identifies the subnet to the account, but the account keeps its public address. A storage account in the same region as a client treats that traffic differently from public traffic, so an IP rule does not apply to clients in the same region.
Which firewall rule?
Resource instances and trusted services
A resource instance rule is the precise way to admit an Azure service. It names one resource, or all resources of a type in a subscription, and it relies on that resource's managed identity having a suitable role. The exception for trusted Azure services is broader, because it admits every instance of a listed service, potentially including those in other tenants, although each must still be authorized.
When a choice is offered, prefer the resource instance rule. A scenario with phrases like only this specific Azure AI Search service or without allowing other instances points to it.
Private endpoints and the firewall
A private endpoint gives the storage account a private address, one for each sub-resource such as blob, file or dfs, so a client that uses several services needs several endpoints. Clients resolve the account's name to the private address through the zone privatelink.blob.core.windows.net. Firewall rules do not apply to private endpoint traffic, so a common design disables public network access and uses endpoints only. A private endpoint needs a general-purpose v2 account.
The following comparison shows how a service endpoint and a private endpoint differ, as candidates must be able to select between them.
Network Security Perimeter provides another option for PaaS resources, with a logical boundary around several resources and with rules for both inbound and outbound access. A service endpoint policy can limit a subnet's service endpoint to named accounts, which reduces the risk of data being copied to an attacker's account.
Service or private endpoint?
Configuring rules
The following commands set the default action to Deny, admit a subnet, and admit an IP range. The order shown adds the allowances last only for brevity. In production, add them first.
az storage account update --name ACCOUNT --resource-group RG --default-action Deny --bypass AzureServices Logging Metrics
az storage account network-rule add --account-name ACCOUNT --resource-group RG --subnet SUBNET_ID
az storage account network-rule add --account-name ACCOUNT --resource-group RG --ip-address 203.0.113.0/24The --bypass value controls the trusted services exception, and whether logs and metrics can still be read. Check any service that reads from the account, because Azure Monitor and Azure Backup can fail if that exception is removed.
After the firewall change
Admitting one Azure service
A storage account must reject all public traffic. One named Azure AI Search service in the same tenant must index blobs, and on-premises users must upload through an ExpressRoute connection. Other Azure AI Search services must not be able to reach the account at network level. What should you configure?
Set the account to selected networks or disable public access, add a resource instance rule for the named service, and give its managed identity Storage Blob Data Reader. For on-premises users, add a private endpoint reached through ExpressRoute, with DNS forwarding for privatelink.blob.core.windows.net.
The trusted services exception might admit other instances, which the scenario forbids. A service endpoint cannot serve on-premises clients. An IP rule cannot take a private range.
A client reaches blobs through a private endpoint, and needs file shares too. What must be added?
Show answer
A second private endpoint for the file sub-resource, since each endpoint serves one sub-resource.
Exam Tips
Remember for the exam
- Enabling rules blocks everything that a rule does not admit.
- Prefer a resource instance rule to the trusted services exception.
- A private endpoint serves on-premises clients; a service endpoint does not.
- Each storage sub-resource needs its own private endpoint.