跳转到内容
文档试用 Aspire
文档试用

Container registry configuration

此内容尚不支持你的语言。

Aspire 13.1 introduced explicit container registry configuration, giving developers control over where and when container images are pushed during deployment. This article explains how to configure container registries for your Aspire applications.

When deploying Aspire applications to production environments, your containerized services need to be pushed to a container registry. Prior to Aspire 13.1, registry configuration was often implicit, making it difficult to control and understand the deployment process. The new ContainerRegistryResource provides explicit configuration for:

  • Generic container registries — DockerHub, GitHub Container Registry (GHCR), Harbor, or any Docker-compatible registry
  • Azure Container Registry — First-class support with automatic credential management
  • Pipeline integration — Control when images are built and pushed using aspire do push
  • Authentication — Configure registry credentials securely

Use the AddContainerRegistry method to configure a generic container registry for your application. This works with any Docker-compatible registry including DockerHub, GitHub Container Registry, Harbor, and private registries.

The following example configures a container registry and associates it with a project resource:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
// Add a container registry
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
("myregistry", "registry.example.com");
// Associate the registry with a project
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

The preceding code:

  • Creates a container registry resource pointing to registry.example.com.
  • Associates the registry with the api project.
  • When deploying, the api project will be built as a container image and pushed to the specified registry.

To push images to DockerHub, specify docker.io as the registry endpoint:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
("dockerhub", "docker.io");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);

To push images to GitHub Container Registry (GHCR):

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
("ghcr", "ghcr.io");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);

For private registries, provide the full registry URL:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
(
"private-registry",
"registry.mycompany.com:5000");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);

Container registries typically require authentication for pushing images. You can configure credentials using parameters and secrets.

Parameters allow you to provide registry configuration dynamically:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registryEndpoint: ParameterResource
registryEndpoint
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("registry-endpoint");
const
const registryRepository: ParameterResource
registryRepository
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("registry-repository");
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, repository?: string | ParameterResource): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
(
"myregistry",
const registryEndpoint: ParameterResource
registryEndpoint
,
const registryRepository: ParameterResource
registryRepository
);
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);

For more information about parameters, see External parameters.

Registry credentials should be configured through your deployment environment:

Before pushing images, ensure you’re authenticated with the registry:

Docker login
docker login registry.example.com

For DockerHub:

DockerHub login
docker login docker.io -u username

For GitHub Container Registry:

GHCR login
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin

In CI/CD environments (GitHub Actions, Azure Pipelines, and so on), configure credentials using secrets:

GitHub Actions example
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
run: aspire do push

Azure Container Registry (ACR) provides first-class integration with Aspire, with automatic credential management and parallel provisioning.

Aspire 13.1 introduces explicit container registry configuration for Azure Container Apps environments:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const environment: AzureContainerAppEnvironmentResource
environment
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("myenv");
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const environment: AzureContainerAppEnvironmentResource
environment
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

In the preceding example:

  • The code creates an Azure Container Apps environment with an associated ACR.
  • The ACR is provisioned in parallel with that environment.
  • Images are pushed as soon as the registry is available.
  • Credentials are automatically managed through Azure authentication.

For more information, see Azure Container Registry integration.

To use an existing Azure Container Registry, call the PublishAsExisting method when you add the ACR:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registryName: ParameterResource
registryName
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("registryName");
const
const rgName: ParameterResource
rgName
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("rgName");
const
const acr: AzureContainerRegistryResource
acr
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerRegistry(name: string): AzureContainerRegistryResource

Adds an Azure Container Registry resource to the application model.

addAzureContainerRegistry
("my-acr");
await
const acr: AzureContainerRegistryResource
acr
.
AzureBicepResource.publishAsExisting(name: string | ParameterResource, resourceGroup?: string | ParameterResource): AzureContainerRegistryResource (+1 overload)

Marks the resource as an existing resource when the application is deployed.

publishAsExisting
(
const registryName: ParameterResource
registryName
,
const rgName: ParameterResource
rgName
);
const
const environment: AzureContainerAppEnvironmentResource
environment
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("env");
await
const environment: AzureContainerAppEnvironmentResource
environment
.
AzureBicepResource.withAzureContainerRegistry(registryBuilder: AzureContainerRegistryResource): AzureContainerAppEnvironmentResource

Configures a compute environment resource to use an Azure Container Registry.

withAzureContainerRegistry
(
const acr: AzureContainerRegistryResource
acr
);
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const acr: AzureContainerRegistryResource
acr
);

Aspire’s deployment pipeline includes a dedicated push step for pushing container images to registries.

The aspire do push command builds container images and pushes them to configured registries:

Aspire CLI — Push images
aspire do push

This command:

  1. Builds all container images for compute resources
  2. Tags images with the appropriate registry and repository names
  3. Pushes images to their configured registries

Example output:

Output
16:03:38 (pipeline-execution) → Starting pipeline-execution...
16:03:38 (build-api) → Starting build-api...
16:03:43 (push-api) → Starting push-api...
16:03:43 (push-api) → Pushing api to container-registry
16:03:44 (push-api) i [INF] Docker tag for api -> docker.io/username/api:latest succeeded.
16:04:05 (push-api) i [INF] Docker push for docker.io/username/api:latest succeeded.
16:04:05 (push-api) ✓ Successfully pushed api to docker.io/username/api:latest (21.3s)
16:04:05 (push-api) ✓ push-api completed successfully

For more information about pipeline commands, see aspire do command.

The push step automatically handles dependencies:

  • build-prereq — Ensures prerequisites are met before building
  • build-<resource> — Builds container images for each resource
  • push-<resource> — Pushes images to registries

You can execute individual steps or the entire pipeline:

Aspire CLI — Build only
aspire do build
Aspire CLI — Full deployment
aspire do deploy

The deploy step includes building, pushing, and deploying all resources.

You can configure different registries for different resources:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const publicRegistry: ContainerRegistryResource
publicRegistry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
("dockerhub", "docker.io");
const
const privateRegistry: ContainerRegistryResource
privateRegistry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, options?: {
repository?: string | ParameterResource;
}): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
(
"private",
"registry.company.com");
const
const publicApi: ProjectResource
publicApi
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("public-api", "../PublicApi/PublicApi.csproj");
await
const publicApi: ProjectResource
publicApi
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const publicRegistry: ContainerRegistryResource
publicRegistry
);
const
const internalApi: ProjectResource
internalApi
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("internal-api", "../InternalApi/InternalApi.csproj");
await
const internalApi: ProjectResource
internalApi
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const privateRegistry: ContainerRegistryResource
privateRegistry
);

You can use parameters when you need flexible deployment across environments:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const registryEndpoint: ParameterResource
registryEndpoint
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("registry-endpoint");
const
const registryRepository: ParameterResource
registryRepository
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("registry-repository");
const
const registry: ContainerRegistryResource
registry
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addContainerRegistry(name: string, endpoint: string | ParameterResource, repository?: string | ParameterResource): ContainerRegistryResource (+1 overload)

Adds a container registry resource

addContainerRegistry
(
"container-registry",
const registryEndpoint: ParameterResource
registryEndpoint
,
const registryRepository: ParameterResource
registryRepository
);
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);
const
const worker: ProjectResource
worker
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("worker", "../Worker/Worker.csproj");
await
const worker: ProjectResource
worker
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const registry: ContainerRegistryResource
registry
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Configure the parameters in your AppHost configuration:

appsettings.json
{
"Parameters": {
"registry-endpoint": "ghcr.io",
"registry-repository": "myorg"
}
}

Alternatively, use environment variables to configure them:

Environment variables
export Parameters__registry_endpoint="ghcr.io"
export Parameters__registry_repository="myorg"

The following code constitutes a complete AppHost example with Azure Container Apps and ACR:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
// Create Azure Container Apps environment with ACR
const
const environment: AzureContainerAppEnvironmentResource
environment
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addAzureContainerAppEnvironment(name: string): AzureContainerAppEnvironmentResource

Adds a container app environment resource to the distributed application builder.

addAzureContainerAppEnvironment
("production");
// Add Redis cache
const
const cache: RedisResource
cache
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addRedis(name: string, options?: {
port?: number;
password?: string | ParameterResource;
}): RedisResource (+1 overload)

Adds a Redis container to the application model.

addRedis
("cache");
// Add API with registry configuration
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("api", "../Api/Api.csproj");
await
const api: ProjectResource
api
.
ProjectResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): ProjectResource (+1 overload)

Adds a reference to another resource

withReference
(
const cache: RedisResource
cache
);
await
const api: ProjectResource
api
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const environment: AzureContainerAppEnvironmentResource
environment
);
// Add frontend with registry configuration
const
const web: ProjectResource
web
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
("web", "../Web/Web.csproj");
await
const web: ProjectResource
web
.
ProjectResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): ProjectResource (+1 overload)

Adds a reference to another resource

withReference
(
const api: ProjectResource
api
);
await
const web: ProjectResource
web
.
ProjectResource.withContainerRegistry(registry: IResource): ProjectResource

Configures the resource to use the specified container registry for container image operations.

withContainerRegistry
(
const environment: AzureContainerAppEnvironmentResource
environment
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

The explicit container registry configuration introduced in Aspire 13.1 provides several benefits:

  • Visibility — Clear understanding of where images are pushed
  • Control — Explicit configuration of registry endpoints and credentials
  • Parallelization — Registry provisioning happens in parallel with other resources
  • Early feedback — Faster deployments with images pushing as soon as registries are ready
  • Flexibility — Support for any Docker-compatible registry

For a deeper dive into container registry improvements, see Safia Abdalla’s blog post on fixing Aspire’s image problem.