On-Behalf-Of auth in Azure Container Apps with built-in Easy Auth
Tech-mirage · first published 1 January 2026 · 3 min read
Abstract. Getting a Graph access token handed to your app by the Easy Auth sidecar, and the three details that cost me days.
For a recent project I needed an easy-to-maintain, no-worries setup where an application running in an Azure Container App could access Microsoft Graph (SharePoint) on behalf of the user.
I realised that I could let the built-in auth sidecar (Easy Auth) do this for me by handing the app an access token directly, but I ran into problems with the setup. Quite a few hours later it works wonderfully, and I wanted to share, in case a search crawler finds it, how I made it work and why I found it challenging.
On-behalf-of auth (OBO)
Reading about the OBO flow in Microsoft’s documentation, and seeing how easily it could be set up in this post on the token store and OBO in Container Apps (it summarises it all and has some interesting references, worth a read), I believed this would be easy-peasy. All I needed to do was request a scope in the Entra ID app registration and in my application, for an access token to e.g. Graph (like https://graph.microsoft.com/Sites.Read.All). Then the auth sidecar would hand me the token in the HTTP headers, and I’d be good to go.
It turned out to be quite a headache, thanks to finicky command syntax, broken or missing documentation and more.
A quick recipe that works
Instead of going through everything that didn’t work, here is what does.
The problem
When you use Azure Container Apps with built-in authentication, by default:
- user information is provided in headers (
X-MS-CLIENT-PRINCIPAL-NAME); - access tokens are not exposed;
- and without the access token you cannot call Microsoft Graph (SharePoint, OneDrive and so on).
The solution in four steps
- Configure authentication to request the Microsoft Graph scopes, plus
offline_accessto get a refresh token. - Make sure the app registration has the right API permissions (I don’t go through this here).
- Configure Easy Auth so that the tokens are actually fetched, stored and exposed. As of 1 January 2026 I believe this cannot be done by clicking in the Azure Portal.
- The access token then arrives in the
X-MS-TOKEN-AAD-ACCESS-TOKENheader, and is refreshed for you.
Step by step
Enable authentication on your existing Container App, in the Portal or with the CLI:
# Set your variables
APP_NAME="your-container-app-name"
RESOURCE_GROUP="your-resource-group"
CLIENT_ID="your-client-id"
CLIENT_SECRET="your-client-secret"
TENANT_ID="your-tenant-id"
ISSUER_URL="https://login.microsoftonline.com/${TENANT_ID}/v2.0"
# Configure Microsoft authentication
az containerapp auth microsoft update \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--client-id $CLIENT_ID \
--client-secret $CLIENT_SECRET \
--issuer $ISSUER_URL \
--tenant-id $TENANT_ID \
--yes
Next, turn on the token store. Unlike App Service, Container Apps does not have it on by default.
The SAS URL must point to a Blob Storage container, not the storage account: a container-level SAS with read, write, create and delete permissions.
# Critical: the token store must be turned on by hand in Container Apps
az containerapp secret set \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--secrets 'tokenstore-sas-url=CONTAINER_SAS_URL_HERE'
az containerapp auth update \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--sas-url-secret-name tokenstore-sas-url \
--token-store true
Now update the configuration so the sidecar asks for the Graph scopes when the user logs in:
# Critical: this syntax is the one that works.
# Most sources online get it wrong (loginParameters[0]=scope=...).
az containerapp auth update \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--set 'identityProviders.azureActiveDirectory.login.loginParameters=[scope=openid profile email https://graph.microsoft.com/User.Read https://graph.microsoft.com/Sites.Read.All https://graph.microsoft.com/Files.Read.All offline_access]'
To check the whole configuration:
az containerapp auth show \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP
Hot tip: in the Portal or the CLI you can stream the logs of the auth sidecar too. That tells you whether authentication works at all, and surfaces some really finicky errors.
Some of these changes restart the auth sidecar automatically, but sometimes that fails, and sometimes the app itself needs a restart as well. I have also seen the sidecar take a few minutes to find the token-store container. All of which makes debugging slow.
Wrap-up
I struggled with the Azure CLI rejecting commands I found online, refusing to update the scopes from an uploaded JSON file, and a SAS token of the wrong type. Pair that with a slow debugging cycle of waiting for every change and redeploy, and an error easily takes a few days to fix.
I now have this working in several apps, where different Python backends use the access token for delegated access to e.g. SharePoint, and fetch a new one with the refresh token when it expires.
Hope that helps someone. Good luck!
First published on hetland.bearblog.dev; lightly edited here.
Correspondence: write to me on LinkedIn.