Storage Firewalls and Virtual Network Rules
30-second answer
The storage firewall controls which networks can reach a storage account's public endpoint. Set the default action to Deny (in the portal, *Enabled from selected virtual networks and IP addresses*) and only these get in: subnets added as virtual network rules (they use the Microsoft.Storage service endpoint), public addresses in IP rules, specific resource instances, and trusted Azure services if you tick that exception. The firewall is checked before authorization, so a valid key or SAS from a blocked network still gets 403.
Simulate it » No Azure account neededExam objective: 2.1.1 Configure Azure Storage firewalls and virtual networks. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open the storage account and, under <strong>Security + networking</strong>, select <strong>Networking</strong>. The firewall lives on the <strong>Firewalls and virtual networks</strong> tab.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open the storage account and, under Security + networking, select Networking. The firewall lives on the Firewalls and virtual networks tab.
- Today the account answers all networks. Pick Enabled from selected virtual networks and IP addresses. That sets the default action to Deny.
- Under Virtual networks select + Add existing virtual network and choose the app subnet.
- Under Firewall, add the office’s public range and tick Add your client IP address so you can still browse data from the portal.
- Keep Allow Azure services on the trusted services list so services such as Azure Backup and Event Grid still get in. Select Save.
- Done. Requests from anywhere else get 403, even with a valid key or SAS. Same thing in the CLI: az storage account update --default-action Deny and az storage account network-rule add.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
The front door: the storage firewall
Every account has a public endpoint that accepts all networks by default. Set the default action to Deny and only what you list gets in: virtual network rules (subnets with the Microsoft.Storage service endpoint), IP rules (public addresses only) and trusted Azure services if you tick the exception.
🤔 What happens if…
Read this tour as text
- The front door: the storage firewall. Every account has a public endpoint that accepts all networks by default. Set the default action to Deny and only what you list gets in: virtual network rules (subnets with the Microsoft.Storage service endpoint), IP rules (public addresses only) and trusted Azure services if you tick the exception.
- Three ways in, plus one for file shares. Callers prove who they are with an account key (full control), a SAS (limited rights for limited time) or a Microsoft Entra ID token checked against RBAC data roles. For SMB file shares, users bring a Kerberos ticket from AD DS, Microsoft Entra Domain Services or Microsoft Entra Kerberos.
- SAS tokens and stored access policies. A service SAS can point at a stored access policy on the container (up to 5 per container). The policy holds the permissions and expiry, so deleting or editing it revokes every SAS that names it. An ad hoc SAS can only be revoked by regenerating the key that signed it.
- Rotate access keys. Each account has two keys so you can rotate without downtime: move apps to key2, regenerate key1, and next time do the reverse. A key expiration policy flags old keys. Regenerating a key kills every SAS signed with it.
- Encryption at rest. Azure Storage always encrypts data with AES-256. By default Microsoft manages the key. With a customer-managed key in Key Vault (soft delete and purge protection on), the account’s managed identity wraps and unwraps its data key with your key, and you can revoke it.
- Redundancy and a region outage. LRS keeps 3 copies in one datacenter, ZRS spreads 3 across availability zones, GRS adds an async copy in the paired region and GZRS combines both. RA- versions let you read the secondary. A customer-managed failover promotes the secondary when the primary region is down.
- Moving data: AzCopy and object replication. AzCopy moves files in parallel from the command line, signed in with Microsoft Entra ID (and a Storage Blob Data role) or with a SAS. Storage Explorer does the same with a GUI. Object replication keeps copying new block blobs to another account by itself.
- Access tiers and lifecycle management. Blobs sit in Hot, Cool (30-day minimum), Cold (90 days) or Archive (180 days, offline). A lifecycle management rule moves or deletes blobs by age or last access, about once a day. Reading an archived blob means rehydrating it first.
- Undo buttons: soft delete, versioning and snapshots. Blob soft delete and container soft delete keep deleted items for 1 to 365 days. Versioning keeps every previous version of a blob. For Azure Files, share snapshots are read-only point-in-time copies and share soft delete keeps a deleted share.
Contoso keeps invoices in a storage account that anyone on the internet can reach with the right key. Close the front door, let only the app subnet and the office in, hand auditors a SAS you can revoke on your own terms, then rotate a key the safe way.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Anyone on the internet with a leaked key can read your invoices.
😊 THE SOLUTION
Set the storage firewall to Deny and allow only your subnets and office IPs.
- Open to every network✓ Default action Deny
- App VMs need access✓ Virtual network rules
- Azure Backup gets blocked✓ Trusted services exception
Start with a question
If someone steals the key to your house, how do you still keep them out?
You put a guard at the gate of your housing society. The guard has a list: residents of Block A, the office van, the milk delivery. A stranger walks up holding a perfectly good copy of your house key. The guard doesn’t care about the key. The stranger isn’t on the list, so the stranger doesn’t get through the gate.
That’s the storage firewall. Keys and SAS tokens decide what someone can do. The firewall decides where they’re allowed to come from, and it checks first.
Explain it like I’m 10
The technical explanation
Every storage account has a public endpoint, such as https://stcontoso.blob.core.windows.net. Out of the box it accepts requests from all networks. The storage firewall (Microsoft calls it network security for the account) lets you narrow that down.
The settings on the Networking blade
In the portal go to the storage account, then Security + networking > Networking > Firewalls and virtual networks. Under Public network access you’ll see three choices:
| Choice | What it means |
|---|---|
| Enabled from all networks | Default action Allow. Anyone on any network can try. |
| Enabled from selected virtual networks and IP addresses | Default action Deny. Only the rules and exceptions below get in. |
| Disabled | No public access at all. Only private endpoints work. |
Once you pick selected networks, four kinds of exceptions open up:
- Virtual networks: add a subnet. The subnet needs the Microsoft.Storage service endpoint, and the portal offers to turn it on for you. Traffic then reaches storage over the Azure backbone and storage knows which subnet it came from.
- Firewall (IP rules): public IPv4 addresses or CIDR ranges, such as
198.51.100.0/24for an office. Private ranges (10.x, 172.16-31.x, 192.168.x) are refused, and/31or/32ranges aren’t supported, so add a single address without a prefix. There’s also a tick box to add your own client IP so the portal can still show data. - Resource instances: allow one specific resource, like a single Azure AI Search service, based on its managed identity.
- Exceptions: Allow Azure services on the trusted services list to access this storage account (Azure Backup, Event Grid, Azure Monitor and others), plus read access to storage logging and metrics.
Data plane, not management plane
The firewall guards data: blobs, files, queues and tables. It doesn’t stop az storage account show, listing keys or changing settings, because those go through Azure Resource Manager and are controlled by Azure RBAC. That’s why you can lock yourself out of reading blobs while still being able to fix the firewall.
The same thing in the CLI and PowerShell
# Block by default, but keep trusted Azure services working
az storage account update -g rg-storage-prod -n stcontosoprod \
--default-action Deny --bypass AzureServices
# Allow one subnet (it needs the Microsoft.Storage service endpoint)
az network vnet subnet update -g rg-storage-prod --vnet-name vnet-app -n snet-app \
--service-endpoints Microsoft.Storage
az storage account network-rule add -g rg-storage-prod --account-name stcontosoprod \
--vnet-name vnet-app --subnet snet-app
# Allow the office's public range
az storage account network-rule add -g rg-storage-prod --account-name stcontosoprod \
--ip-address 198.51.100.0/24
Update-AzStorageAccountNetworkRuleSet -ResourceGroupName rg-storage-prod -Name stcontosoprod `
-DefaultAction Deny -Bypass AzureServices
Add-AzStorageAccountNetworkRule -ResourceGroupName rg-storage-prod -Name stcontosoprod `
-IPAddressOrRange "198.51.100.0/24"
-
1 Arrive
A request reaches stcontosoprod.blob.core.windows.net.
-
2 Firewall
Is it from an allowed subnet, IP, resource instance or trusted service? If not and the default is Deny: 403.
-
3 Authorize
Only now does storage check the key, SAS or Microsoft Entra token.
-
4 Serve
The blob is returned if both checks pass.
Architect level Service endpoints or private endpoints?
A service endpoint keeps the storage account’s public IP but lets you say “only this subnet”. It’s free and quick. A private endpoint gives the account a private IP inside your VNet, so traffic never touches the public endpoint, and it works from on-premises over VPN or ExpressRoute. Many companies use a private endpoint and set public network access to Disabled. Service endpoints by default only work for accounts in the same region as the VNet (and its pair); Microsoft.Storage.Global endpoints extend that to any region.
Real-world business scenario
Contoso Retail (fictional)
- The problem
- An old connection string with an account key leaked in a public repo. Anyone who found it could download every customer invoice from anywhere in the world.
- What they used
- The team rotated the key, then set the storage firewall to Deny with a virtual network rule for the invoice app's subnet, an IP rule for head office and the trusted services exception for Azure Backup.
- Why that choice
- Even if a key leaks again, the attacker isn't calling from an allowed network, so the firewall returns 403 before the key is even checked.
- The result
- The next security review found the account unreachable from the internet, backups kept running, and the app needed no code change.
When to use it and when not to
✓ Use it when…
- Your data should only be reached from known subnets or offices.
- You need a quick extra layer on top of keys, SAS and RBAC.
- Azure services such as Backup still need to get in through the trusted services exception.
✕ Think twice when…
- Clients are anywhere on the internet, such as a public mobile app (use SAS or Entra ID instead).
- You need fully private connectivity from on-premises (use a private endpoint).
- You expect it to restrict management actions; it only covers data.
↔ Alternatives to consider
- Private endpoints with public network access disabled.
- Network security perimeter to group several PaaS resources behind one boundary.
- Microsoft Entra ID and RBAC to control who can act on the data.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What does setting a storage account firewall to Deny actually do?
Model answer
It changes the default for requests that don't match a rule. Anything not coming from an allowed subnet, an allowed public IP, an allowed resource instance or a trusted Azure service gets a 403, even if it presents a valid key or SAS. It doesn't change who is authorized, it changes where they're allowed to come from.
Intermediate A developer says the app VM can't reach storage after you set the firewall to Deny. You added the VM's public IP as an IP rule. What's wrong?
Model answer
If the VM is in Azure, especially in the same region, its traffic to storage doesn't arrive from its public IP. IP rules don't apply to requests from the same Azure region. I'd add the VM's subnet as a virtual network rule, which turns on the Microsoft.Storage service endpoint, or give storage a private endpoint.
Experienced developer After you locked the firewall, Azure Backup and some diagnostics stopped working. How do you fix it without opening the account up again?
Model answer
I'd tick the exception "Allow Azure services on the trusted services list to access this storage account", which in the CLI is --bypass AzureServices. If logging or metrics readers need access, I'd add Logging and Metrics to the bypass too. For a service that isn't on the trusted list, I'd use a resource instance rule for that specific resource.
Scenario Contoso wants the storage account reachable only from its app subnet and its head office. Walk me through it in the CLI.
Model answer
az storage account update with --default-action Deny and --bypass AzureServices. Then az storage account network-rule add with --vnet-name and --subnet for the app subnet, after making sure the subnet has the Microsoft.Storage service endpoint. Then network-rule add with --ip-address and the office's public CIDR. Finally I'd test a data call from outside and expect a 403.
Quick revision
Key points
- Portal path: storage account > Security + networking > Networking > Firewalls and virtual networks.
- Enabled from selected virtual networks and IP addresses = default action Deny.
- VNet rules need the Microsoft.Storage service endpoint on the subnet; the portal can enable it for you.
- IP rules take public IPv4 addresses and CIDR ranges only. No private ranges and no /31 or /32 prefixes.
- IP rules don't apply to clients in the same Azure region as the account.
- The trusted services exception (bypass AzureServices) lets services like Azure Backup in.
Important terminology
- Default action
- What the storage firewall does with a request that matches no rule. Allow (the default) or Deny.
- Virtual network rule
- A firewall rule that allows traffic from one subnet, which needs the Microsoft.Storage service endpoint turned on.
- IP network rule
- A firewall rule that allows a public IPv4 address or CIDR range, such as an office's internet range.
- Trusted services exception
- A firewall exception that lets listed Azure services, such as Azure Backup and Event Grid, reach the account even when the default action is Deny.
- Resource instance rule
- A firewall rule that lets one specific Azure resource, identified by its managed identity, reach the account.
- Service endpoint
- A subnet setting that sends traffic for an Azure service over the Azure backbone and tells the service which subnet it came from.
Common mistakes
- Adding an Azure VM's public IP as an IP rule and expecting it to work from the same region.
- Thinking a valid account key gets past the firewall. It doesn't.
- Forgetting your own client IP, then wondering why the portal can't list blobs.
Exam tips
- "Allow only one subnet" = virtual network rule plus Microsoft.Storage service endpoint.
- "Allow the on-premises office" = IP rule with its public range.
- "Azure Backup fails after the firewall change" = enable the trusted Microsoft services exception.
Five quick revision questions
-
1.Which CLI flag sets the firewall to block by default?Show
az storage account update --default-action Deny
-
2.What must a subnet have before it can be used in a storage VNet rule?Show
The Microsoft.Storage service endpoint.
-
3.Can an IP rule contain 10.0.0.0/16?Show
No. IP rules accept public addresses only.
-
4.Which bypass value allows trusted Azure services?Show
AzureServices.
-
5.Does the firewall apply to management operations such as listing keys?Show
No. It protects the data plane (blobs, files, queues, tables).
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: SAS Tokens and Stored Access Policies
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.