TokenBroker

Home / Token Setup / Azure Foundation

Token Setup: Azure Foundation

The Azure side of TokenBroker: what was provisioned, how, and the lessons that cost time the first time through (2026-11-28).

Resources

Thing Value
Subscription Example subscription, id
Tenant ,
Resource group rg-tokenbroker (West US 2)
Function App tokenbroker-example, Flex Consumption, Linux, .NET 11 isolated
Function App identity system-assigned managed identity, principal
Key Vault kv-tokenbroker-example, RBAC authorization on
Storage account sttokenbrokerexample, Standard_LRS, blob public access off

Role assignments on the vault:

Configuration lives in config files, not Azure app settings: appsettings.json (committed defaults) and appsettings.Local.json (gitignored; the real KeyVaultUri), the latter carried in the deployment package. The original deployment used app settings (KeyVaultUri, ZohoAccountsBase, ZohoMailBase) until 2026-11-28, when they were deleted after the config-file setup was verified end to end; environment variables still override file values when set.

Tooling on the deployment machine

Signing in (the MFA catch)

Plain device-code sign-in reads fine, but ARM writes fail with AADSTS50076: the tenant's Conditional Access requires an MFA-satisfied token for resource changes. The working recipe:

  1. az logout
  2. az login --use-device-code --tenant <tenant-id> --scope "https://management.core.windows.net//.default" --claims-challenge <base64 from the AADSTS50076 error>
  3. Complete the sign-in including Authenticator MFA when prompted.

Use the claims challenge value from your own AADSTS50076 error (it encodes the acrs claim your tenant requires; if a future error gives a different value, use the new one).

Why Flex Consumption and .NET 11

Provisioning commands (as run)

az group create -n rg-tokenbroker -l westus2
az storage account create -n sttokenbrokerexample -g rg-tokenbroker -l westus2 --sku Standard_LRS --allow-blob-public-access false
az keyvault create -n kv-tokenbroker-example -g rg-tokenbroker -l westus2 --enable-rbac-authorization true
az functionapp create -n tokenbroker-example -g rg-tokenbroker --consumption-plan-location westus2 --flexconsumption-location westus2 --runtime dotnet-isolated --runtime-version 11.0 --functions-version 4 --storage-account sttokenbrokerexample --assign-identity [system]
az role assignment create --assignee <app-principal> --role "Key Vault Secrets User" --scope <vault-resource-id>
az functionapp config appsettings set -n tokenbroker-example -g rg-tokenbroker --settings KeyVaultUri=https://kv-tokenbroker-example.vault.azure.net/ ZohoAccountsBase=https://accounts.zoho.com ZohoMailBase=https://mail.zoho.com

(The last command is history: configuration later moved into appsettings.json / appsettings.Local.json and those app settings were deleted, as described above.)

Deploy

From src/TokenBroker, with az, the .NET SDK, and func on PATH:

func azure functionapp publish tokenbroker-example --dotnet-isolated

A minimal local local.settings.json (gitignored) with FUNCTIONS_WORKER_RUNTIME=dotnet-isolated must exist for runtime detection; its values are not uploaded without --publish-local-settings.

Verify after deploy: az functionapp function list shows ZohoMailAccounts, ZohoMailSearch, ZohoMailRead, ZohoMailSend; an unauthenticated call to /api/zoho/mail/accounts returns 401.

Gotchas worth the page