Skip to content

fixes #3085 Simple example for configuring the container apps environment #3119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/azure/configure-aca-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ builder.Build().Run();

Calling this API ensures your existing Azure resources remain consistent and prevents duplication.

## Customize provisioning infrastructure

All .NET Aspire Azure resources are subclasses of the <xref:Aspire.Hosting.Azure.AzureProvisioningResource> type. This enables customization of the generated Bicep by providing a fluent API to configure the Azure resources—using the <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.ConfigureInfrastructure``1(Aspire.Hosting.ApplicationModel.IResourceBuilder{``0},System.Action{Aspire.Hosting.Azure.AzureResourceInfrastructure})> API:

```csharp
var builder = DistributionApplicationBuilder.Create(args);

var acaEnv = builder.AddAzureContainerAppEnvironment(Config.ContainEnvironmentName);

acaEnv.ConfigureInfrastructure(config =>
{
var resources = config.GetProvisionableResources();
var containerEnvironment = resources.OfType<ContainerAppManagedEnvironment>().FirstOrDefault();

containerEnvironment.Tags.Add("ExampleKey", "Example value");
});
```

The preceding code:

- Chains a call to the <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.ConfigureInfrastructure*> API:
- The `infra` parameter is an instance of the <xref:Aspire.Hosting.Azure.AzureResourceInfrastructure> type.
- The provisionable resources are retrieved by calling the <xref:Azure.Provisioning.Infrastructure.GetProvisionableResources> method.
- The single <xref:Azure.Provisioning.AppContainers.ContainerAppManagedEnvironment> resource is retrieved.
- A tag is added to the Azure Container Apps environment resource with a key of `ExampleKey` and a value of `Example value`.

## See also

- [.NET Aspire Azure integrations overview](integrations-overview.md)
Expand Down
Loading