docs: fix inaccurate Customize Azure resources page#946
Draft
IEvangelist wants to merge 1 commit into
Draft
Conversation
Reported in #246 by @kamranayub. Verified each claim against microsoft/aspire main and against the live page on aspire.dev. Three concrete inaccuracies fixed: * "Use custom Bicep files" called `builder.AddAzureBicepResource(...)`, which is not a real API. Replaced with `AddBicepTemplate(name, path)` (and the matching `addBicepTemplate` for the TypeScript sample). The C# sample also called `.WithReference(storage)` on a bare `AzureBicepResource`, which doesn't compile because that resource doesn't implement `IResourceWithConnectionString`. Replaced with `WithEnvironment("STORAGE_CONNECTION_STRING", storage.GetOutput(...))`, which is the correct way to consume a Bicep output. * "Inspect generated Bicep" said to run the AppHost locally and look in an `./infra` folder. Local provisioning compiles Bicep into a temp directory and never writes it into the project. Rewrote the steps to use `aspire publish` (or `aspire deploy`) and look in the `aspire-output` folder (the publish/deploy default). * "Add Azure resources to the infrastructure" used a `SubnetReference` type that doesn't exist in `Azure.Provisioning.Network`. Replaced the example with the idiomatic Aspire pattern using `vnet.AddSubnet(...).AddPrivateEndpoint(target)` from `Aspire.Hosting.Azure.Network`, plus a note that authors can fall back to `ConfigureInfrastructure` + `Azure.Provisioning` constructs when no Aspire-native builder fits. Also addressed the reporter's wishlist for "passing parameters and consuming outputs" with a new "Pass parameters and read outputs" subsection that demonstrates `AddParameter(name, secret: true)`, `WithParameter(name, parameterResource)`, and `GetOutput(name)` end-to-end in C# and TypeScript, and lists the supported `WithParameter` value types (ParameterResource, BicepOutputReference, ReferenceExpression, IResourceWithConnectionString, EndpointReference). Added a `LearnMore` pointer to the `playground/bicep` sample for fuller scenarios, and a short `Aside` about `AddBicepTemplateString` for inline Bicep. The two new TypeScript twoslash blocks call `withParameter(name, { value })` with a string and a `ParameterResource`, which the polyglot tests in `tests/PolyglotAppHosts/Aspire.Hosting.Azure/TypeScript/apphost.ts` exercise verbatim. The current `aspire.d.ts` generator only emits the last `withParameter` overload, so twoslash sees `{ value?: EndpointReference }` only and reports `ts(2769)`. Added two `KNOWN_TYPE_BUGS` entries with a clear label so the regression gate stays precise; the entries will fall out automatically once the generator emits all overloads. 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 page at https://aspire.dev/integrations/cloud/azure/customize-resources/ contains three concrete API inaccuracies that mislead readers building custom Bicep workflows. Verified each claim against the microsoft/aspire
mainsource tree and against the live page on aspire.dev (screenshot in Evidence below).Changes
All edits are scoped to
src/frontend/src/content/docs/integrations/cloud/azure/customize-resources.mdxplus one allowlist entry pair insrc/frontend/tests/unit/twoslash-blocks-audit.ts(see Twoslash note below).AddBicepTemplateinstead ofAddAzureBicepResourcein the C# Use custom Bicep files sample.AddAzureBicepResourceis not a public API; the real APIs areAddBicepTemplate(name, bicepFile)andAddBicepTemplateString(name, bicepContent). The TypeScript sample was already using the correctaddBicepTemplatename..WithReference(storage)on the bicep resource with.WithEnvironment("STORAGE_CONNECTION_STRING", storage.GetOutput("connectionString")).AzureBicepResourcedoes not implementIResourceWithConnectionString, so the original snippet did not compile. ShowingGetOutputhere also addresses one of the reporter's wishlist items (consuming outputs from a custom Bicep template).aspire run) does not write Bicep into the project — local provisioning compiles Bicep into a temporaryaspire-bicepdirectory (perBicepProvisioner.cs). Updated the steps to useaspire publish(oraspire deploy) and to look in theaspire-outputfolder (the publish/deploy default perPublishCommandStrings.resx). Added anotecallout calling out the difference and atipcallout pointing to the Azure Portal Export template trick.SubnetReferenceexample in Add Azure resources to the infrastructure with the idiomatic Aspire pattern usingAzurePrivateEndpointExtensions.AddPrivateEndpoint(fromAspire.Hosting.Azure.Network). Added a TypeScript note that the high-level builders are C#-only today, plus a fallback paragraph pointing readers atConfigureInfrastructure+Azure.Provisioningfor advanced needs not covered by Aspire-native builders.AddParameter(name, secret: true),WithParameter(name, parameterResource), andGetOutput(name). Added a bulleted list of the supportedWithParametervalue types (ParameterResource,BicepOutputReference,ReferenceExpression,IResourceWithConnectionString,EndpointReference) and aLearnMorelink to theplayground/bicepsample for end-to-end scenarios — closes the wishlist items in the issue.tipaboutAddBicepTemplateString/addBicepTemplateStringfor inline Bicep snippets.playground/bicepsample link.Evidence
Live aspire.dev page before the fix (issue still reproduces today):
builder.AddAzureBicepResource(name: ..., bicepFilePath: ...)followed by.WithReference(storage)../infra.new PrivateEndpoint("storagepe") { Subnet = new SubnetReference { Id = "..." } }.Local rendered HTML after the fix shows the new
AddPrivateEndpoint(blobs)snippet, the rewrittenaspire publish/aspire-outputsteps, and the newPass parameters and read outputssubsection in the right-hand TOC.How I verified
microsoft/aspire.dev:mainandmicrosoft/aspire:main, then createddapine/fix-customize-azure-resources-246from the new tip.microsoft/aspireand the matching polyglot TypeScript usage intests/PolyglotAppHosts/to confirm the real API surface (signatures and call patterns).customize-resources.mdx, then ran:pnpm --dir src/frontend exec astro sync— clean (no errors related to this page).pnpm --dir src/frontend exec astro build— page builds and renders in all 12 locales (errors in the build log are pre-existing GitHub API rate limits ingetContributors.tsand unrelated TypeScript reference page collisions).pnpm --dir src/frontend twoslash-typesthenpnpm --dir src/frontend test:unit:twoslash-blocks— passes after the allowlist entries below.dist/integrations/cloud/azure/customize-resources/index.htmlto confirm the new section headings appear in the on-this-page TOC and the new code samples are present.Twoslash note
The two new TypeScript twoslash blocks call
withParameter(name, { value })with astringand aParameterResource. The polyglot testtests/PolyglotAppHosts/Aspire.Hosting.Azure/TypeScript/apphost.tsuses this exact pattern, so the runtime API supports it. However, the currentaspire.d.tsgenerator only emits the lastwithParameteroverload ({ value?: EndpointReference }), so twoslash reportsts(2769) — No overload matches this call.Added twoKNOWN_TYPE_BUGSentries with a clear label so the regression gate stays precise; the entries fall out automatically once the generator emits all overloads (separate, pre-existing concern inscripts/generate-twoslash-types.ts).Out of scope
withParameteris emitted toaspire.d.ts. Worth a follow-up issue againstscripts/generate-twoslash-types.ts, but outside the scope of this docs fix.