Cloud
Azure App Service Easy Auth: diagnose issuer and audience before disabling authentication
A production runbook for separating authsettingsV2, issuer, audience, calling client and application authorization when Easy Auth returns 401 or 403.
An Azure App Service API starts returning 401 or 403 after a Microsoft Entra ID change. The application deployment is healthy, health checks are green, and no failed request appears in business logs. To restore service, the team considers switching Easy Auth to anonymous access or adding several audiences “just in case.”
Those workarounds remove the control involved in the incident without explaining the broken contract. Easy Auth intercepts the request before the application, validates the token, and can enforce additional restrictions on the tenant, calling application, or identity. A failure can therefore originate in authsettingsV2, the token actually issued, the client requesting it, or application authorization, while looking identical to the caller.
The running case is an internal API called by an Azure DevOps job and a web application. After moving the issuer to the v2 endpoint and changing the Application ID URI, the browser still works but the job receives 401. The goal is to decide whether to fix the scope requested by the client, restore an expected audience, align the issuer, roll back the configuration, or escalate with evidence, without disabling authentication.
Freeze one request and the expected contract
Preserve one failure before changing anything. Record UTC time, hostname, path, client type, status, correlation ID, slot, last known configuration, and application release. Never copy the bearer token into the incident ticket; retain only the necessary claims and a fingerprint if your security procedure allows it.
incident: INC-AUTH-241
observed_utc: 2026-10-09T06:40:00Z
app_service: api-orders-prod
slot: production
request:
client: ado-release-orders
method: GET
path: /api/health/dependencies
status: 401
correlation_id: auth-canary-7f31
expected_contract:
tenant_id: <tenant-id>
issuer: https://login.microsoftonline.com/<tenant-id>/v2.0
audience: api://<api-client-id>
caller_client_id: <pipeline-client-id>
unauthenticated_action: Return401
containment:
disable_authentication: forbidden
add_wildcard_audience: forbidden
test_mode: read_only_canary First distinguish which boundary generated the response. If no application log carries the correlation ID, Easy Auth or an upstream proxy probably stopped the request. If the same ID reaches the application, the token crossed the platform boundary and the 403 may come from a role, scope, or business authorization rule.
Capture authsettingsV2 without exposing a secret
Export the effective configuration for the affected slot. Compare it with IaC or the last approved state, not an old screenshot. The useful properties are platform enablement, unauthenticated request action, Entra provider, client ID, issuer, allowed audiences, and claim checks.
RG="rg-app-prod"
APP="api-orders-prod"
SLOT="production"
if [ "$SLOT" = "production" ]; then
APP_ID=$(az webapp show -g "$RG" -n "$APP" --query id -o tsv)
else
APP_ID=$(az webapp deployment slot show -g "$RG" -n "$APP" --slot "$SLOT" --query id -o tsv)
fi
az resource show --ids "$APP_ID/config/authsettingsV2" --api-version 2025-05-01 --query '{platform:properties.platform,globalValidation:properties.globalValidation,entra:properties.identityProviders.azureActiveDirectory}' --output jsonc
# List names only: values may contain secrets.
az webapp config appsettings list -g "$RG" -n "$APP" --query '[].name' --output tsv Check the slot explicitly. Correct staging configuration proves nothing about production, and an application swap must not be assumed to have moved the authentication contract as intended. Also record the name of the setting that carries the provider secret, or the identity used instead, without displaying its value.
Read the token as evidence, not permission
Acquire a fresh token from the real caller context and decode it locally. An access token must target the API; an ID token intended for an interactive client is not a substitute. Compare at least iss, aud, tid, azp or appid, ver, scp, roles, nbf, and exp.
import base64
import json
import os
import time
token = os.environ["TOKEN"]
payload = token.split(".")[1]
payload += "=" * (-len(payload) % 4)
claims = json.loads(base64.urlsafe_b64decode(payload))
keys = ["iss", "aud", "tid", "azp", "appid", "ver", "scp", "roles", "nbf", "exp"]
print(json.dumps({key: claims.get(key) for key in keys}, indent=2))
print({"now": int(time.time()), "seconds_until_expiry": claims.get("exp", 0) - int(time.time())}) Run this script on an approved diagnostic workstation, then clear the variable and relevant history. Do not send the raw token or its full payload to logs: unnecessary claims can contain personal data or architecture details.
An audience represented by a bare client ID, api://<client-id>, or a custom URI is not interchangeable by intuition. It must match the resource requested by the client and the list accepted by Easy Auth. Likewise, v1 and v2 issuers represent different contracts; align the issued token, Entra configuration, and authsettingsV2 instead of adding values until a request returns 200.
Separate a platform 401, policy 403 and application denial
Build a matrix with positive and negative controls. A useful test keeps the same hostname, path, network, and method; only the token changes.
No token
Expected for an API: 401 according to globalValidation
No business log should appear
Expired token or invalid signature
Expected: rejection before the application
Check Easy Auth logs and absence of backend correlation
Valid token, wrong audience
Expected: token validation rejection
Fix the resource or scope requested by the client
Correct audience, calling application not allowed
Expected: 403 from the client application check
Compare azp or appid with the effective policy
Token accepted, business role or scope missing
The correlation reaches the application
Fix roles, scopes or application authorization, not Easy Auth
Conformant token
2xx expected on a read-only endpoint
Retain observed correlation, issuer, audience and client For an API, a 302 redirect can hide the problem from a noninteractive client. Keep Return401, or the convention already approved, during diagnosis. Do not use AllowAnonymous to determine whether the backend works: a bounded internal probe or canary slot provides that evidence without opening production.
Enable traces at the right boundary
App Service authentication traces appear in application logs when logging is enabled. On Windows, failed request tracing can also show the Easy Auth module’s involvement. Enable those signals for a short window without logging Authorization headers, then correlate three sources: caller logs for token acquisition, App Service platform logs, and application logs.
The absence of a backend request is evidence. It prevents rolling back a release that never saw the traffic. Conversely, a correlated request with an injected principal moves the investigation toward roles and business authorization. Identity headers provided by the platform should be trusted only when the backend cannot be reached by bypassing Easy Auth.
Change one dimension and canary it
Prepare a minimal diff: one audience, issuer, allowed client, or unauthenticated action. Do not change all four at once. Apply the change to a slot first, or during a bounded window, acquire a new token, and replay the matrix.
Promote
authsettingsV2 matches the versioned contract
The canary token carries the expected issuer, audience, tenant and client
The positive control reaches the application with correlation
Wrong-audience and forbidden-client tokens remain denied
No secret or raw token appears in the evidence
Hold
The status cannot be attributed to platform or application
Multiple clients still use unlisted audiences
The tested slot differs from production authentication
Rollback
Restore the last approved authsettingsV2
Restore the previous client scope or Application ID URI if changed
Replay the positive and negative controls
Remove every temporary audience, identity or logging setting If the canary restores the expected client but also accepts the wrong client, the change widens scope and must be rolled back. If restoring the old scope fixes the old client, keep Easy Auth unchanged and repair the pipeline. If no conformant token can be issued, the incident is in Entra registration or token acquisition, not the App Service runtime.
Conclusion
An Easy Auth 401 or 403 is not permission to remove the authentication boundary. Diagnosis must connect four objects: the effective configuration of the correct slot, claims in the real token, identity of the calling client, and evidence that the request did or did not reach the application.
Recovery is validated when a read-only canary passes with the expected contract while negative controls remain denied. The team can then promote one minimal diff, keep the configuration, fix the client, or restore the last approved authsettingsV2 with a testable rollback.