Aller au contenu
Docs Try Aspire
Docs Try

Use Azure Container Registry at deploy time

Ce contenu n’est pas encore disponible dans votre langue.

Azure Container Registry logo

This page describes how Azure Container Registry is consumed at deployment time in an Aspire solution. For the AppHost API surface — adding a registry, referencing an existing one, scheduling purge tasks, and role assignments — see Azure Container Registry Hosting integration.

Unlike database or cache integrations, Azure Container Registry is not accessed by your app’s code at runtime. It is a publish-target integration: your deployment pipeline pushes container images to the registry, and compute environments (such as Azure Container Apps) pull images from it using credentials that Aspire provisions automatically.

There is no client library to install in consuming apps. Your services do not open a connection to ACR, send commands to it, or read environment variables from it at startup.

When Aspire provisions an Azure Container Registry resource, the generated Bicep module exposes the following outputs:

Output nameDescription
nameThe provisioned name of the registry (used to reference the registry from other Bicep modules).
loginServerThe registry login server hostname, for example myacr1234abcd.azurecr.io. This is the endpoint used to tag and push images during CI/CD and to pull images in compute environments.

These outputs are automatically wired into the compute environment’s Bicep when you call WithAzureContainerRegistry (or withAzureContainerRegistry) from your AppHost.

If you need to pass the registry’s loginServer value to another resource in your AppHost — for example, to tag images before pushing — use GetOutput (or getOutput) to retrieve it as a Bicep output reference:

C# — AppHost.cs
var acr = builder.AddAzureContainerRegistry("my-acr");
var loginServer = acr.GetOutput("loginServer");
TypeScript — apphost.ts
const acr = await builder.addAzureContainerRegistry("my-acr");
const loginServer = await acr.getOutput("loginServer");

Your CI/CD pipeline is responsible for building and pushing container images to the registry. Use the loginServer output as the image tag prefix:

Terminal — Push image to ACR
# Authenticate using Azure CLI
az acr login --name <registryName>
# Tag and push the image
docker tag myapp:latest <loginServer>/myapp:latest
docker push <loginServer>/myapp:latest

For automated pipelines, use a service principal or managed identity with the AcrPush role. See Assign roles for access control in the Hosting integration reference for how to grant push access from your AppHost.