diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/customize-resources.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/customize-resources.mdx index 7c765bf07..60804d345 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/customize-resources.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/customize-resources.mdx @@ -642,6 +642,63 @@ await builder.build().run(); For more end-to-end examples — including chaining outputs between Bicep resources and using the `existing` Bicep keyword to reference resources that Aspire didn't provision — see the [Aspire `playground/bicep` sample](https://github.com/dotnet/aspire/tree/main/playground/bicep). +### Set the deployment scope + +By default, Aspire deploys Bicep resources at the resource group scope. Some Bicep templates require a different [deployment scope](https://learn.microsoft.com/azure/azure-resource-manager/bicep/deploy-to-subscription), such as the subscription or the tenant. + + + + +Set the `Scope` property on the Bicep resource using `AzureBicepResourceScope.CreateForSubscription` or `AzureBicepResourceScope.CreateForTenant`: + +```csharp title="AppHost.cs" +using Aspire.Hosting.Azure; + +var builder = DistributedApplication.CreateBuilder(args); + +var subscriptionId = builder.AddParameter("subscriptionId"); + +var subscriptionScoped = builder.AddBicepTemplateString( + "subscriptionScoped", + """ + targetScope = 'subscription' + + param location string + + output value string = 'subscription' + """); +subscriptionScoped.Resource.Scope = AzureBicepResourceScope.CreateForSubscription(subscriptionId.Resource); + +var tenantScoped = builder.AddBicepTemplateString( + "tenantScoped", + """ + targetScope = 'tenant' + + param location string + + output value string = 'tenant' + """); +tenantScoped.Resource.Scope = AzureBicepResourceScope.CreateForTenant(); + +builder.Build().Run(); +``` + + + + + + + + + + + ### Inspect generated Bicep To see the Bicep that Aspire emits after applying your `ConfigureInfrastructure` callbacks, publish the AppHost and read the files from the output folder: