Lesson 2 of 5 Securing Access to Azure Storage

Delegating Access with Shared Access Signatures

A shared access signature grants limited, time-bound access to storage. This lesson explains the SAS types, their parameters and how they are revoked.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish between user delegation, service and account SAS.
  • Describe the main SAS parameters.
  • Explain how each type of SAS is revoked.

Types of SAS

A SAS is a query string appended to a resource URI, such as https://stcontoso.blob.core.windows.net/docs/a.pdf?sv=...&sp=r&se=...&sig=.... Azure Storage supports three types. A user delegation SAS is signed with a user delegation key that a Microsoft Entra security principal requests with generateUserDelegationKey permission, applies to Blob Storage and Data Lake Storage only, and is limited to the permissions of that principal; it is the recommended type because no account key is involved. A service SAS is signed with an account key and grants access to resources in one service: blobs, files, queues or tables. An account SAS is signed with an account key and can grant access to resources in several services and to service-level operations such as getting service properties.

User delegation SAS
Signed withUser delegation key (Microsoft Entra)
ServicesBlob and Data Lake Storage
Stored access policyNot supported
RevocationRevoke user delegation keys or the principal's role
Choose when Default choice for blobs
Service SAS
Signed withAccount key
ServicesOne service
Stored access policySupported
RevocationPolicy change or key rotation
Choose when Need a stored access policy, or files, queues, tables
Account SAS
Signed withAccount key
ServicesOne or more services
Stored access policyNot supported
RevocationKey rotation
Choose when Several services or service-level operations

The following diagram shows a user delegation SAS that shares one blob for 48 hours, and its parameters.

Sharing one blob for 48 hours when account key access is disabled. Only a user delegation SAS can be issued, signed with the Microsoft Entra credentials of a principal holding a Storage Blob Data role. It covers the single blob with read permission, expires in 48 hours, requires HTTPS and is limited to the partner's IP address.
The URI is abbreviated; values in angle brackets are placeholders.
Sort into groups

Which SAS type?

Exam skills 2.1.2

Choose the SAS type that fits each requirement.

Log in to try this activity Interactive activities are free with an account.

SAS parameters

The parameters define what the token allows. sp lists permissions such as read (r), add (a), create (c), write (w), delete (d) and list (l). st and se set the start and expiry times in UTC. sip limits the client IP addresses, and spr=https requires HTTPS. sr gives the resource (blob, container, share and so on) for service SAS, and ss and srt give services and resource types for account SAS. si references a stored access policy, and sig is the signature that prevents tampering.

SAS tokens are generated in the portal on the account's Shared access signature page (account SAS), on a container's or blob's Generate SAS page (choosing the account key, a stored access policy or user delegation key), in Storage Explorer, or with az storage blob generate-sas --as-user --auth-mode login for a user delegation SAS. A SAS expiration policy on the account sets a recommended maximum validity, and Azure Monitor logs record SAS use that exceeds it.

Match the pairs

Reading a SAS token

Exam skills 2.1.2

Match each SAS parameter with what it controls.

Log in to try this activity Interactive activities are free with an account.

Risks and revocation

Anyone holding a SAS URL can use it until it expires, so tokens should have the minimum permissions, short expiry times, HTTPS only and, where possible, IP restrictions. A key-signed ad hoc SAS cannot be revoked individually: the only way is to rotate the account key that signed it, which also invalidates every other SAS and client using that key. That is why service SAS tokens are often tied to a stored access policy, covered in the next topic. A user delegation SAS is limited to seven days and is revoked by revoking all user delegation keys or by removing the principal's data role.

Scenario questions

Revoking a SAS

Exam skills 2.1.2

Decide how each kind of SAS can be revoked.

Log in to try this activity Interactive activities are free with an account.
Worked example

Sharing a file securely

A partner must download one blob, contracts/q4.pdf, during the next 48 hours from their office address. The company has disabled storage account key access on the account. Which SAS should you create, and with which parameters?

With key access disabled, only a user delegation SAS can be issued, signed with Microsoft Entra credentials of a principal that has a Storage Blob Data role. Create it for the blob (sr=b) with read permission only (sp=r), an expiry 48 hours ahead, spr=https and the partner's public IP in sip. A service or account SAS requires an account key, so it cannot be created on this account.

Check yourself

Which SAS type is signed without an account key?

Show answer

The user delegation SAS, signed with a key obtained with Microsoft Entra credentials.

Exam Tips

Remember for the exam

  • Prefer a user delegation SAS for blobs; it uses Microsoft Entra credentials, not account keys.
  • Service SAS: one service; account SAS: several services and service-level operations.
  • A key-signed ad hoc SAS is revoked only by rotating the key.
  • Limit SAS tokens with permissions, expiry, HTTPS and IP restrictions.