Skip to main content
Available on the Enterprise plan. Contact sales to learn more.
Ona environments can access Azure resources using workload identity federation. You configure a federated credential on an Azure app registration or user-assigned managed identity that trusts Ona’s OIDC tokens. Environments exchange their JWT for an Azure access token without storing any secrets.

Azure-specific constraints

Azure Entra ID federated credentials have two limits that shape how you design the trust:
  • Exact match on subject — wildcards are not supported. You need one federated credential per distinct sub value you want to authorize.
  • Maximum 20 federated credentials per app registration or managed identity.
Reference: Microsoft — Federated identity credential considerations. Plan the sub claim composition before creating credentials so the number of subs you need stays comfortably under 20.

Prerequisites

  • V3 tokens enabled on the OIDC Token Configuration page. See Enable V3 tokens.
  • Azure CLI installed in your environment.
  • An Azure app registration or user-assigned managed identity. The examples below use an app registration; the same federated-credential and CLI flow works for managed identities.

How it works

  1. Ona issues a JWT signed with RS256, containing identity claims about the environment, user, or service account.
  2. Azure validates the token against Ona’s OIDC discovery endpoint and JWKS.
  3. If iss, aud, and sub match the federated credential, Azure issues a service principal access token.
  4. The Azure CLI or any Azure SDK uses that access token to call Azure APIs.

Step 1: Create an app registration or managed identity

Use either an app registration or a user-assigned managed identity. Note the client ID and tenant ID — both are required for the login flow. App registration:
User-assigned managed identity:

Step 2: Inspect your Ona token

Run this in an Ona environment to see what sub value Azure will need to match:
Record the sub value verbatim — Azure requires an exact-match string.

Step 3: Add a federated identity credential

Add a federated identity credential that trusts Ona’s OIDC tokens for the recorded sub. For an app registration:
For a user-assigned managed identity:
The subject must match the sub claim exactly, including case and order of key/value pairs. New federated credentials take a few minutes to propagate; token exchange may fail with AADSTS70021 during this window.

Step 4: Assign Azure RBAC roles

Grant the app registration or managed identity access to the Azure resources it needs:

Step 5: Authenticate from an environment

Use ona idp login azure to exchange the OIDC token and configure the Azure CLI:
To set an active subscription as part of the login:
Subsequent az calls use the federated credentials:

Flags

Automate on environment startup

Add the login to your automations:

Manual exchange (without ona idp login azure)

Use this when integrating with non-CLI tooling or other Azure SDKs:
Or call Microsoft’s token endpoint directly:
For programmatic access in Python, the Azure Identity SDK accepts a token-fetching callable via ClientAssertionCredential:

Sub claim strategy

Azure’s exact-match constraint means you should pick the coarsest sub that still expresses your trust boundary. Each unique sub you want to authorize costs one of your 20 federated credentials per identity. The default V3 environment sub depends on whether the environment belongs to a project:
  • With project: organization_id:<orgID>:project_id:<projID> — stable across all environments in the project.
  • Without project: organization_id:<orgID> — matches every environment in the org.
Pick one of the patterns below. sub = organization_id + project_id (default — no configuration needed).

Per-user, per-project

Add creator_email (or creator_id) to the extra sub fields on the OIDC Token Configuration page. The sub becomes:

Per-user, all projects

Add user_id (for user tokens) or creator_id (for environment tokens) to the extra sub fields.

Per-repository

Add environment_initializers.git.remote_uri to the extra sub fields. Useful when you want the trust to follow a repository regardless of which Ona project wraps it.
Colons in values are URL-encoded as %3A in the sub claim.
See Customizing the sub claim for the full list of fields you can add.

Limits

  • Maximum 20 federated credentials per app registration or managed identity. If you need more, create additional identities with different role assignments.
  • The subject field has a 600-character limit. Long sub compositions (many extra fields with UUIDs) can approach this.

Token claims available to your application

Even though Azure only matches against sub, the rest of the JWT body is available to your application after login. Use top-level claims for downstream authorization (audit logs, tenant routing, group-based checks). See Token structure for the full schema and per-principal variants.

SSO claims forwarding

creator_idp_claims forwards string-valued claims from your SSO provider (for example, Entra ID groups or preferred_username). To enable additional claims:
  1. Open Organization Settings → Login and Security in Ona.
  2. Add the scopes your IdP returns on login (for example, profile, email, groups).
  3. Configure your IdP to release those claims to Ona.
You can include any string-valued SSO claim in the sub using the creator_idp_claims.<key> syntax.

A note on the creator_ prefix

In Ona, environments have their own identity — they are machines, not users. The creator_ prefix makes explicit that those claims describe the user who created the environment, not the environment itself. The distinction matters when environments are launched by automations or shared across users.

V2 tokens

V2 tokens also work with Azure federated credentials. The V2 sub uses a path-based format (for example, org:<orgID>/prj:<projectID>/env:<envID>). Set the federated credential’s subject to the exact V2 sub value. V2 tokens carry fewer claims (org, gsub, and standard JWT fields), so trust is limited to matching sub. New integrations should use V3. See V2 tokens for the full V2 reference.

Troubleshooting

AADSTS70021: No matching federated identity record found
  • The sub claim in your Ona token does not match any federated credential’s subject.
  • Decode your token: ona idp token --audience api://AzureADTokenExchange --decode.
  • Compare it to the subject you registered. The match must be exact, including case.
  • Newly created federated credentials take a few minutes to propagate. Retry after the wait.
AADSTS700024: Client assertion is not within its valid time range
  • The token has expired. Ona OIDC tokens are short-lived. Re-run ona idp login azure.
AADSTS700016: Application not found in the directory
  • --client-id must be the client ID (appId) of the app registration or managed identity, not its object ID.
missing --client-id / missing --tenant-id
  • Pass the flags or set IDP_AZURE_CLIENT_ID / IDP_AZURE_TENANT_ID in the environment.

Further reading