A Shared Access Signature grants delegated access to Azure Storage resources for a defined set of permissions and time. A user delegation SAS signed with a user delegation key is generally preferred for Blob Storage when Microsoft Entra authorization is available.
What you need to know
Create scoped Azure Storage SAS access with short expiry, least privilege and user delegation keys instead of exposing account keys.
Implementation steps
- Decide which container or blob the client needs and grant only the required permissions.
- Prefer a user delegation SAS for Blob Storage when the application can obtain a user delegation key through Microsoft Entra credentials.
- Set a short start and expiry window, accounting for clock skew and the operation duration.
- Return the SAS only over an authenticated, encrypted channel and avoid logging the full token.
- Monitor access and revoke or rotate the underlying delegation key or credentials according to the incident plan.
Example
// .NET: generate a user delegation SAS (core pattern)
var credential = new DefaultAzureCredential();
var service = new BlobServiceClient(new Uri(blobEndpoint), credential);
var key = await service.GetUserDelegationKeyAsync(
DateTimeOffset.UtcNow.AddMinutes(-5),
DateTimeOffset.UtcNow.AddHours(1));
// Build a BlobSasBuilder for the target blob with only required permissions.
Common pitfalls
- Do not issue account-wide write SAS tokens for a single-file upload.
- Avoid long expiry windows and logging query-string credentials.
- Check storage account SAS policy and clock-skew requirements.
Testing checklist
Verify the SAS can perform only the intended action, expires as expected and cannot access another container or blob.
Conclusion
Keep access and failure handling explicit, test the unhappy path and document the operational response so the integration can be supported confidently.