Get started with the Azure Container Registry integration
Questi contenuti non sono ancora disponibili nella tua lingua.
Azure Container Registry is a managed Docker container registry service that simplifies the storage, management, and deployment of container images. The Aspire integration allows you to provision or reference an existing Azure Container Registry and seamlessly integrate it with your app’s compute environments.
In this introduction, you’ll see how to install and use the Aspire Azure Container Registry integration in a simple configuration. If you already have this knowledge, see Azure Container Registry Hosting integration for full reference details.
Overview
Section titled “Overview”Aspire apps often build and run container images locally but require secure registries for staging and production environments. The Azure Container Registry integration provides the following capabilities:
- Provision or reference an existing Azure Container Registry.
- Attach the registry to any compute-environment resource (for example, Azure Container Apps, Docker, Kubernetes) to ensure proper credential flow.
- Grant fine-grained ACR role assignments to other Azure resources.
Supported scenarios
Section titled “Supported scenarios”The Azure Container Registry integration supports the following scenarios:
- Provisioning a new registry: Automatically create a new Azure Container Registry for your app.
- Referencing an existing registry: Use an existing Azure Container Registry by providing its name and resource group.
- Credential management: Automatically flow credentials to compute environments for secure image pulls.
- Role assignments: Assign specific roles (for example,
AcrPush) to enable services to push images to the registry.
Set up hosting integration
Section titled “Set up hosting integration”To begin, install the Aspire Azure Container Registry Hosting integration in your Aspire AppHost project. This integration allows you to create and manage Azure Container Registry resources from your Aspire hosting projects:
aspire add azure-containerregistryLa CLI Aspire è interattiva; seleziona il risultato corretto quando richiesto:
Select an integration to add:
> azure-containerregistry (Aspire.Hosting.Azure.ContainerRegistry)> Other results listed as selectable options...#:package Aspire.Hosting.Azure.ContainerRegistry@*<PackageReference Include="Aspire.Hosting.Azure.ContainerRegistry" Version="*" />Next, in the AppHost project, create an Azure Container Registry resource and wire it to a compute environment:
var builder = DistributedApplication.CreateBuilder(args);
// Add (or reference) the registryvar acr = builder.AddAzureContainerRegistry("my-acr");
// Wire an environment to that registrybuilder.AddAzureContainerAppEnvironment("env") .WithAzureContainerRegistry(acr);
builder.Build().Run();The preceding code:
- Creates a new Azure Container Registry named
my-acr. - Attaches the registry to an Azure Container Apps environment named
env.
Continue learning
Section titled “Continue learning”For more information on how the Azure Container Registry integration works, see: