-
Notifications
You must be signed in to change notification settings - Fork 163
Description
Proposed topic or title
Azure Container Registry
Location in table of contents.
/ Integrations / Azure / Container registry
Reason for the article
We're adding a new hosting integration for Azure Container Registry in Aspire that's designed for integration with our compute environments. It allows you to reference existing Azure container registries in your app.
Article abstract
Aspire apps often build and run container images locally but must pull from a secure registry in staging/production.
The new helpers let you:
- Provision or reference an existing Azure Container Registry.
- Attach that registry to any compute-environment resource (Container Apps, Docker, Kubernetes, etc.) so the right credentials flow automatically.
- Grant fine-grained ACR role assignments to other Azure resources.
The feature can be used as follows. In the case below, a new container registry will be provisioned and used as the registry for the default container app environment that is generated.
var builder = DistributedApplication.CreateBuilder(args);
// Add (or reference) the registry
var acr = builder.AddAzureContainerRegistry("myacr");
// Wire an environment to that registry
builder.AddAzureContainerAppsEnvironment("env")
.WithAzureContainerRegistry(acr);
// (Optional) let a service **push** images
builder.AddProject("api", "../Api/Api.csproj")
.WithRoleAssignments(acr, ContainerRegistryBuiltInRole.AcrPush);
await builder.Build().RunAsync();
This feature also works in conjunction with the existing resources feature. You can use the following format to reference an existing container registry:
var builder = DistributedApplication.CreateBuilder(args);
var registryName = builder.AddParameterResource("registryName");
var rename = builder.AddParameterResource("rgName");
// Add (or reference) the registry
var acr = builder.AddAzureContainerRegistry("myacr")
.PublishAsExisting(registryName, rgName);
// Wire an environment to that registry
builder.AddAzureContainerAppsEnvironment("env")
.WithAzureContainerRegistry(acr);
await builder.Build().RunAsync();
Relevant searches
No response