docs: fix inaccurate APIs and workflow in Customize Azure resources#951
Draft
IEvangelist wants to merge 1 commit into
Draft
docs: fix inaccurate APIs and workflow in Customize Azure resources#951IEvangelist wants to merge 1 commit into
IEvangelist wants to merge 1 commit into
Conversation
The Customize Azure resources page had three concrete inaccuracies that
broke copy-paste use of the snippets:
- The custom Bicep example called `AddAzureBicepResource(name:...,
bicepFilePath:...)`, which doesn't exist. Replace it with the real
`AddBicepTemplate("storage", "./custom-storage.bicep")` API.
- The `PrivateEndpoint` snippet used a fictional `SubnetReference` type
and omitted the required `PrivateLinkServiceConnections`. Fix it to
match the actual `Azure.Provisioning.Network` pattern used by
`AddPrivateEndpoint`, and add an aside pointing readers at that
first-class extension as the recommended path.
- "Open the ./infra directory" is wrong — Bicep is emitted only at
publish time. Replace the steps with `aspire publish -o ./publish`
and accurately describe the emitted `main.bicep` and
`<resource-name>.module.bicep` files.
Also adds a "Bicep samples in the dotnet/aspire repo" link to the See
also list (explicitly requested by the reporter).
Verified:
- pnpm build (Astro + Starlight) passes, starlight-links-validator
reports all internal links valid.
- pnpm test:unit: 163/163 pass, including twoslash-blocks tests.
- Live preview confirms rendered HTML contains AddBicepTemplate, the
AddPrivateEndpoint aside, `aspire publish -o ./publish`, and the
Bicep samples link, with no remaining AddAzureBicepResource.
Fixes #246
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #246
Problem
The Customize Azure resources page contains three concrete inaccuracies, each verified against the
dotnet/aspiresource and the live aspire.dev site:builder.AddAzureBicepResource(name: ..., bicepFilePath: ...), which doesn't exist onIDistributedApplicationBuilder. The real API isAddBicepTemplate(name, bicepFile).PrivateEndpointsnippet: The "Add Azure resources to the infrastructure" example usedSubnet = new SubnetReference { Id = ... }(no such type) and omittedPrivateLinkServiceConnections, which is mandatory. The correct pattern (perAzurePrivateEndpointExtensions.cs#L122-L138) ispe.Subnet.Id = "..."; pe.PrivateLinkServiceConnections.Add(new NetworkPrivateLinkServiceConnection { ... }). Also, Aspire ships a first-classAddPrivateEndpointextension that should be the recommended path for this scenario../infradirectory inside your AppHost project" is incorrect. Aspire emits Bicep only at publish time viaaspire publish -o <dir>, producing amain.bicepplus one<resource-name>.module.bicepper Azure resource. No./infra/folder is created at run time.Changes
PrivateEndpointexample (### Add Azure resources to the infrastructure):using Azure.Provisioning.Network;to the snippet.Subnetassignment to useprivateEndpoint.Subnet.Id = "...".PrivateLinkServiceConnections.Add(new NetworkPrivateLinkServiceConnection { Name, PrivateLinkServiceId, GroupIds })call.<Aside type="tip">pointing readers at the first-classAddPrivateEndpointextension fromAspire.Hosting.Azure.Networkas the recommended path.### Use custom Bicep files):AddAzureBicepResource(name: ..., bicepFilePath: ...)with the real APIAddBicepTemplate("storage", "./custom-storage.bicep").### Inspect generated Bicep):./infra" steps with the actual workflow:aspire publish -o ./publish, then inspect the emittedmain.bicepand<resource-name>.module.bicepfiles.Evidence
Before (captured from https://aspire.dev/integrations/cloud/azure/customize-resources/):
After (this PR; verified via local
pnpm previewagainst the rendered HTML):builder.AddBicepTemplate("storage", "./custom-storage.bicep").PrivateEndpointsnippet uses the correctSubnet.Id/PrivateLinkServiceConnections.Add(...)pattern and an Aside points toAddPrivateEndpoint.Terminalcodeblock withaspire publish -o ./publish.How I verified
dotnet/aspire):AddBicepTemplate/AddBicepTemplateStringsignatures fromsrc/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs.PrivateEndpointusage pattern fromsrc/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs#L122-L138.src/Aspire.Hosting.Azure/AzurePublishingContext.csand the real artifacts inplayground/bicep/BicepSample.AppHost/*.module.bicep.pnpm build(full Astro + Starlight build, 12,226 pages) — passed;starlight-links-validator: All internal links are valid.pnpm test:unit— 163/163 tests passed, includingtwoslash-blocks.vitest.test.ts.pnpm preview+ grep over rendered HTML confirms all four changes (AddBicepTemplate,AddPrivateEndpointaside,aspire publish -o ./publish, Bicep samples link) are present in the final output, with no remaining occurrences ofAddAzureBicepResource.#add-private-endpointsonazure-virtual-networkwas confirmed to resolve by the build's link validator.Out of scope (follow-up candidates)
The reporter also mentioned that the page is "lacking" coverage of customizing parameters/outputs and adding existing resources. That's a content addition rather than a correctness fix, so it's not included here — happy to file a follow-up issue if useful.