Skip to main content
Use a centrally managed Azure Container Registry (ACR) when you deploy hosted agent container images. You can build locally and push to an existing ACR, or skip the build and deploy a pre-built image that was pushed by another pipeline.

Prerequisites

Choose your ACR workflow

Most teams want their hosted agent container images to come from a centrally managed ACR, not a new per-project registry. There are two flavors of this:
  • Build locally and push to an existing ACR. This is typical when teams share one registry across many projects.
  • Skip the build entirely and deploy a pre-built image that was already pushed by a separate pipeline.
Both workflows are independent of whether the ACR is “private” in the network sense, such as a private endpoint with publicNetworkAccess: Disabled. Network privacy is covered in Configure virtual networks. This article focuses on registry selection and access.

Decide when to bring your own ACR

Bring your own ACR when one or more of these requirements apply:
  • Compliance. Images must live in a centrally audited registry your org already operates.
  • Shared infrastructure. One ACR feeds many agent projects; new per-project registries aren’t acceptable.
  • ABAC-mode registries. Your enterprise ACR is configured with attribute-based access control, requiring specific roles.
  • Pre-built images. A separate CI pipeline builds the image with vulnerability scanning, supply-chain signing, and hardened base images. The agent project should consume that image as-is.
If none of those apply, leave the defaults alone. azd ai agent init creates a new ACR for the project and azd up pushes to it.

Review registry selection

When you run azd ai agent init against an existing Microsoft Foundry project, the extension scans the project for ACR connections and offers them as choices:
  • 0 ACR connections found. You’re prompted for an ACR authentication server, such as myregistry.azurecr.io. Leave the prompt blank to let azd provision create the project registry when your configuration requires one.
  • 1 ACR connection found. It’s selected automatically and shown in the output.
  • 2+ ACR connections found. You pick one from a list.
Whatever is selected writes two env vars to your azd environment: You can also set these environment variables yourself before azd up:
When both are set, azd skips creating a new ACR and the build path pushes directly to the existing one.

Build locally and push to an existing ACR

This workflow is the most common enterprise path: keep the default container build, but target a shared registry instead of a per-project one.
  1. Point at the existing ACR. If you’re about to run azd ai agent init, you can answer the ACR prompt with your registry’s sign-in server, and the environment variables are written for you. If the project already exists, set them with azd env set as shown earlier.
  2. Confirm developer RBAC. azd up runs a preflight check against the ACR before it starts building. The role you need depends on which build path is configured in azure.yaml: If the registry is ABAC-enabled, the preflight check also looks for one of:
    • Local build: Container Registry Repository Writer (per-repository grant), or
    • Remote build: Owner/Contributor, since the Repository Writer role doesn’t cover ACR Tasks actions.
    When the push or remote build fails with a 403, azd up classifies the error and prints a ready-to-paste az role assignment create command, substituting your object ID and the ACR scope from the ARM error response.
  3. Run azd up.
    The build artifact is pushed to your existing ACR. The agent identity is granted AcrPull at deploy time so the Microsoft Foundry hosted agent runtime can pull it.

Deploy a pre-built image

Use this workflow when a separate CI pipeline already builds, scans, signs, and pushes the image. The agent project consumes that image directly, with no Dockerfile and no local build.
  1. Set the image field in the azure.ai.agent service in azure.yaml.
    The image value must be a valid container reference. Both tags and SHA digests are accepted. Pin to a digest (@sha256:...) for reproducible deploys. For a new project, provide the image during initialization instead:
    The --image option uses the prebuilt image path and skips code scaffolding, Dockerfile generation, and ACR setup.
  2. Run the deploy.
    The Foundry hosted agent runtime pulls the image from your ACR using the per-agent agent identity, which azd granted AcrPull during deploy.

Review RBAC

Run azd ai agent doctor after a deploy attempt to see the RBAC state. Failed pushes also surface the missing role and a paste-ready az role assignment create command.

Work with a private endpoint on the ACR

If the ACR has publicNetworkAccess: Disabled, and is only reachable from a virtual network, then azd up must run from inside that virtual network. Use a self-hosted runner, an Azure DevOps agent, or a jump host. The Foundry runtime separately needs network reachability to the registry to pull the image. That requirement is a platform concern beyond this article. See Configure virtual networks for the network-side picture and for how to integrate this workflow with private endpoints on the ACR, Foundry account, AppInsights, and Storage.

Troubleshoot ACR deployment