Goal
Create a storage account the way a real admin does: the right type and redundancy, no anonymous access, TLS 1.2 only, access with Entra ID roles instead of keys, a short-lived SAS for one partner, and network access only from your own IP address. At the end you delete everything, so the lab costs almost nothing.
Before you start
- Open Cloud Shell (Bash) in the Azure portal, or run
az loginon your computer. - Choose a region close to you, for example
westeurope. Storage account names are global: use only small letters and numbers, 3–24 characters. - Set two variables you use in every task:
RG=rg-lab-storageandSA=st<yourname><4 digits>.
Tasks
Tick a task when it is done. Only your browser remembers it.
- Make the resource group
$RGand a StorageV2 account$SAwith ZRS redundancy, hot access tier, minimum TLS 1.2, HTTPS only and anonymous blob access disabled. - Turn off shared key access, so nobody can use the account keys any more.
- Give your own user the role Storage Blob Data Contributor on the account only (not on the subscription).
- Make a private container
reportsand upload a small file with your Entra ID login, not with a key. - Make a user delegation SAS for the file that allows only read, works only over HTTPS and ends in 1 hour. Open the file with
curland the SAS. - Allow network access only from your own public IP address (default action Deny). Show the network rules.
- Show the encryption settings (key source) and the redundancy of the account.
- Delete the resource group.
Check your work
az storage account show -g $RG -n $SA --query "{kind:kind, sku:sku.name, tls:minimumTlsVersion, https:enableHttpsTrafficOnly, anon:allowBlobPublicAccess, keys:allowSharedKeyAccess}" -o table
az role assignment list --scope $(az storage account show -g $RG -n $SA --query id -o tsv) -o table
az storage blob list --account-name $SA -c reports --auth-mode login -o table
az storage account network-rule list -g $RG --account-name $SAkindisStorageV2,skuisStandard_ZRS,tlsisTLS1_2,httpsisTrue,anonandkeysareFalse.- Your user has Storage Blob Data Contributor on the scope of the account.
- The blob list shows your file. A
curlwith the SAS gives the text; the same URL without the SAS gives an error. - The network rules show your IP address and the default action
Deny.
Hints
Show the hints
az storage account createhas the options--sku,--kind,--min-tls-version,--https-only,--allow-blob-public-access.az storage account update --allow-shared-key-access false.- Role assignments need a few minutes before they work. Wait and try again if you get
AuthorizationPermissionMismatch. - A user delegation SAS needs
--as-user --auth-mode loginand an expiry time in UTC (date -u -d '+1 hour' '+%Y-%m-%dT%H:%MZ'). - Your public IP:
curl -s https://ifconfig.me.
Solution
Show the solution
- Create the group and the account with safe settings.
- Stop key access.
az storage account update -g $RG -n $SA --allow-shared-key-access false - Give yourself a data role on the account only.
- Make the container and upload with your login.
- Make a read-only user delegation SAS for 1 hour.
- Allow only your IP address.
- Read encryption and redundancy.
az storage account show -g $RG -n $SA --query "{keySource:encryption.keySource, sku:sku.name}" -o table - Clean up.
az group delete -n $RG --yes --no-wait
My notes
No notes yet.