Skip to content

Commit bae6497

Browse files
IEvangelistJamesNKadegeostefannikoleiafscrome
authored
.NET Aspire content for 9.2 (#2870)
* Remove IsAspireHost bits. Fixes #2847 * New dashboard config to disable resource graph (#2874) * Fixes #2842 * Update configuration.md Co-authored-by: James Newton-King <[email protected]> --------- Co-authored-by: James Newton-King <[email protected]> * Position VS Code first * Add clarifying details about updates to `AddDatabase` APIs (#2878) * Contributes to #2789 * Added PostgreSQL and links to eventing * Quick edit pass * Apply suggestions from code review Co-authored-by: Andy (Steve) De George <[email protected]> --------- Co-authored-by: Andy (Steve) De George <[email protected]> * Adding GitHub Copilot prompts (#2896) * Initial prompts * Update prompts * Adding content for `WithHttpCommand` (#2875) * Initial setup * Rework HTTP command content with an example * Add images and more details. * Edit pass * Added playground sample * Update HTTP command content with updated source * Remove duplicated code snippet * Correct member over parameter * Fix name * Correct postgres connection command * Update kafka-integration.md (#2712) Change links von provectuslabs to Kafbat * Add role assignments with .NET Aspire (#2891) * Getting closer on adding roles details * Apply suggestions from code review Co-authored-by: Andy (Steve) De George <[email protected]> * Address feedback and update content * Add to TOC * Edit pass * Add link * Fix a few issues * Remove absolute URL --------- Co-authored-by: Andy (Steve) De George <[email protected]> * Breaking changes for .NET Aspire 9.2 (#2892) * Added breaking changes for 9.2, fixes #2888 and fixes #2889 * Correct TOC * Add clarifying type name * Fixes #2899 * Added new breaking changes docs * Remove link * Correct MD lint error/warnings * Bump bicep bits (#2930) * Update docs to use `EndpointProperty.HostAndPort` where appropriate (#2934) Fixes #2646 * Reorganize the order of the Azure storage content (#2937) * Fixes #2935 * Tweak table style * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> --------- Co-authored-by: Genevieve Warren <[email protected]> * Add content on customizing resource URLs (#2940) * Fixes #2936 * Correct TOC * Minor tweaks * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> * Apply suggestions from code review Co-authored-by: Damian Edwards <[email protected]> * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Genevieve Warren <[email protected]> Co-authored-by: Damian Edwards <[email protected]> * Add CosmosDB parent-child relationship bits. (#2912) * Add CosmosDB parent-child relationship bits. Part of #2907 * A few fixes * Update docs/database/azure-cosmos-db-integration.md Co-authored-by: Safia Abdalla <[email protected]> * Update docs/database/azure-cosmos-db-integration.md Co-authored-by: Safia Abdalla <[email protected]> * A few updates based on feedback * Add a few more bits * Add more details about the web pubsub. * Apply suggestions from code review Co-authored-by: Safia Abdalla <[email protected]> --------- Co-authored-by: Safia Abdalla <[email protected]> * Add new Azure PostgreSQL client integrations. (#2905) * Replace manual identity code with new package. Fixes #2883 * Add xref reminders. * Replace standard clients * Correct leading para * Apply suggestions from code review * Adjustment from peer reviews * Correct terminology * .NET Aspire 💜 Playwright (#2904) * WIP * Initial bits in place * Yeah, now we're cookin'! * OMG, I'm having too much fun! * Add a few more bits * Encapsulate selector. * Even more images automated, and better coverage. * More coverage... * Added more coverage. * More images and coverage. * A bit more clean up * Added a few more bits and updated. * Fixed link issue * Fix last issue * Tracing and structured log pages * Apply suggestions from code review * Update docs/fundamentals/dashboard/automation/aspire-dashboard/Aspire.Dashboard.ScreenCapture/README.md * Add "Configure Azure Container App environments" article (#3058) * Yuck, too rough of a draft but need to context switch. * Tweaks * Let's go, this fixes #2938 * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> --------- Co-authored-by: Genevieve Warren <[email protected]> * What's new in .NET Aspire 9.2 (#2877) * Add initial bits for #2869. What's new in .NET Aspire 9.2 * Add a few more what's new bits * Add dashboard config * Add initial details about HTTP commands * Apply suggestions from code review Co-authored-by: Andy (Steve) De George <[email protected]> * Edit pass * Add link to breaking changes * Removed MS-collected telemetry * Try toying with TOC * Expand product updates * Apply suggestions from code review Co-authored-by: Maddy Montaquila (Leger) <[email protected]> * Delete section * Update .NET Aspire 9.2 documentation * Update docs/whats-new/dotnet-aspire-9.2.md * Update connection string and deployment section * Added testing updates * Update docs/whats-new/dotnet-aspire-9.2.md Co-authored-by: James Newton-King <[email protected]> * Clean up * Minor updates * Apply suggestions from code review Co-authored-by: David Fowler <[email protected]> * Apply suggestions from code review Co-authored-by: David Fowler <[email protected]> * Apply suggestions from code review Co-authored-by: David Fowler <[email protected]> * Apply suggestions from code review Co-authored-by: David Fowler <[email protected]> * Add images * Final tweaks before release branch --------- Co-authored-by: Andy (Steve) De George <[email protected]> Co-authored-by: Maddy Montaquila (Leger) <[email protected]> Co-authored-by: David Fowler <[email protected]> Co-authored-by: Mitch Denny <[email protected]> Co-authored-by: James Newton-King <[email protected]> * Bump versions * nits (#3064) * Fix build issues * More fixes * Move things * Move even more things * Point to 9.2 * Fix bookmakrs --------- Co-authored-by: James Newton-King <[email protected]> Co-authored-by: Andy (Steve) De George <[email protected]> Co-authored-by: Stefan Nikolei <[email protected]> Co-authored-by: Alex Crome <[email protected]> Co-authored-by: Genevieve Warren <[email protected]> Co-authored-by: Damian Edwards <[email protected]> Co-authored-by: Safia Abdalla <[email protected]> Co-authored-by: Maddy Montaquila (Leger) <[email protected]> Co-authored-by: David Fowler <[email protected]> Co-authored-by: Mitch Denny <[email protected]>
1 parent f0150a0 commit bae6497

File tree

347 files changed

+68672
-980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+68672
-980
lines changed

Diff for: .github/prompts/adhere-to-writing-style.prompt.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
The following is a set of guidelines to follow when writing documentation for .NET Aspire. Please ensure that all documentation adheres to these guidelines:
2+
3+
## Voice and tone
4+
5+
Write for readers who may have a limited vocabulary or are not native English speakers. Use simple, clear language and avoid jargon whenever possible. If you must use technical terms, provide a brief explanation of what they mean.
6+
7+
- Use active voice
8+
- Use the second person (you, your) to address the reader directly
9+
10+
## Headings
11+
12+
Headings use sentence-style capitalization. Always capitalize the first word of a heading. Do not use gerunds (e.g., "Using" or "Creating") in heading.
13+
14+
## Text styling
15+
16+
Use _italics_ for files, folders, paths (for long items, split onto their own line), new terms.
17+
18+
Use **bold** for UI elements.
19+
20+
Use `code` for inline code, language keywords, NuGet package names, command-line commands, database table and column names, and URLs that you don't want to be clickable.
21+
22+
## Links
23+
24+
Strive to use relative links whenever possible. Use absolute links only when necessary. For example, if you are linking to a page on a different site, use an absolute link. When using absolute links, use the full URL (including the protocol) and remove the locale from the URL. Avoid HTTP links, always prefer HTTPS. Whenever providing additional resources, use the following format:
25+
26+
"For more information, see [link text](../relative/link/to/content.md)."
27+
28+
Never link to `https://learn.microsoft.com` or `https://learn.microsoft.com/en-us`, always remove these and instead use site relative links. For example, if the original link is `https://learn.microsoft.com/en-us/aspnet/core/mvc/overview`, it should be changed to `/aspnet/core/mvc/overview`.
29+
30+
## Things to avoid
31+
32+
- Avoid future tense: In some non-English languages the concept of future tense is not the same as English. Using future tense can make your documents harder to read.
33+
- Avoid passive voice: Passive voice can make your writing less clear and harder to read. Use active voice whenever possible.

Diff for: .github/prompts/rephrase-selected-text.prompt.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Please rephrase the selected text to make it more concise and clear, while maintaining the original meaning. The rephrased text should strive to improve readability. Please ensure that the rephrased text is grammatically correct and flows well. Take obvious opportunities to improve structure, and emphasis of domain specific intent.
2+
3+
Please also always [adhere to our writing style](adhere-to-writing-style.prompt.md).

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ _dependentPackages/
3434
!/xml/System.IO.Log/
3535
!/xml/System.Net.Cache/
3636

37+
# Playwright dependencies
38+
**/*/playwright-deps
39+
3740
# Visual Studio Code
3841
.vscode/*
3942
!.vscode/extensions.json
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Sdk Name="Aspire.AppHost.Sdk" Version="9.1.0" />
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
77
<TargetFramework>net9.0</TargetFramework>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
10-
<IsAspireHost>true</IsAspireHost>
1110
<UserSecretsId>7b352f08-305b-4032-9a21-90deb02efc04</UserSecretsId>
1211
</PropertyGroup>
1312

@@ -17,8 +16,8 @@
1716
</ItemGroup>
1817

1918
<ItemGroup>
20-
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
21-
<PackageReference Include="Aspire.Hosting.Redis" Version="9.1.0" />
19+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
20+
<PackageReference Include="Aspire.Hosting.Redis" Version="9.2.0" />
2221
</ItemGroup>
2322

2423
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Sdk Name="Aspire.AppHost.Sdk" Version="9.1.0" />
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
77
<TargetFramework>net9.0</TargetFramework>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
10-
<IsAspireHost>true</IsAspireHost>
1110
<UserSecretsId>7b352f08-305b-4032-9a21-90deb02efc04</UserSecretsId>
1211
</PropertyGroup>
1312

@@ -17,8 +16,8 @@
1716
</ItemGroup>
1817

1918
<ItemGroup>
20-
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
21-
<PackageReference Include="Aspire.Hosting.Redis" Version="9.1.0" />
19+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
20+
<PackageReference Include="Aspire.Hosting.Redis" Version="9.2.0" />
2221
</ItemGroup>
2322

2423
</Project>

Diff for: docs/app-host/snippets/AspireApp/AspireApp.ServiceDefaults/AspireApp.ServiceDefaults.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1212

1313
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.4.0" />
14-
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.1.0" />
14+
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.2.0" />
1515
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.11.2" />
1616
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.2" />
1717
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />

Diff for: docs/app-host/snippets/AspireApp/AspireApp.Web/AspireApp.Web.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Aspire.StackExchange.Redis.OutputCaching" Version="9.1.0" />
14+
<PackageReference Include="Aspire.StackExchange.Redis.OutputCaching" Version="9.2.0" />
1515
</ItemGroup>
1616

1717
</Project>

Diff for: docs/authentication/snippets/AspireApp/AspireApp.AppHost/AspireApp.AppHost.csproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Sdk Name="Aspire.AppHost.Sdk" Version="9.1.0" />
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
77
<TargetFramework>net9.0</TargetFramework>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
10-
<IsAspireHost>true</IsAspireHost>
1110
<UserSecretsId>10daccf5-26f1-4641-80b2-95f0357607cf</UserSecretsId>
1211
</PropertyGroup>
1312

@@ -17,7 +16,7 @@
1716
</ItemGroup>
1817

1918
<ItemGroup>
20-
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
19+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
2120
<PackageReference Include="Aspire.Hosting.Keycloak" Version="9.1.0-preview.1.24113.4 />
2221
</ItemGroup>
2322

Diff for: docs/authentication/snippets/AspireApp/AspireApp.ServiceDefaults/AspireApp.ServiceDefaults.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1212

1313
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.4.0" />
14-
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.1.0" />
14+
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.2.0" />
1515
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.11.2" />
1616
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.2" />
1717
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />

Diff for: docs/azure/configure-aca-environments.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Configure Azure Container Apps environments
3+
description: Learn how to configure Azure Container Apps environments in .NET Aspire.
4+
ms.topic: how-to
5+
ms.date: 04/09/2025
6+
---
7+
8+
# Configure Azure Container Apps environments
9+
10+
It's easy to [publish resources as Azure Container Apps (ACA)](integrations-overview.md#publish-as-azure-container-app) using any of the supported APIs:
11+
12+
- <xref:Aspire.Hosting.AzureContainerAppProjectExtensions.PublishAsAzureContainerApp*?displayProperty=nameWithType>
13+
- <xref:Aspire.Hosting.AzureContainerAppContainerExtensions.PublishAsAzureContainerApp*?displayProperty=nameWithType>
14+
- <xref:Aspire.Hosting.AzureContainerAppExecutableExtensions.PublishAsAzureContainerApp*?displayProperty=nameWithType>
15+
16+
These APIs automatically create a default ACA environment when you publish your app. While this default setup works well for most scenarios, you might need to customize the ACA environment to meet specific requirements. To achieve this, use the `AddAzureContainerAppEnvironment` method.
17+
18+
The [.NET Aspire app host](../fundamentals/app-host-overview.md) simplifies infrastructure provisioning by generating code to create Azure resources for your applications. This approach enables you to model and configure deployment-related aspects directly in C#, reducing the need to rely on tools like Bicep. These aspects include configuring ACA environments, which provide a serverless platform for running containerized applications.
19+
20+
By using the <xref:Azure.Provisioning> APIs (explained in [Infrastructure as code](integrations-overview.md#infrastructure-as-code)), you can configure and customize ACA environments along with related resources, such as container registries and file share volumes. Any available deployment setting can be configured. For more information on the available settings, see [Microsoft.App managedEnvironments](/azure/templates/microsoft.app/managedenvironments).
21+
22+
This article guides you through the process of tailoring ACA environments for your .NET Aspire solutions.
23+
24+
## Add an ACA environment
25+
26+
<!-- TODO: Add xref to AddAzureContainerAppEnvironment when available -->
27+
28+
The `AzureContainerAppEnvironmentResource` type models an ACA environment resource. When you call the `AddAzureContainerAppEnvironment` method, it creates an instance of this type (wrapped in the <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1>).
29+
30+
:::code language="csharp" source="snippets/aca/AspireAca.AppHost/AspireApp.AppHost/Program.cs":::
31+
32+
By default, the calling this API to add an ACA environment generates the following provisioning Bicep module:
33+
34+
:::code language="bicep" source="snippets/aca/AspireAca.AppHost/AspireApp.AppHost/aca-env.module.bicep":::
35+
36+
This module configures:
37+
38+
- A user-assigned managed identity for the ACA environment.
39+
- An Azure Container Registry (ACR) for the ACA environment.
40+
- A Log Analytics workspace for the ACA environment.
41+
- An Azure Container Apps environment.
42+
- The [.NET Aspire dashboard](../fundamentals/dashboard/overview.md) for the ACA environment.
43+
- A role assignment for the user principal ID to the ACA environment.
44+
- Various outputs for the ACA environment.
45+
46+
Using the `acaEnv` variable, you can chain a call to the <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.ConfigureInfrastructure*> API to customize the ACA environment to your liking. For more information, see [Configure infrastructure](integrations-overview.md#configure-infrastructure).
47+
48+
## Handle naming conventions
49+
50+
<!-- TODO: Add xref to WithAzdResourceNaming when available -->
51+
52+
By default, `AddAzureContainerAppEnvironment` uses a different Azure resource naming scheme than the [Azure Developer CLI (`azd`)](/azure/developer/azure-developer-cli/). If you're upgrading an existing deployment that previously used `azd`, you might see duplicate Azure resources. To avoid this issue, call the `WithAzdResourceNaming` method to revert to the naming convention used by `azd`:
53+
54+
```csharp
55+
var builder = DistributionApplicationBuilder.Create(args);
56+
57+
var acaEnv = builder.AddAzureContainerAppEnvironment("aca-env")
58+
.WithAzdResourceNaming();
59+
60+
// Omitted for brevity...
61+
62+
builder.Build().Run();
63+
```
64+
65+
Calling this API ensures your existing Azure resources remain consistent and prevents duplication.
66+
67+
## See also
68+
69+
- [.NET Aspire Azure integrations overview](integrations-overview.md)
70+
- [Azure Container Apps overview](/azure/container-apps/overview)

Diff for: docs/azure/integrations-overview.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Azure integrations overview
33
description: Overview of the Azure integrations available in the .NET Aspire.
4-
ms.date: 03/07/2025
4+
ms.date: 04/10/2025
55
uid: dotnet/aspire/integrations/azure-overview
66
---
77

@@ -107,7 +107,7 @@ You can query whether a resource is marked as an existing resource, by calling t
107107

108108
.NET Aspire provides support for referencing existing Azure resources. You mark an existing resource through the `PublishAsExisting`, `RunAsExisting`, and `AsExisting` APIs. These APIs allow developers to reference already-deployed Azure resources, configure them, and generate appropriate deployment manifests using Bicep templates.
109109

110-
Existing resources referenced with these APIs can be enhanced with role assignments and other customizations that are available with .NET Aspire's [infrastructure as code capabilities](#infrastructure-as-code). These APIs are limited to Azure resources that can be deployed with Bicep templates.
110+
Existing resources referenced with these APIs can be enhanced with [role assignments](role-assignments.md) and other customizations that are available with .NET Aspire's [infrastructure as code capabilities](#infrastructure-as-code). These APIs are limited to Azure resources that can be deployed with Bicep templates.
111111

112112
### Configure existing Azure resources for run mode
113113

@@ -321,7 +321,7 @@ The preceding code:
321321
- Adds an environment variable named `Hello` to the container app, using the `env` parameter.
322322
- The `AsProvisioningParameter` method is used to treat `env` as either a new <xref:Azure.Provisioning.ProvisioningParameter> in infrastructure, or reuses an existing bicep parameter if one with the same name already exists.
323323

324-
For more information, see <xref:Azure.Provisioning.AppContainers.ContainerApp> and <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.AsProvisioningParameter*>.
324+
To configure the Azure Container App environment, see [Configure Azure Container Apps environments](configure-aca-environments.md). For more information, see <xref:Azure.Provisioning.AppContainers.ContainerApp> and <xref:Aspire.Hosting.AzureProvisioningResourceExtensions.AsProvisioningParameter*>.
325325

326326
## Infrastructure as code
327327

@@ -462,27 +462,27 @@ By default, when you call any of the Bicep-related APIs, a call is also made to
462462

463463
Imagine that you have a Bicep template in a file named `storage.bicep` that provisions an Azure Storage Account:
464464

465-
:::code language="bicep" source="snippets/AppHost.Bicep/storage.bicep":::
465+
:::code language="bicep" source="snippets/bicep/AppHost.Bicep/storage.bicep":::
466466

467467
To add a reference to the Bicep file on disk, call the <xref:Aspire.Hosting.AzureBicepResourceExtensions.AddBicepTemplate%2A> method. Consider the following example:
468468

469-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.ReferenceBicep.cs" id="addfile":::
469+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.ReferenceBicep.cs" id="addfile":::
470470

471471
The preceding code adds a reference to a Bicep file located at `../infra/storage.bicep`. The file paths should be relative to the _app host_ project. This reference results in an <xref:Aspire.Hosting.Azure.AzureBicepResource> being added to the application's resources collection with the `"storage"` name, and the API returns an `IResourceBuilder<AzureBicepResource>` instance that can be used to further customize the resource.
472472

473473
#### Reference Bicep inline
474474

475475
While having a Bicep file on disk is the most common scenario, you can also add Bicep templates inline. Inline templates can be useful when you want to define a template in code or when you want to generate the template dynamically. To add an inline Bicep template, call the <xref:Aspire.Hosting.AzureBicepResourceExtensions.AddBicepTemplateString%2A> method with the Bicep template as a `string`. Consider the following example:
476476

477-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.InlineBicep.cs" id="addinline":::
477+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.InlineBicep.cs" id="addinline":::
478478

479479
In this example, the Bicep template is defined as an inline `string` and added to the application's resources collection with the name `"ai"`. This example provisions an Azure AI resource.
480480

481481
#### Pass parameters to Bicep templates
482482

483483
[Bicep supports accepting parameters](/azure/azure-resource-manager/bicep/parameters), which can be used to customize the behavior of the template. To pass parameters to a Bicep template from .NET Aspire, chain calls to the <xref:Aspire.Hosting.AzureBicepResourceExtensions.WithParameter%2A> method as shown in the following example:
484484

485-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.PassParameter.cs" id="addparameter":::
485+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.PassParameter.cs" id="addparameter":::
486486

487487
The preceding code:
488488

@@ -511,11 +511,11 @@ To use a well-known parameter, pass the parameter name to the <xref:Aspire.Hosti
511511

512512
Consider an example where you want to set up an Azure Event Grid webhook. You might define the Bicep template as follows:
513513

514-
:::code language="bicep" source="snippets/AppHost.Bicep/event-grid-webhook.bicep" highlight="3-4,27-35":::
514+
:::code language="bicep" source="snippets/bicep/AppHost.Bicep/event-grid-webhook.bicep" highlight="3-4,27-35":::
515515

516516
This Bicep template defines several parameters, including the `topicName`, `webHookEndpoint`, `principalId`, `principalType`, and the optional `location`. To pass these parameters to the Bicep template, you can use the following code snippet:
517517

518-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.PassParameter.cs" id="addwellknownparams":::
518+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.PassParameter.cs" id="addwellknownparams":::
519519

520520
- The `webHookApi` project is added as a reference to the `builder`.
521521
- The `topicName` parameter is passed a hardcoded name value.
@@ -528,11 +528,11 @@ The well-known parameters are convention-based and shouldn't be accompanied with
528528

529529
In addition to passing parameters to Bicep templates, you can also get outputs from the Bicep templates. Consider the following Bicep template, as it defines an `output` named `endpoint`:
530530

531-
:::code language="bicep" source="snippets/AppHost.Bicep/storage-out.bicep":::
531+
:::code language="bicep" source="snippets/bicep/AppHost.Bicep/storage-out.bicep":::
532532

533533
The Bicep defines an output named `endpoint`. To get the output from the Bicep template, call the <xref:Aspire.Hosting.AzureBicepResourceExtensions.GetOutput%2A> method on an `IResourceBuilder<AzureBicepResource>` instance as demonstrated in following C# code snippet:
534534

535-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.GetOutputReference.cs" id="getoutput":::
535+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.GetOutputReference.cs" id="getoutput":::
536536

537537
In this example, the output from the Bicep template is retrieved and stored in an `endpoint` variable. Typically, you would pass this output as an environment variable to another resource that relies on it. For instance, if you had an ASP.NET Core Minimal API project that depended on this endpoint, you could pass the output as an environment variable to the project using the following code snippet:
538538

@@ -558,11 +558,11 @@ It's important to [avoid outputs for secrets](/azure/azure-resource-manager/bice
558558

559559
Consider the following Bicep template as an example the helps to demonstrate this concept of securing secret outputs:
560560

561-
:::code language="bicep" source="snippets/AppHost.Bicep/cosmosdb.bicep" highlight="2,41":::
561+
:::code language="bicep" source="snippets/bicep/AppHost.Bicep/cosmosdb.bicep" highlight="2,41":::
562562

563563
The preceding Bicep template expects a `keyVaultName` parameter, among several other parameters. It then defines an Azure Cosmos DB resource and stashes a secret into Azure Key Vault, named `connectionString` which represents the fully qualified connection string to the Cosmos DB instance. To access this secret connection string value, you can use the following code snippet:
564564

565-
:::code language="csharp" source="snippets/AppHost.Bicep/Program.cs" id="secrets":::
565+
:::code language="csharp" source="snippets/bicep/AppHost.Bicep/Program.cs" id="secrets":::
566566

567567
In the preceding code snippet, the `cosmos` Bicep template is added as a reference to the `builder`. The `connectionString` secret output is retrieved from the Bicep template and stored in a variable. The secret output is then passed as an environment variable (`ConnectionStrings__cosmos`) to the `api` project. This environment variable is used to connect to the Cosmos DB instance.
568568

0 commit comments

Comments
 (0)