Skip to main content
This article shows how to deploy a Microsoft Foundry hosted agent that uses a container image stored in an authenticated container registry outside Azure, such as JFrog Artifactory or a self-hosted Docker Distribution registry. The solution uses OpenID Connect (OIDC) token exchange so that the agent can authenticate with the registry by using short-lived credentials instead of stored secrets, such as registry usernames, passwords, or access tokens. In this article, private registry refers to any container registry that requires authentication. It doesn’t refer to an Azure Container Registry (ACR) secured with an Azure private endpoint. To use an existing ACR or an ACR with public network access disabled, see Deploy a hosted agent with a private Azure Container Registry. This approach works with non-Azure registries that support OIDC token exchange. A Microsoft Entra application and the Foundry project managed identity participate in the authentication flow, allowing the registry to issue short-lived credentials for image pulls.

Prerequisites

The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
  • Azure CLI, installed and authenticated.
  • A Bash-compatible shell.
  • Azure Developer CLI, version 1.32.0 or later, installed and authenticated.
  • The Azure Developer CLI Foundry extensions, including azure.ai.agents 1.0.0-beta.13 or later. See Install the Azure Developer CLI Foundry extensions.
  • For the Python SDK workflow, Python 3.10 or later and the Azure AI Projects and Azure Identity packages.
  • A fully qualified prebuilt image in an authenticated container registry outside Azure or in a self-hosted Docker Distribution registry.
  • Permission to configure identity trust and read-only repository access in the registry or its authentication service.
  • The registry target, token audience, and token-exchange endpoint from your registry administrator.
A registry that supports OpenID Connect (OIDC) isn’t automatically compatible with this workflow. The registry’s authentication service must be able to exchange a Microsoft Foundry project managed identity token for short-lived credentials that the registry accepts for image pulls. JFrog Artifactory is one validated example of a compatible implementation. Docker Distribution requires an authentication adapter because its native bearer token authentication flow doesn’t provide an OAuth 2.0 token exchange endpoint.

Create an Entra application

Create an Entra application to provide the audience value used during token exchange:
Record the application (client) ID. The application doesn’t need a client secret for this flow. Give the application ID to your registry administrator to configure as the expected audience in the registry’s OIDC provider or token-exchange service.

Configure OIDC for your registry

Configure the registry authentication service to trust the Foundry project managed identity and grant it pull access only to the repository that contains the agent image:
  1. Set the Foundry project resource ID.
  2. Get the project managed identity object ID.
  3. Give PROJECT_PRINCIPAL_ID to your registry administrator. Bind that identity to read-only access for the repository that contains the agent image.
Choose the setup that matches your registry.
In JFrog Artifactory, create an OIDC integration and identity mapping that bind the project managed identity to a group with read-only repository access. Use /access/api/v1/oidc/token as the token endpoint. Record the JFrog OIDC provider name because the connection sends it to the token endpoint as body.provider_name.Configure the Entra application ID from Step 1 as the JFrog OIDC audience. The audience in the Foundry connection must match the audience in the JFrog OIDC integration.Record these values from your JFrog administrator:

Create the registry connection

Create a CustomKeys connection in the same Foundry project that hosts the agent. The connection metadata identifies it as an image registry connection that uses OAuth token exchange.
Set the project endpoint. Include the project name in the /api/projects/<project-name> path:
Create the connection. Choose the command for your registry authentication service.For JFrog Artifactory:
For a Docker Distribution authentication adapter:
Add a body.<field-name> custom key for each extra form field that your adapter requires.Verify the connection without displaying its credentials:
The output identifies a CustomKeys connection with the registry target and the registry_connection metadata.

Configure private network access

Choose the option that matches your Foundry project network configuration.
When the registry target and token endpoint are available through public HTTPS endpoints, you don’t need to configure extra registry networking.

Create and deploy the agent

Create and deploy the hosted agent from the prebuilt private registry image.
Initialize a hosted agent project with the fully qualified image and the connection name. The connection must already exist in the selected project.
Review the generated azure.yaml. Keep the azure.ai.project service and the agent’s uses relationship. The agent service must include the prebuilt image, docker.imagePassthrough: true, and the registry connection name:
An existing connection doesn’t belong in the uses list. The registryConnectionId value can be the connection’s Foundry name or resource ID.If the agent requires runtime configuration, store nonsecret values in the active azd environment and reference them from the agent service’s env map. Don’t store secrets directly in azure.yaml. See Configure environment variables for a hosted agent.Deploy the agent:

Verify and invoke the agent

Wait for the hosted agent to become active, and then send a test request.
Check the agent status:
Wait for the status to change to Active, and then invoke the agent:
A successful deployment confirms that Foundry exchanged the identity token, retrieved the image, and started the container. A successful invocation also confirms that the container implements the configured Responses protocol.

Troubleshoot registry deployment