Repository navigation
[docs] Document AzureBicepResourceScope.CreateForSubscription/CreateForTenant #1451
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -552,6 +552,59 @@ await builder.build().run(); | |
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### 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. | ||
|
|
||
| <Tabs syncKey="aspire-lang"> | ||
| <TabItem id="csharp" label="C#"> | ||
|
|
||
| Set the `Scope` property on the Bicep resource using `AzureBicepResourceScope.CreateForSubscription` or `AzureBicepResourceScope.CreateForTenant`: | ||
|
|
||
| ```csharp title="AppHost.cs" | ||
|
IEvangelist marked this conversation as resolved.
|
||
| 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block is not compilable as shown.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 2a00c63 — added |
||
|
|
||
| var tenantScoped = builder.AddBicepTemplateString( | ||
| "tenantScoped", | ||
| """ | ||
| targetScope = 'tenant' | ||
|
|
||
| param location string | ||
|
|
||
| output value string = 'tenant' | ||
| """); | ||
| tenantScoped.Resource.Scope = AzureBicepResourceScope.CreateForTenant(); | ||
|
|
||
| builder.Build().Run(); | ||
| ``` | ||
|
|
||
| <Aside type="note"> | ||
| `targetScope` in the Bicep template must match the scope you assign in C#. `CreateForSubscription` requires a subscription identifier; `CreateForTenant` targets the current tenant and takes no arguments. | ||
| </Aside> | ||
|
Comment on lines
+686
to
+690
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — addressed in 2a00c63. The note now explains that |
||
|
|
||
| </TabItem> | ||
| <TabItem id="typescript" label="TypeScript"> | ||
|
|
||
| <Aside type="note"> | ||
| `AzureBicepResourceScope` and `Resource.Scope` are not currently exposed in the TypeScript AppHost APIs, so subscription/tenant deployment scopes for Bicep resources are currently C# only. | ||
| </Aside> | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### Inspect generated Bicep | ||
|
|
||
| After customizing with `ConfigureInfrastructure`, inspect the Bicep that Aspire generates: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we call out the lifecycle and permission change here? These scopes can create resources outside the AppHost resource group and require broader RBAC. The normal destroy path deletes the tracked resource group, so subscription- or tenant-level resources may remain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make an inline change suggestion—it's far easier.