Configure Access to Azure Storage: SAS, Keys & Firewalls (AZ-104)
Configuring access to Azure Storage means controlling two things: which networks can reach a storage account, and how each request is authorized. At the network edge, the storage firewall admits selected subnets, public IP ranges and trusted Azure resources, and private endpoints remove public exposure entirely. For authorization, you choose between account access keys (full control, highest risk), shared access signature (SAS) tokens (scoped, time-limited delegated access), and Microsoft Entra ID with Azure RBAC data roles (identity-based, the recommended option). Stored access policies let you revoke or change a service SAS after issue, Shared Key authorization can be switched off entirely, and identity-based access lets Azure Files SMB shares authenticate users against AD DS, Microsoft Entra Domain Services or Microsoft Entra Kerberos. This lesson covers how to configure each control, how the SAS types and user delegation keys behave, and how to pick the least-privilege option for a scenario.
On this page9 sections
- Two layers: network access and authorization
- Storage firewalls and virtual networks
- Managing access keys
- Shared access signatures: account, service, and user delegation SAS
- User delegation SAS: keys, rights and revocation
- Stored access policies: making a service SAS revocable
- Comparing access keys, SAS, and Entra RBAC
- Identity-based access for Azure Files
- Scenario: granting a partner revocable read access
- Restrict storage access with IP rules, virtual network rules, resource instance rules, trusted services and private endpoints, including their limits
- Create account, service and user delegation SAS tokens and read their parameters (sp, st, se, sr, sip, spr, si)
- Explain user delegation key lifetime, permission intersection and revocation
- Use stored access policies to revoke or change an issued service SAS, and decide which fields belong in the policy
- Rotate access keys, set key and SAS expiration policies, and disallow Shared Key authorization
- Choose data-plane roles (blob and queue) at least-privilege scope instead of control-plane roles
- Configure identity-based access for Azure Files: identity sources, share-level roles, default share-level permission and NTFS ACLs
Storage firewalls and virtual networks
The storage firewall decides which networks may connect to the account's public endpoint. You change the account's Public network access setting from Enabled from all networks to Enabled from selected virtual networks and IP addresses (deny by default, then allow what you list), or to Disabled, which leaves private endpoints as the only way in.
The rule types
| Rule | What it admits | Requirements and limits |
|---|---|---|
| Virtual network rule | Traffic from a specific subnet, over the Azure backbone to the public endpoint | The subnet must have a Microsoft.Storage service endpoint enabled |
| IP network rule | Public IPv4 addresses or ranges, such as office egress IPs | Public addresses only — private RFC 1918 ranges are rejected; /31 and /32 prefixes are not accepted (add the addresses as single IPs); does not apply to requests from the same Azure region as the account |
| Resource instance rule | One named Azure resource instance (for example a specific Synapse workspace) using its managed identity | Its access is still limited by the RBAC role its managed identity holds |
| Trusted services exception | Whole Azure services on Microsoft's trusted list | Some services are trusted by service; others only when they authenticate with their managed identity |
Same-region traffic ignores IP rules. Requests from Azure resources in the same region as the storage account use private Azure addresses, so an IP rule for a VM's public IP never matches them. To admit a same-region VM, use a virtual network rule (with a service endpoint on its subnet), a private endpoint, or a resource instance rule / trusted services exception for an Azure service.
Portal data access comes from your browser. When you browse containers or file shares in the Azure portal, the data requests originate from your own client IP. Lock the firewall down without adding that IP and the portal shows an authorization-style error even though you hold the right role.
Private endpoints
A private endpoint gives the account a private IP address inside your virtual network, so traffic never uses the public endpoint and is reachable over peering, VPN and ExpressRoute. A private endpoint targets one sub-resource — blob, file, queue, table, dfs or web — so an account used privately for blobs and SMB file shares needs two endpoints. Each sub-resource has its own private DNS zone (for example privatelink.blob.core.windows.net, privatelink.file.core.windows.net). Clients must resolve the account name to the private IP: a VM in a peered virtual network that still resolves the public IP needs the zone linked to its own virtual network (or a DNS forwarder that uses the zone). With private endpoints in place you usually set public network access to Disabled.
Exceptions: trusted services versus resource instances
Allow Azure services on the trusted services list keeps platform features such as Azure Backup, Azure Monitor and Event Grid working after you lock the account down. For services that use trusted access based on managed identity (Data Factory, Synapse, Azure AI services and others), the exception only applies when the service authenticates with its managed identity — a connection configured with an account key or another secret is not covered by it — and the identity still needs a data-plane role such as Storage Blob Data Contributor to touch the data. When you want the firewall to admit one specific resource rather than every instance of a service, add a resource instance rule instead.
In short, only known public IP ranges maps to an IP rule, only one subnet maps to a virtual network rule backed by a service endpoint, no public exposure maps to a private endpoint, and admit one specific resource, not the whole service maps to a resource instance rule.
Managing access keys
Every storage account is created with two access keys, key1 and key2. Each key grants full, unrestricted control of the entire account — every blob, file, queue and table, with permission to read, write and delete. A key cannot be scoped to a single container or made read-only; possession of a key is total power over the account. This is why keys are described as all-or-nothing and are the highest-risk credential in Azure Storage. Requests signed with a key use Shared Key authorization.
Two keys exist to enable rotation without downtime: applications use key1; to rotate, you switch them to key2, regenerate key1, and later repeat in the other direction. Because one key stays valid while you regenerate the other, running clients never break. Store keys in Azure Key Vault rather than in app settings, and rotate on a schedule and immediately after any exposure.
Regenerating a key immediately invalidates every SAS signed with it, because account SAS and service SAS are both signed by an account key; a SAS cannot be re-signed with the other key. That is both a risk (you can break legitimate SAS holders) and the blunt emergency tool for revoking every ad-hoc SAS at once. A user delegation SAS is unaffected, because no account key signs it.
Key expiration policy
A key expiration policy sets a rotation interval in days. Keys older than the interval are flagged as due for rotation (in the portal and through Azure Policy), but nothing is rotated automatically — it is a reminder, not a rotation mechanism. To rotate automatically you build it yourself — for example Key Vault with Event Grid and Azure Functions — though moving clients to Microsoft Entra ID removes the need for keys altogether.
Disallowing Shared Key authorization
To remove keys from the picture entirely, set Allow storage account key access to Disabled (the AllowSharedKeyAccess property set to false). The account then rejects every request authorized with Shared Key:
| Stops working | Keeps working |
|---|---|
Connection strings and tools that use an account key (AccountKey=) | Requests authorized with Microsoft Entra ID (users, service principals, managed identities) |
| Account SAS tokens | User delegation SAS tokens (signed with Entra credentials) |
| Service SAS tokens signed with an account key | Anonymous public read access, if it is separately allowed |
Check clients before flipping the switch: Azure Monitor metrics split requests by authorization type, so you can find anything still using Shared Key. Rotation and key expiration policies do not block key use; only disallowing Shared Key does.
User delegation SAS: keys, rights and revocation
A user delegation SAS is signed with a user delegation key that a Microsoft Entra identity requests from the storage service, so no account key is ever handled. It is the SAS type Microsoft recommends, and it keeps working when Shared Key authorization is disallowed.
- Lifetime: a user delegation key is valid for at most seven days, and a SAS cannot outlive the key that signed it. The effective expiry is the earlier of the token's
seand the key's expiry. - Rights: the token grants only the intersection of its
sppermissions and the RBAC data rights of the identity that requested the key. Nothing stops the signer from putting permissions inspthat it does not hold — the token is created — but any request that needs those permissions fails with an authorization error when the token is used. Fix it by giving the signer a data role that includes the operation, at a scope that covers the target. - Requesting the key: the identity needs the
generateUserDelegationKeyaction. Storage Blob Delegator grants only that action and has no data actions, so on its own it lets the identity request a key but not sign a SAS that can actually read or write anything; the data rights come from a data-plane role. - Revocation: revoke all user delegation keys for the account (for example
Revoke-AzStorageAccountUserDelegationKeysoraz storage account revoke-delegation-keys), which invalidates every user delegation SAS at once, or remove the signer's role assignment so the intersection becomes empty (role changes can take a few minutes to propagate). - No stored access policies: a user delegation SAS cannot reference a stored access policy.
So a requirement for the most secure SAS, secured with Entra credentials or account keys must not be used points to a user delegation SAS, while a token that must be revocable per container through a policy points to a service SAS.
Stored access policies: making a service SAS revocable
A plain (ad-hoc) service SAS carries its permissions and times inside the signed string, so once issued it stays valid until it expires — short of regenerating the account key, which kills every SAS signed with that key across the account.
A stored access policy solves this. You define a named policy on a container (or file share, queue or table) and issue a service SAS that references the policy by name (si). The service checks the policy on each request, so you can:
- Revoke every SAS bound to it by deleting the policy, renaming it, or setting its expiry to the past — without touching account keys or any other container's tokens.
- Change the policy — extend or bring forward its expiry, or reduce its permissions — and every linked SAS inherits the change, keeping the same URLs.
Changes are not instant: Microsoft documents that creating, changing or deleting a stored access policy can take up to 30 seconds to take effect.
Where each field lives. Start time, expiry time and permissions must each be specified in either the token or the policy — never both, or the request fails authorization. Only values held in the policy can be changed after issue, so a design that must later cut permissions or move the expiry puts sp, st and se in the policy and leaves them out of the tokens.
A container, share, queue or table supports up to five stored access policies at a time. Policies apply only to a service SAS; account SAS and user delegation SAS cannot use them.
Comparing access keys, SAS, and Entra RBAC
The authorization choice usually comes down to whether the caller can have an Entra identity and how easily you must revoke it.
| Method | Granularity | Revocation | Best for |
|---|---|---|---|
| Access keys | Whole account, full control | Regenerate the key (breaks every client and SAS using it) | Administration and emergencies only |
| Service / account SAS | Chosen resources, permissions and time window | Stored access policy (service SAS), or key regeneration | Clients without an Entra identity |
| User delegation SAS | Scoped, time-limited, capped by the signer's RBAC | Revoke user delegation keys, or the signer's role | Handing a URL outside your directory with Entra-backed signing |
| Microsoft Entra ID + RBAC | Per-identity role assignments, down to one container or queue | Remove the role assignment; no shared secret | Users and apps that can have an identity |
Data-plane versus control-plane roles
Entra authorization to data needs a data-plane role. Control-plane roles such as Reader and Contributor manage the storage account resource; Reader alone reads no data. Contributor (and Reader and Data Access) can reach data only by listing the account keys — which is full access, so neither is a least-privilege data role.
| Role | Grants |
|---|---|
| Storage Blob Data Reader | Read and list containers and blobs |
| Storage Blob Data Contributor | Read, write and delete containers and blobs |
| Storage Blob Data Owner | Contributor rights plus managing POSIX ACLs and ownership (Data Lake Storage) |
| Storage Blob Delegator | Request a user delegation key only — no data actions |
| Storage Queue Data Reader | Peek messages and read queue properties |
| Storage Queue Data Message Sender | Add messages (producers) |
| Storage Queue Data Message Processor | Peek, receive and delete messages (consumers) |
| Storage Queue Data Contributor | Full queue and message management |
Assign data roles at the narrowest scope that works — a single container or queue is a valid scope. In line with Microsoft's recommendations (Entra ID first; user delegation SAS when a SAS is needed), a practical order from most to least preferred is Entra RBAC, user delegation SAS, service SAS (ideally with a stored access policy), then access keys.
Identity-based access for Azure Files
Azure Files SMB shares can authenticate users with their own identities over Kerberos instead of the storage account key, which is what makes them a drop-in replacement for an on-premises file server. You enable one identity source on the storage account — an account can use only one at a time, and switching sources briefly interrupts identity-based access.
| Identity source | Users | Clients |
|---|---|---|
| On-premises AD DS | AD DS users synced to Entra ID | Domain-joined or hybrid joined machines with line of sight to a domain controller |
| Microsoft Entra Domain Services | Cloud-only or synced Entra users | Machines (typically Azure VMs) joined to the managed domain, which needs network connectivity to it |
| Microsoft Entra Kerberos | Hybrid identities synced from AD DS, and cloud-only identities | Entra joined or hybrid joined clients — Entra ID issues the tickets, so no domain controller connectivity is needed |
The deciding factor is usually where the clients are and how they are joined. AD DS authentication needs line of sight to a domain controller, and Entra Domain Services needs clients joined to the managed domain; Entra Kerberos needs neither, because Entra ID issues the Kerberos tickets. Because an account has only one source, a mixed fleet of Entra joined and hybrid joined clients is served by the one source that supports both — Entra Kerberos.
Share-level and file-level permissions
Access is checked twice. Share-level permissions come from Azure RBAC roles assigned to users or groups:
- Storage File Data SMB Share Reader — read over SMB.
- Storage File Data SMB Share Contributor — read, write and delete over SMB.
- Storage File Data SMB Share Elevated Contributor — Contributor plus modifying Windows ACLs (NTFS permissions), needed to edit permissions in File Explorer with an identity rather than the account key.
Instead of assigning a role to every group, you can set a default share-level permission on the account; it applies to all authenticated identities on every file share in the account, leaving fine-grained control to NTFS. It starts as None (no access). When an identity also holds a specific SMB Share role, it gets the higher of the two — so a broad default can lift users above the role you assigned them.
Directory- and file-level permissions are standard Windows NTFS ACLs. Effective access is the more restrictive of the two layers: the share-level permission is a ceiling that NTFS cannot raise, and NTFS can only narrow what the share allows. A user whose NTFS rights include write still cannot change files through a read-only share-level permission, and a share role that allows write does not override an NTFS entry that grants only read. Troubleshoot by checking both layers.
Do not confuse the SMB roles with Storage File Data Privileged Reader / Privileged Contributor: those authorize access to file data over the REST API with Entra OAuth tokens and override NTFS ACLs. They are not share-level permissions for SMB mounts.
Scenario: granting a partner revocable read access
A partner company needs read-only access to the blobs in one container for the next two weeks, they have no identity in your Microsoft Entra tenant, and you must be able to cut off their access early if the project is cancelled.
Because the partner signs in with nothing of yours, you hand them a URL. A user delegation SAS would avoid account keys, but it cannot be revoked per container — only by revoking every user delegation key in the account or the signer's role — and it is capped at seven days, so it would need reissuing. The design that fits is a service SAS scoped to that container with read and list permissions, bound to a stored access policy that holds the permissions and the two-week expiry, with the token itself carrying only the policy name (si), plus spr=https and, if known, the partner's sip range.
Every requirement is met: access is scoped, read-only, time-limited and revocable. If the project is cancelled you delete the policy and, within about 30 seconds, the SAS stops working — no key regeneration and no impact on any other client. If the project is extended, you move the policy's expiry and the partner keeps the same URL. This only works while Shared Key authorization is allowed on the account; if your security baseline disallows it, the user delegation SAS is the remaining option.
Tip. Expect scenarios with a deciding constraint. A ban on account keys points to Entra RBAC or a user delegation SAS, and rejecting every key-signed request to disallowing Shared Key; changing or revoking issued tokens without reissuing them points to a stored access policy holding the fields. Expect to reason about what limits a user delegation SAS (key lifetime and the signer's data rights) and how a SAS expiration policy is enforced. Firewall items hinge on rule limits: which traffic IP rules can match, one private endpoint and DNS zone per sub-resource, and how trusted-service exceptions differ from resource instance rules. Azure Files items test choosing an identity source for a client type, the default share-level permission, and how share-level roles combine with NTFS ACLs.
- Storage access has two layers: networking (firewall rules, exceptions, private endpoints) and authorization (keys, SAS, Entra RBAC) — decide them separately.
- Prefer Microsoft Entra ID with Azure RBAC data roles whenever the caller can have an identity; use a SAS only for callers that cannot.
- IP rules take public addresses only (no RFC 1918, no /31 or /32 prefixes) and never match same-region traffic; use a virtual network rule with a Microsoft.Storage service endpoint, a private endpoint, or a resource instance rule instead.
- A private endpoint serves one sub-resource (blob, file, queue, table, dfs, web) with its own privatelink DNS zone, which must be linked to every client virtual network.
- Trusted access for managed-identity services needs managed identity authentication plus a data role; a resource instance rule admits one named resource.
- Access keys are all-or-nothing; rotate with two keys, and regenerating one immediately invalidates every SAS it signed. A key expiration policy only flags keys; disallowing Shared Key blocks keys, account SAS and key-signed service SAS.
- A user delegation SAS is signed with an Entra-issued key valid for at most seven days, grants only what both its sp and the signer's RBAC allow, and is revoked by revoking all user delegation keys or the signer's role.
- A stored access policy makes a service SAS revocable and editable (changes take up to 30 seconds); each of start, expiry and permissions lives in the token or the policy, never both.
- Azure Files uses one identity source per account; effective SMB access is the more restrictive of the share-level permission and NTFS ACLs, and an identity with both a default share-level permission and its own SMB role gets the higher of the two.
- A SAS expiration policy applies to every SAS type and is checked when a token is used: Log allows and records out-of-policy requests, Block denies them, and a SAS with no start time counts as out of policy.
Frequently asked questions
What is the difference between a SAS token and an access key?
An access key grants full, unrestricted control of the entire storage account and cannot be scoped or made read-only. A shared access signature (SAS) is a signed URL that grants only the permissions, resources and time window you specify, so it delegates limited access without handing over the key. Account SAS and service SAS are still signed with an access key, so regenerating that key invalidates them; a user delegation SAS is signed with Microsoft Entra credentials instead.
What is a user delegation SAS and why is it the most secure?
A user delegation SAS is signed with a user delegation key that a Microsoft Entra identity requests from Azure Storage, not with an account key. The key lasts at most seven days, the token can grant no more than the signer's own RBAC data rights, and it keeps working when Shared Key authorization is disabled. You revoke it by revoking all user delegation keys for the account or removing the signer's role. It cannot use a stored access policy.
Why would you use a stored access policy with a SAS?
A stored access policy lets you revoke or change a service SAS after you have issued it. The SAS references a named policy on the container, share, queue or table, and the policy holds the permissions and times. Deleting the policy or moving its expiry to the past revokes every linked SAS, and editing it extends or narrows them, within about 30 seconds and without regenerating account keys. Each field must be set in either the token or the policy, not both.
What happens when you disallow Shared Key authorization on a storage account?
Setting Allow storage account key access to Disabled makes the storage account reject every request authorized with an account key, including connection strings that contain the key, account SAS tokens and service SAS tokens signed with a key. Requests authorized with Microsoft Entra ID and user delegation SAS tokens keep working. Rotating keys or setting a key expiration policy does not block key use; only this setting does.
How do storage firewalls restrict access to a storage account?
The storage firewall controls which networks can reach a storage account's public endpoint. You switch public network access from all networks to selected virtual networks and IP addresses, then allow specific subnets (virtual network rules, which need a Microsoft.Storage service endpoint), public IP ranges (IP rules), named resource instances, and services on the trusted services list; everything else is denied. Setting public network access to Disabled leaves private endpoints as the only way in. The firewall only decides reachability: callers still need a key, a SAS or a role assignment.
Why does a storage firewall IP rule not let my Azure VM in?
Azure Storage IP network rules do not apply to requests that come from the same Azure region as the storage account, because that traffic does not arrive from the VM's public IP. Admit the VM with a virtual network rule for its subnet (which needs a Microsoft.Storage service endpoint) or through a private endpoint. IP rules also accept only public addresses and reject /31 and /32 prefixes, which you add as single IPs.
Which identity source should I use for Azure Files SMB access?
A storage account uses one identity source at a time. On-premises AD DS suits domain-joined clients that can reach a domain controller. Microsoft Entra Domain Services suits machines joined to that managed domain. Microsoft Entra Kerberos suits Entra joined and hybrid joined clients without domain controller connectivity, for both hybrid and cloud-only identities. Share-level RBAC roles and NTFS ACLs then both apply, and the more restrictive wins.
What is the difference between a service SAS and an account SAS?
Both are signed with a storage account key. A service SAS grants access to resources in one service, such as a single container, blob, share, queue or table, and can reference a stored access policy for revocation. An account SAS can cover several services in one token and service-level operations such as listing containers, but it cannot use a stored access policy. Use a service SAS for narrow, per-resource delegation.
Source
This lesson covers the "Implement and manage storage" domain of the official AZ-104 exam guide. Vendors revise their guides — check the source for the current version.
- Microsoft AZ-104 study guide — Microsoft Learn
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.