Identity and access in one picture
πͺͺMicrosoft Entra ID
Signs in users, groups, apps and managed identities; issues tokens
πAzure RBAC role assignment
Identity + role (e.g. Storage Blob Data Reader) + scope (account, container)
ποΈResource
The storage account checks the token's roles before answering
RBAC: roles a data engineer uses
| Role | Plane | Allows |
|---|---|---|
| Owner / Contributor / Reader | Control | Manage (or view) the resource itself; not the data inside |
| Storage Blob Data Reader | Data | Read files |
| Storage Blob Data Contributor | Data | Read, write, delete files |
| Storage Blob Data Owner | Data | All of the above + set ACLs on ADLS Gen2 |
| Key Vault Secrets User | Data | Read secret values |
| Key Vault Secrets Officer | Data | Manage secrets |
| Data Factory Contributor | Control | Create and manage factories |
# Give the factory's managed identity read/write access to the lake only (not run: needs Azure)
az role assignment create \
--assignee-object-id <factory-principal-id> --assignee-principal-type ServicePrincipal \
--role "Storage Blob Data Contributor" \
--scope /subscriptions/<sub>/resourceGroups/rg-shopkart-dev/providers/Microsoft.Storage/storageAccounts/stshopkartdevLesson 4 does the same assignment in Bicep, validated with Bicep's build.
Managed identities: no passwords at all
Data Factory, Databricks (through an access connector), Functions and VMs can have a managed identity. Azure gives the resource tokens automatically, so there's no secret to store, leak or rotate. In code, DefaultAzureCredential picks the right identity wherever it runs:
# Not run here (needs Azure). The same code works on your laptop and in production:
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from azure.storage.blob import BlobServiceClient
cred = DefaultAzureCredential() # laptop: your 'az login'; in Azure: the resource's managed identity
secrets = SecretClient("https://kv-shopkart-dev.vault.azure.net", credential=cred)
api_key = secrets.get_secret("supplier-api-key").value # needs 'Key Vault Secrets User'
lake = BlobServiceClient("https://stshopkartdev.blob.core.windows.net", credential=cred)
print([c.name for c in lake.list_containers()]) # needs a Storage Blob Data role| Where the code runs | DefaultAzureCredential uses |
|---|---|
| Your laptop | Your Azure CLI / VS Code sign-in (az login) |
| CI pipeline (GitHub Actions) | Workload identity federation (environment variables) |
| Azure resource (Function, VM, AKSβ¦) | That resource's managed identity |
Key Vault: for the secrets you can't avoid
- Store partner API keys, third-party database passwords and certificates in Key Vault, never in code, notebooks or pipeline JSON.
- Use the RBAC permission model (Key Vault Secrets User for apps), soft delete and purge protection.
- Data Factory linked services and Databricks secret scopes can read Key Vault secrets directly (see our ADF course, lesson 3).
SAS tokens: share one file, briefly
A shared access signature is a signed URL granting limited access. We created a read-only, one-hour SAS on Azurite and tested it:
from datetime import datetime, timedelta, timezone
from azure.storage.blob import generate_blob_sas, BlobSasPermissions, BlobClient
sas = generate_blob_sas(
account_name="devstoreaccount1",
container_name="lake",
blob_name="curated/daily_revenue/daily_revenue.parquet",
account_key=service.credential.account_key,
permission=BlobSasPermissions(read=True), # read only
expiry=datetime.now(timezone.utc) + timedelta(hours=1)) # valid for one hour
url = f"http://127.0.0.1:10000/devstoreaccount1/lake/curated/daily_revenue/daily_revenue.parquet?{sas}"
print(url.split("?")[1].split("&sig=")[0] + "&sig=...")
print(len(BlobClient.from_blob_url(url).download_blob().readall()), "bytes read with the SAS link")
try:
BlobClient.from_blob_url(url).upload_blob(b"hack", overwrite=True)
except Exception as e:
print("write with a read-only SAS ->", type(e).__name__, getattr(e, "error_code", ""))se=2026-11-29T06%3A10%3A31Z&sp=r&sv=2026-10-06&sr=b&sig=...
2299 bytes read with the SAS link
write with a read-only SAS -> HttpResponseError AuthorizationPermissionMismatchThe token's fields tell the story: sp=r (read only), se= (expiry), sr=b (one blob). Reading worked; uploading with the same link was refused with AuthorizationPermissionMismatch. On real Azure, prefer a user delegation SAS (signed with Entra ID) and keep allowSharedKeyAccess off so account keys can't be used at all.
π― Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1What is a managed identity and why use it?Fresher+
Q2Control plane vs data plane in Azure RBAC?1β3 yrs+
Q3RBAC vs ACLs in ADLS Gen2?1β3 yrs+
Q4How would you secure a data platform end to end?3+ yrs+
Key takeaways
- βIdentities plus least-privilege roles beat keys and passwords.
- βRemember control plane vs data plane: it explains most 403s.
- βKey Vault for what's left; SAS only short and narrow.
- βNext: deploy all of this as code with Bicep.
Frequently asked questions
What's the difference between Entra ID and RBAC?
Microsoft Entra ID (formerly Azure AD) is the identity directory: it knows who users, groups and applications are and signs them in. Azure RBAC decides what those identities may do on which resources, through role assignments (role + identity + scope).
Why does my user see the storage account but get 403 reading files?
Owner/Contributor are control-plane roles: they manage the resource but don't grant data access. Reading blobs with Entra ID needs a data-plane role such as Storage Blob Data Reader or Contributor, which can take a few minutes to apply.
What is a managed identity?
An identity in Entra ID that Azure creates for a resource (a data factory, VM, Function, Databricks access connector). The resource gets tokens automatically; there are no passwords or keys for you to store or rotate. System-assigned lives and dies with the resource; user-assigned is a separate resource you can attach to many.
When are SAS tokens OK?
For short-lived, narrowly scoped sharing: one file, read-only, expiring in hours, for example letting a partner download a report. Prefer user delegation SAS (signed with Entra ID) over account-key SAS, and never hand out long-lived account-level SAS.
π§ Quick check: Azure security
1. A role assignment is made of...
2. Data Factory must read the lake. Best approach?
3. Our read-only SAS link tried to upload. Result?
4. Contributor on a storage account lets you read blobs with Entra ID?
Checking your accessβ¦