Skip to content

docs: fix inaccurate APIs and workflow in Customize Azure resources#951

Draft
IEvangelist wants to merge 1 commit into
mainfrom
dapine/fix-customize-azure-resources-docs-246
Draft

docs: fix inaccurate APIs and workflow in Customize Azure resources#951
IEvangelist wants to merge 1 commit into
mainfrom
dapine/fix-customize-azure-resources-docs-246

Conversation

@IEvangelist
Copy link
Copy Markdown
Member

Fixes #246

Problem

The Customize Azure resources page contains three concrete inaccuracies, each verified against the dotnet/aspire source and the live aspire.dev site:

  1. Non-existent API: The custom Bicep example used builder.AddAzureBicepResource(name: ..., bicepFilePath: ...), which doesn't exist on IDistributedApplicationBuilder. The real API is AddBicepTemplate(name, bicepFile).
  2. Invalid PrivateEndpoint snippet: The "Add Azure resources to the infrastructure" example used Subnet = new SubnetReference { Id = ... } (no such type) and omitted PrivateLinkServiceConnections, which is mandatory. The correct pattern (per AzurePrivateEndpointExtensions.cs#L122-L138) is pe.Subnet.Id = "..."; pe.PrivateLinkServiceConnections.Add(new NetworkPrivateLinkServiceConnection { ... }). Also, Aspire ships a first-class AddPrivateEndpoint extension that should be the recommended path for this scenario.
  3. Wrong inspection workflow: "Open the ./infra directory inside your AppHost project" is incorrect. Aspire emits Bicep only at publish time via aspire publish -o <dir>, producing a main.bicep plus one <resource-name>.module.bicep per Azure resource. No ./infra/ folder is created at run time.

Changes

  • PrivateEndpoint example (### Add Azure resources to the infrastructure):
    • Added using Azure.Provisioning.Network; to the snippet.
    • Fixed the Subnet assignment to use privateEndpoint.Subnet.Id = "...".
    • Added the required PrivateLinkServiceConnections.Add(new NetworkPrivateLinkServiceConnection { Name, PrivateLinkServiceId, GroupIds }) call.
    • Added an <Aside type="tip"> pointing readers at the first-class AddPrivateEndpoint extension from Aspire.Hosting.Azure.Network as the recommended path.
  • Custom Bicep C# example (### Use custom Bicep files):
    • Replaced AddAzureBicepResource(name: ..., bicepFilePath: ...) with the real API AddBicepTemplate("storage", "./custom-storage.bicep").
  • Inspect generated Bicep (### Inspect generated Bicep):
    • Replaced the "Open ./infra" steps with the actual workflow: aspire publish -o ./publish, then inspect the emitted main.bicep and <resource-name>.module.bicep files.
  • See also:

Evidence

Before (captured from https://aspire.dev/integrations/cloud/azure/customize-resources/):

  1. Run your AppHost locally.
  2. Open the ./infra directory inside your AppHost project.
  3. Review the generated .bicep files to verify your customizations.
var storage = builder.AddAzureBicepResource(
    name: "storage",
    bicepFilePath: "./custom-storage.bicep")
var privateEndpoint = new PrivateEndpoint("storagepe")
{
    Location = "eastus",
    Subnet = new SubnetReference { Id = "..." }
};

After (this PR; verified via local pnpm preview against the rendered HTML):

  • Custom Bicep example renders builder.AddBicepTemplate("storage", "./custom-storage.bicep").
  • PrivateEndpoint snippet uses the correct Subnet.Id / PrivateLinkServiceConnections.Add(...) pattern and an Aside points to AddPrivateEndpoint.
  • Inspect section renders a Terminal codeblock with aspire publish -o ./publish.
  • "See also" includes the Bicep samples link.

How I verified

  1. Cross-checked every claim against the product source (dotnet/aspire):
    • AddBicepTemplate/AddBicepTemplateString signatures from src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs.
    • PrivateEndpoint usage pattern from src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs#L122-L138.
    • Emitted Bicep filenames from src/Aspire.Hosting.Azure/AzurePublishingContext.cs and the real artifacts in playground/bicep/BicepSample.AppHost/*.module.bicep.
  2. Reproduced all three issues on the live site via Playwright before editing.
  3. Validated the edit locally:
    • pnpm build (full Astro + Starlight build, 12,226 pages) — passed; starlight-links-validator: All internal links are valid.
    • pnpm test:unit163/163 tests passed, including twoslash-blocks.vitest.test.ts.
    • pnpm preview + grep over rendered HTML confirms all four changes (AddBicepTemplate, AddPrivateEndpoint aside, aspire publish -o ./publish, Bicep samples link) are present in the final output, with no remaining occurrences of AddAzureBicepResource.
  4. Anchor #add-private-endpoints on azure-virtual-network was 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Customize Azure resources has inaccurate docs

1 participant