What this thread does
Do first: run az webapp identity show --resource-group GROUP --name APP and compare the attached identity's principal ID with the target resource's role assignment.
Short answer
As of November 2026, use current Azure App Service/CLI docs; Python SDK reference baseline is azure-identity 1.26.0, published October 1, 2026. Attach identity first, authorize its service principal on the target resource, then select that same identity in the SDK.
Choose / don't choose
- System-assigned: choose a unique app identity whose identity lifecycle follows the app; don't expect it to survive deletion/recreation. Clean up orphaned role assignments separately. Lifecycle.
- User-assigned: choose a preprovisioned identity that survives resource replacement, or identical replicas with the same permission set; don't share it across unrelated privileges. Create using
az identity create --resource-group GROUP --name IDENTITY. Identity CLI, selection. - Data role: choose only the target operation's data-plane permissions; Blob authorization.
Not for: GitHub Actions OIDC role assumption; see github-actions-oidc-credentials-runner-communication-errors.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
az webapp identity assign --identities | Quote '[system]' for system identity (default); provide intended user-assigned identity resource ID for that identity | Current App Service CLI | Webapp identity, App Service |
az role assignment create --assignee-object-id | Managed identity's principalId, not its client/application ID | Current Azure CLI | Role assignment |
--assignee-principal-type | ServicePrincipal with object ID; avoids Graph propagation lookup failures | Current Azure CLI | Role assignment |
--role | Storage Blob Data Reader only for read-only blob access; choose the actual service's data role otherwise | Current Azure Blob conditional example | Blob roles |
--scope | Exact container resource ID for one-container access; avoid subscription/resource-group scope unless needed | Current Azure Blob conditional example | Scope format |
App Service token client_id | User-assigned identity's client ID; omit identity selectors only for intended system identity | Current App Service token endpoint; SDK must select equivalent identity | Identity selectors |
For a container scope use /subscriptions/SUBSCRIPTION/resourceGroups/GROUP/providers/Microsoft.Storage/storageAccounts/ACCOUNT/blobServices/default/containers/CONTAINER. Values are resource placeholders, not a credential. Container scope.
Order of operations
1. For user-assigned identity, create the identity and then attach it to the app; capture resource ID, principal ID and client ID as distinct identifiers. Attach it to the correct app/slot. App Service. 2. Assign the least data role to the principal ID and narrow target scope. For a new principal, use both object-ID and ServicePrincipal flags rather than a name lookup. Confirm subscription/tenant and use bounded retry if replication still delays the assignment. CLI flags. 3. Select the intended identity in the SDK and request the target resource's token. Inspect error stage, credential chosen and resource audience without printing tokens or identity endpoint headers. DefaultAzureCredential can select a different account than intended. SDK troubleshooting. 4. Allow documented role propagation, then exercise allowed and forbidden operations. Blob role updates can take up to 10 minutes; managed-identity caches can take around 24 hours. Don't widen scope while waiting for a known propagation delay. Blob propagation, managed-identity caching.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ManagedIdentityCredential authentication unavailable. | App Services host environment variables weren't present | Confirm identity attachment and host endpoint availability; use the intended hosted credential rather than granting more data roles | Python SDK guide |
PrincipalNotFound | Principal ID does not exist in the directory | Confirm principal ID; pass --assignee-object-id plus --assignee-principal-type ServicePrincipal; retry transient replication | RBAC troubleshooting |
403 Forbidden from target service | Authentication succeeded but service denied authorization | Confirm actual principal and token audience; inspect service-specific denial and target role assignment | SDK diagnosis, Blob data roles |
Managed Identity response was not in the expected format. | Historical identity-endpoint 403 during Function deployment | Distinguish endpoint response from data-service 403; inspect host/SDK diagnostics before changing RBAC | Cameron Taggart, August 11, 2022 |
Taggart's report is in Azure/azure-sdk-for-net and concerns Functions; it is not evidence of a Python SDK regression or a universal RBAC fix.
Missing
- A token acquisition failure and a resource's denied data operation require different fixes.
- don't assume subscription Contributor or Reader authorizes blob content
- System identity must be enabled before its principal exists.
- Actual target service, app/slot, identity IDs and operations are unspecified. Blob Reader/container scope is conditional; it must be replaced for write access or a different service. No universal propagation sleep makes every authorization change immediate.
Checked
2026-11-12; SDK baseline and release date linked above; current Azure CLI/App Service docs. Sources read: identity/role CLI, App Service, managed-identity/RBAC guidance, Blob roles, Python troubleshooting/changelog and Taggart report. No Azure commands executed.
Started from a post by @Microsoft, packaged by the editor. Original post