Skip to content

Log in to Azure Container Registry with Entra identities (workload identity, managed identity, OIDC) - #6

Merged
olljanat-ai merged 1 commit into
mainfrom
claude/tender-meitner-ajhg0z
Nov 12, 2026
Merged

olljanat-ai merged 1 commit into
mainfrom
claude/tender-meitner-ajhg0z

Conversation

@olljanat-ai

Copy link
Copy Markdown
Member

Summary

Adds passwordless pushes to Azure Container Registry (*.azurecr.io), including from self-hosted Azure DevOps agents and GitHub runners. The login works like az acr login (Entra access token → https://<acr>/oauth2/exchange → ACR refresh token → docker login) without needing the Azure CLI.

When no username/password is configured, the first available identity is used:

  1. Platform identity
    • Azure DevOps: a Docker Registry (ACR) or Azure Resource Manager service connection (new azureSubscription input) using workload identity federation, managed identity or a service principal. For federation, the job OIDC token is requested from System.OidcRequestUri with System.AccessToken.
    • GitHub: GitHub OIDC using azure-client-id / azure-tenant-id or the AZURE_CLIENT_ID / AZURE_TENANT_ID variables, plus id-token: write.
  2. An existing docker login for the registry is kept, for example from az acr login in a previous step, so it isn't overwritten.
  3. AKS workload identity of agent or runner pods (AZURE_FEDERATED_TOKEN_FILE).
  4. Managed identity of agent VMs / VMSS via IMDS. AZURE_CLIENT_ID selects a user-assigned identity.

On a self-hosted pool with a managed identity or workload identity, CONTAINER_REGISTRY=myacr.azurecr.io in the agent's or runner's .env file is the only configuration needed.

Details

  • src/core/http.ts is a small curl-based client. The whole request (URL, headers, body) goes to curl on stdin, so tokens never appear in the process list, and proxy and CA settings of corporate self-hosted agents are honoured. IMDS is always called without a proxy.
  • All intermediate tokens (OIDC assertion, Entra token, ACR refresh token) are masked.
  • The reusable workflow now requests id-token: write. It exports only the org variables and secrets that are actually set, so variables the runner already provides (runner .env, AKS workload identity) aren't overwritten with empty values.
  • An optional CI job e2e-acr-oidc does a real ACR push via GitHub OIDC. It runs only when the repository variables E2E_ACR, AZURE_CLIENT_ID and AZURE_TENANT_ID are set.
  • README and Marketplace overview document setup for each scenario.

Testing

  • 79 unit tests. They cover:
    • curl config building and escaping, and error reporting
    • the federated, secret and managed-identity token flows, checking the exact Entra and ACR exchange requests and the masking
    • the Azure DevOps WIF OIDC request
    • GitHub OIDC, including the cases where no permission is granted and where AKS workload identity takes precedence
    • the resolution order, keeping an existing docker login, and docker config detection
  • Local regression with real Docker: automatic naming and push still work. On a machine with no Azure identity, an ACR target falls through quickly and reports which identities were looked for.
  • Not run against a real Azure tenant from this environment. The optional e2e-acr-oidc job covers that once its variables are configured.

Generated by Claude Code

Support passwordless pushes to Azure Container Registry, including
self-hosted Azure DevOps agents and GitHub runners:

- Azure DevOps Docker Registry (ACR) and Azure Resource Manager service
  connections with workload identity federation (job OIDC token),
  managed identity or service principal
- GitHub OIDC (AZURE_CLIENT_ID / AZURE_TENANT_ID, id-token: write)
- AKS workload identity of agent/runner pods
- managed identity of agent VMs / VM scale sets (IMDS)

Tokens are exchanged for an ACR refresh token like az acr login does,
without the Azure CLI. HTTP calls use curl with the request on stdin so
proxies are honoured and secrets stay out of the process list. An
existing docker login is kept before trying agent identities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HpAsQazVvi679PqLz7o1C1
@olljanat-ai
olljanat-ai merged commit db5e6ef into main Nov 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants