Skip to content

Commit aaf4f17

Browse files
mip1983IEvangelist
andauthored
fixes #3085 Simple example for configuring the container apps environment (#3119)
* fixes #3085 Simple example for configuring the container apps environment with 'ConfigureInfrastructure' * fixes #3085 Simple example for configuring the container apps environment with 'ConfigureInfrastructure' * Apply suggestions from code review --------- Co-authored-by: David Pine <david.pine@microsoft.com>
1 parent da6a060 commit aaf4f17

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/azure/configure-aca-environments.md

+26
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,32 @@ builder.Build().Run();
6464

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

67+
## Customize provisioning infrastructure
68+
69+
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:
70+
71+
```csharp
72+
var builder = DistributionApplicationBuilder.Create(args);
73+
74+
var acaEnv = builder.AddAzureContainerAppEnvironment(Config.ContainEnvironmentName);
75+
76+
acaEnv.ConfigureInfrastructure(config =>
77+
{
78+
var resources = config.GetProvisionableResources();
79+
var containerEnvironment = resources.OfType<ContainerAppManagedEnvironment>().FirstOrDefault();
80+
81+
containerEnvironment.Tags.Add("ExampleKey", "Example value");
82+
});
83+
```
84+
85+
The preceding code:
86+
87+
- Chains a call to the <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.ConfigureInfrastructure*> API:
88+
- The `infra` parameter is an instance of the <xref:Aspire.Hosting.Azure.AzureResourceInfrastructure> type.
89+
- The provisionable resources are retrieved by calling the <xref:Azure.Provisioning.Infrastructure.GetProvisionableResources> method.
90+
- The single <xref:Azure.Provisioning.AppContainers.ContainerAppManagedEnvironment> resource is retrieved.
91+
- A tag is added to the Azure Container Apps environment resource with a key of `ExampleKey` and a value of `Example value`.
92+
6793
## See also
6894

6995
- [.NET Aspire Azure integrations overview](integrations-overview.md)

0 commit comments

Comments
 (0)