From ec5ee23a4a2445e97a9abaae0b382e900f7322d7 Mon Sep 17 00:00:00 2001 From: Matthew Paul Date: Wed, 16 Apr 2025 08:42:02 +0100 Subject: [PATCH 1/3] fixes #3085 Simple example for configuring the container apps environment with 'ConfigureInfrastructure' --- docs/azure/configure-aca-environments.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/azure/configure-aca-environments.md b/docs/azure/configure-aca-environments.md index 0fb9c3d7ee..315ba6bb4a 100644 --- a/docs/azure/configure-aca-environments.md +++ b/docs/azure/configure-aca-environments.md @@ -64,6 +64,30 @@ 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 type. This enables customization of the generated Bicep by providing a fluent API to configure the Azure resources—using the API: + +```csharp +var acaEnv = builder.AddAzureContainerAppEnvironment(Config.ContainEnvironmentName); + +acaEnv.ConfigureInfrastructure(config => +{ + var resources = config.GetProvisionableResources(); + var containerEnvironment = resources.OfType().FirstOrDefault(); + + containerEnvironment.Tags.Add("ExampleKey", "Example value"); +}); +``` + +The preceding code: + +- Chains a call to the API: + - The `infra` parameter is an instance of the type. + - The provisionable resources are retrieved by calling the method. + - The single resource is retrieved. + - A tag is added to the Cognitive Services resource with a key of `ExampleKey` and a value of `Example value`. + ## See also - [.NET Aspire Azure integrations overview](integrations-overview.md) From fa9a4cd68d421fb19f793685207e62971f0e456d Mon Sep 17 00:00:00 2001 From: Matthew Paul Date: Wed, 16 Apr 2025 08:42:02 +0100 Subject: [PATCH 2/3] fixes #3085 Simple example for configuring the container apps environment with 'ConfigureInfrastructure' --- docs/azure/configure-aca-environments.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/azure/configure-aca-environments.md b/docs/azure/configure-aca-environments.md index 0fb9c3d7ee..a9ad0707dd 100644 --- a/docs/azure/configure-aca-environments.md +++ b/docs/azure/configure-aca-environments.md @@ -64,6 +64,30 @@ 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 type. This enables customization of the generated Bicep by providing a fluent API to configure the Azure resources—using the API: + +```csharp +var acaEnv = builder.AddAzureContainerAppEnvironment(Config.ContainEnvironmentName); + +acaEnv.ConfigureInfrastructure(config => +{ + var resources = config.GetProvisionableResources(); + var containerEnvironment = resources.OfType().FirstOrDefault(); + + containerEnvironment.Tags.Add("ExampleKey", "Example value"); +}); +``` + +The preceding code: + +- Chains a call to the API: + - The `infra` parameter is an instance of the type. + - The provisionable resources are retrieved by calling the method. + - The single 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) From 8017de83958bfda19135ee2d2fed86c6d2ceb6cf Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 16 Apr 2025 10:41:24 -0500 Subject: [PATCH 3/3] Apply suggestions from code review --- docs/azure/configure-aca-environments.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/azure/configure-aca-environments.md b/docs/azure/configure-aca-environments.md index a9ad0707dd..86581aed2e 100644 --- a/docs/azure/configure-aca-environments.md +++ b/docs/azure/configure-aca-environments.md @@ -66,9 +66,11 @@ Calling this API ensures your existing Azure resources remain consistent and pre ## Customize provisioning infrastructure -All .NET Aspire Azure resources are subclasses of the type. This enables customization of the generated Bicep by providing a fluent API to configure the Azure resources—using the API: +All .NET Aspire Azure resources are subclasses of the type. This enables customization of the generated Bicep by providing a fluent API to configure the Azure resources—using the API: ```csharp +var builder = DistributionApplicationBuilder.Create(args); + var acaEnv = builder.AddAzureContainerAppEnvironment(Config.ContainEnvironmentName); acaEnv.ConfigureInfrastructure(config =>