Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 10 of 47
❮Prev Next❯

Storage Firewalls and Virtual Network Rules

Module 2: Storage ⏱ 11 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Restrict a storage account to selected networks Switch the account to selected networks and add a VNet rule, an IP rule and the exception.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Open the storage account and, under Security + networking, select Networking. The firewall lives on the Firewalls and virtual networks tab.
    2. Today the account answers all networks. Pick Enabled from selected virtual networks and IP addresses. That sets the default action to Deny.
    3. Under Virtual networks select + Add existing virtual network and choose the app subnet.
    4. Under Firewall, add the office’s public range and tick Add your client IP address so you can still browse data from the portal.
    5. Keep Allow Azure services on the trusted services list so services such as Azure Backup and Event Grid still get in. Select Save.
    6. 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.

    😟 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
    🛠️ Solved with: Storage firewall

    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:

    ChoiceWhat it means
    Enabled from all networksDefault action Allow. Anyone on any network can try.
    Enabled from selected virtual networks and IP addressesDefault action Deny. Only the rules and exceptions below get in.
    DisabledNo 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/24 for an office. Private ranges (10.x, 172.16-31.x, 192.168.x) are refused, and /31 or /32 ranges 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. 1 Arrive

      A request reaches stcontosoprod.blob.core.windows.net.

    2. 2 Firewall

      Is it from an allowed subnet, IP, resource instance or trusted service? If not and the default is Deny: 403.

    3. 3 Authorize

      Only now does storage check the key, SAS or Microsoft Entra token.

    4. 4 Serve

      The blob is returned if both checks pass.

    What happens to one request
    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

    Retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5 · Select 2

    You need to ensure that a storage account accepts data requests only from the subnet snet-app in the virtual network vnet-app. Which two actions should you perform? Each correct answer presents part of the solution.

    Question 2

    Question 2 of 5

    The default network action of a storage account is set to Deny. A user on the internet presents a valid account SAS token from an IP address that is not listed in any network rule. What is the result?

    Question 3

    Question 3 of 5

    You add the IP rule 10.10.0.0/16 to a storage account so that on-premises users can connect through a site-to-site VPN. The rule is rejected. What should you do instead?

    Question 4

    Question 4 of 5

    After you set a storage account to allow access only from selected networks, Azure Backup can no longer back up an Azure file share in the account. You must restore backups without allowing additional public networks. What should you configure?

    Question 5

    Question 5 of 5

    Which Azure CLI command sets a storage account to block requests that do not match a network rule while allowing trusted Azure services?

    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. 1.Which CLI flag sets the firewall to block by default?Show

      az storage account update --default-action Deny

    2. 2.What must a subnet have before it can be used in a storage VNet rule?Show

      The Microsoft.Storage service endpoint.

    3. 3.Can an IP rule contain 10.0.0.0/16?Show

      No. IP rules accept public addresses only.

    4. 4.Which bypass value allows trusted Azure services?Show

      AzureServices.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.