Secure and Share Storage: Access Keys, Shared Access Signatures, Entra ID Access, Firewalls, Private Endpoints and Encryption
Ways to Authorize
| Method | Notes |
|---|---|
| Microsoft Entra ID + RBAC | Best. Roles like Storage Blob Data Contributor. Works with managed identities |
| Shared access signature (SAS) | Limited, time-bound URL |
| Account keys | Full control. Treat like a root password. Rotate regularly |
| Anonymous access | Public containers. Disable unless truly needed |
Account Keys
bash
az storage account keys list -g rg-demo -n stdemo482 -o table
az storage account keys renew -g rg-demo -n stdemo482 --key key2 # rotate: switch apps to key1, renew key2, then swap
- Two keys allow rotation without downtime
- Store keys in Key Vault. Prefer Entra ID auth and disable shared key access when possible
Shared Access Signatures
| Type | Signed with | Notes |
|---|---|---|
| User delegation SAS | Entra ID credentials | Blob only, most secure |
| Service SAS | Account key | One service (blob, file, queue, table) |
| Account SAS | Account key | Many services |
bash
# Read-only link to one blob valid for 2 hours
az storage blob generate-sas --account-name stdemo482 -c images -n logo.png --permissions r \
--expiry $(date -u -d "+2 hours" +%Y-%m-%dT%H:%MZ) --https-only --auth-mode login --as-user --full-uri
- Set start and expiry, permissions (r, w, d, l), HTTPS only and optional IP range
- A stored access policy on a container lets you revoke a service SAS by changing the policy
Entra ID Access to Data
bash
az role assignment create --assignee asha@contoso.com --role "Storage Blob Data Contributor" \
--scope $(az storage account show -n stdemo482 -g rg-demo --query id -o tsv)
Firewalls and Private Endpoints
bash
az storage account update -n stdemo482 -g rg-demo --default-action Deny
az storage account network-rule add -g rg-demo --account-name stdemo482 --vnet-name vnet-app --subnet web
az storage account network-rule add -g rg-demo --account-name stdemo482 --ip-address 203.0.113.10
- Selected networks allows listed VNet subnets (service endpoint needed) and IP ranges
- Private endpoint gives the account a private IP in your VNet. Create the privatelink.blob.core.windows.net private DNS zone and link it to the VNet
- Then disable public network access
Encryption
- At rest: always on (AES-256). Keys can be Microsoft-managed or customer-managed in Key Vault
- In transit: require HTTPS and set minimum TLS 1.2
- Infrastructure encryption adds a second layer
Monitoring
- Turn on diagnostic settings to send storage logs to Log Analytics
- Use Microsoft Defender for Storage for threat alerts
Practice
- Create a user delegation SAS valid for one hour and test the link
- Rotate a storage key safely
- Restrict an account to one VNet subnet
- Assign a data role to a user and read a blob with
--auth-mode login
Conclusion
Prefer Entra ID access, use short user delegation SAS tokens, guard keys, restrict networks with firewalls or private endpoints and keep encryption and logging on.
Quick Summary: authorization; keys; SAS; Entra; firewalls; encryption; monitoring.

