Repository navigation
Use addAzureCosmosDB in the EF Core Cosmos DB TypeScript AppHost samples - #2001
Merged
David Pine (IEvangelist) merged 2 commits intoNov 1, 2026
Merged
Conversation
The TypeScript AppHost export is addAzureCosmosDB (Aspire.Hosting.Azure.CosmosDB ts-module). The three EF Core Cosmos DB host samples called addAzureCosmosDb, which fails type checking and throws at runtime because member lookup is case-sensitive. Add a unit check that TypeScript AppHost samples in English docs never call a casing variant of an exported Aspire TypeScript API. Co-authored-by: Copilot <[email protected]>
Contributor
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
David Fowler (davidfowl)
marked this pull request as ready for review
October 30, 2026 16:59
David Fowler (davidfowl)
requested review from
David Pine (IEvangelist) and
Eric Erhardt (eerhardt)
as code owners
October 30, 2026 16:59
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The casing audit’s lowercase-only prefix misses uppercase-initial method names, allowing incorrectly cased calls such as builder.AddAzureCosmosDB(...) to pass undetected.
1 open issue
What changed in this PR
This PR corrects the Cosmos DB API casing in the EF Core hosting guide’s TypeScript AppHost samples and adds a documentation regression check.
Changes:
- Replaces all three
addAzureCosmosDbcalls withaddAzureCosmosDB. - Adds a test that scans English TypeScript AppHost samples for casing mismatches against exported API names.
| File | Description |
|---|---|
src/frontend/tests/unit/typescript-apphost-api-casing.vitest.test.ts |
Adds the API-casing regression check. |
src/frontend/src/content/docs/integrations/databases/efcore/azure-cosmos-db/azure-cosmos-db-host.mdx |
Corrects the API name in three TypeScript samples. |
Review effort: Balanced
Match method names that start with an uppercase letter, and end a sample at any closing fence at least as long as its opener (CommonMark), so a longer closer does not pull later C# blocks into the TypeScript scan. Co-authored-by: Copilot <[email protected]>
David Pine (IEvangelist)
enabled auto-merge (squash)
November 1, 2026 14:27
David Pine (IEvangelist)
approved these changes
Nov 1, 2026
David Pine (IEvangelist)
deleted the
aspireagent/fix-cosmos-efcore-ts-casing
branch
November 1, 2026 14:27
David Pine (IEvangelist)
pushed a commit
that referenced
this pull request
Nov 1, 2026
…2002) ## Summary The TypeScript AppHost samples for Kubernetes Ingress and Gateway routing use the C# overload names. Those names don't exist in the TypeScript AppHost SDK, so a reader who copies the samples hits `withPath is not a function` (or sends the wrong argument type). In the TypeScript SDK, each C# overload is exported under its own capability name. Upstream `microsoft/aspire` `main` (c77b0c13c34616d1ce4698771bdd445fd50c7a99) defines them in [`KubernetesIngressExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/KubernetesIngressExtensions.cs), [`KubernetesGatewayExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/KubernetesGatewayExtensions.cs) and [`CertManagerExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs). The in-repo `src/data/ts-modules/Aspire.Hosting.Kubernetes.*.json` surface matches them. | C# overload | Upstream `[AspireExport]` | TS sample before | TS sample after | | --- | --- | --- | --- | | `WithPath(path, endpoint)` | `withIngressPath` | `ingress.withPath(...)` | `ingress.withIngressPath(...)` | | `WithTls()` (Ingress) | `withIngressTlsAuto` | `ingress.withTls()` (TS `withTls` requires `secretName`) | `ingress.withIngressTlsAuto()` | | `WithIngressClass(IResourceBuilder<ParameterResource>)` | `withIngressClassParam` | `ingress.withIngressClass(param)` | `ingress.withIngressClassParam(param)` | | `WithHostname(IResourceBuilder<ParameterResource>)` (Ingress) | `withIngressHostnameParam` | `ingress.withHostname(param)` | `ingress.withIngressHostnameParam(param)` | | `WithRoute(path, endpoint)` | `withGatewayPathRoute` | `storefront.withRoute(...)` | `storefront.withGatewayPathRoute(...)` | | `WithTls(issuer)` (Gateway) | `withGatewayTlsIssuer` | `storefront.withTls(letsencrypt)` | `storefront.withGatewayTlsIssuer(letsencrypt)` | | `WithHostname(IResourceBuilder<ParameterResource>)` (Gateway) | `withGatewayHostnameParam` | `storefront.withHostname(param)` | `storefront.withGatewayHostnameParam(param)` | Upstream's own TypeScript polyglot AppHost uses the same names, for example `gateway.withGatewayTlsIssuer(stagingIssuer)` in [`tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts). This PR changes 15 sample lines in 6 TypeScript blocks: - `deployment/kubernetes-ingress.mdx`: 3 blocks. - `deployment/kubernetes/aks.mdx`: 3 blocks. The C# samples and the prose are unchanged. ### How this was found I ran a systematic TypeScript AppHost drift audit across all docs: - **Scope:** 1,264 TS fences in 611 files. 398 are `twoslash` blocks, which the build already type-checks. - **Type-check:** I compiled the remaining 635 AppHost blocks (507 full samples, 128 fragments) against `src/data/twoslash/aspire.d.ts` with the repo's twoslash compiler options. That produced 202 English diagnostics. - **Triage:** - Argument-shape diagnostics were mostly gaps in the local `.d.ts` generator, not sample errors. For example, upstream emits options objects for all optional parameters, so calls like `runAsEmulator({ configureContainer })` are correct. - Name-level diagnostics were checked against the ts-modules data and upstream source. - The Ingress/Gateway names are the confirmed group fixed here. - `addAzureCosmosDb` is already handled by #2001. ### Regression test The new `tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts` scans the TypeScript samples in the English docs for `addIngress`/`addGateway` resources. It checks each call on them against the ts-modules surface for `KubernetesIngressResource`/`KubernetesGatewayResource`, including inherited interface targets. It flags: - methods that aren't exported; - calls with fewer arguments than the required parameters; - resource variables passed where a `string` is required. On `main` it fails with 14 problems: ``` deployment/kubernetes/aks.mdx:311: withRoute is not exported for KubernetesGatewayResource deployment/kubernetes/aks.mdx:360: withRoute is not exported for KubernetesGatewayResource deployment/kubernetes/aks.mdx:361: withTls expects a string but got resource letsencrypt deployment/kubernetes/aks.mdx:458: withHostname expects a string but got resource hostname deployment/kubernetes/aks.mdx:459: withRoute is not exported for KubernetesGatewayResource deployment/kubernetes-ingress.mdx:100: withTls expects 1 argument(s) but got 0 deployment/kubernetes-ingress.mdx:103: withPath is not exported for KubernetesIngressResource deployment/kubernetes-ingress.mdx:104: withPath is not exported for KubernetesIngressResource deployment/kubernetes-ingress.mdx:137: withTls expects 1 argument(s) but got 0 deployment/kubernetes-ingress.mdx:140: withPath is not exported for KubernetesIngressResource deployment/kubernetes-ingress.mdx:141: withPath is not exported for KubernetesIngressResource deployment/kubernetes-ingress.mdx:198: withIngressClass expects a string but got resource ingressClass deployment/kubernetes-ingress.mdx:199: withHostname expects a string but got resource hostname deployment/kubernetes-ingress.mdx:200: withTls expects 1 argument(s) but got 0 ``` With this change, the test passes. The 15th line, `aks.mdx:460` (`withTls(letsencrypt)` → `withGatewayTlsIssuer`), is the same issuer drift. The test doesn't detect it because that snippet reuses `letsencrypt` from an earlier block without declaring it. ### Screenshots The only visual change is the rendered TypeScript tab text. Captures are Playwright, desktop 1280×900, light theme, against a local dev server. | | Before (`main`) | After | | --- | --- | --- | | Kubernetes Ingress — Routing paths to services (desktop, light) |  |  | | AKS — Add automatic HTTPS with cert-manager (desktop, light) |  |  | ### Out of scope The TypeScript samples in `kubernetes-ingress-aks.mdx` and `kubernetes-gateway-aks.mdx` use a different, non-canonical shape (`import { DistributedApplication } from "@aspire/apphost"` with synchronous chaining). Correcting them needs a sample rewrite rather than a rename, so I left them for a separate change. Overlap check: no open issue or PR mentions these names. #1996 and #1868 touch other Kubernetes pages but not these samples. ## Third-party links and affiliations None. The links above point to `microsoft/aspire` source. ## Validation - `npx vitest run tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts`: fails on `main` (14 problems above) and passes with this change. - `npx vitest run`: 85 files, 1,121 passed, 1 skipped. - `npx eslint . --max-warnings 0`: clean. - `npx prettier --check` on the new test: clean. The two `.mdx` files already have Prettier warnings on `main`, unchanged by this PR. - Playwright before/after screenshots above. **🤖 Posted by AspireAgent (AI Agent)** Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]>
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.

Summary
The TypeScript AppHost samples on Azure Cosmos DB EF Core hosting call
builder.addAzureCosmosDb("cosmos-db")three times. The exported TypeScript API isaddAzureCosmosDB, the casing used by the C#AddAzureCosmosDBand by the sibling Azure Cosmos DB hosting page. TypeScript member lookup is case-sensitive, so a reader who copies any of these samples intoapphost.mtsgets a type error ("Property 'addAzureCosmosDb' does not exist"), and plain JS execution fails withbuilder.addAzureCosmosDb is not a function.Upstream evidence:
src/data/ts-modules/Aspire.Hosting.Azure.CosmosDB.13.6.0.jsonwas generated from microsoft/aspiresourceCommitf4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62. It exportsaddAzureCosmosDB(name: string): AzureCosmosDBResource.src/data/twoslash/aspire.d.tslikewise declares onlyaddAzureCosmosDB.Fix: correct all three calls to
addAzureCosmosDB.Regression check: the new
tests/unit/typescript-apphost-api-casing.vitest.test.tsscans TypeScript fences containingcreateBuilderin all English docs. It fails when a call name matches an exported Aspire TypeScript function only case-insensitively, which is a precise, low-false-positive drift signal.mainit fails with exactly the threeaddAzureCosmosDb -> addAzureCosmosDBhits in this file.How it was found: I audited 739 TypeScript AppHost blocks (2,996
.add/with/as/...(calls, excludingwhats-new) against the in-repots-modulesdata. Other unexported names were:addMailDev,addMy*);withRoleAssignments, which is present inaspire.d.ts;withRoute/withHostname/withTls, which differ from the exportedwithGatewayPathRoute/withGatewayTls*names. That one needs a semantic API mapping, so I left it out of scope for this focused change.Overlap: no open issue or PR mentions
addAzureCosmosDb. Open PR #1635 (last updated 2026-09-10) touches this file, but its head6311f11bstill contains all threeaddAzureCosmosDbcalls, so it doesn't fix this. A rebase there would take this one-word change.Rendered TypeScript sample, desktop 1280×900, light theme (local dev server)
Third-party links and affiliations
None
Validation
npx vitest run tests/unit/typescript-apphost-api-casing.vitest.test.ts: fails onmainwith the three hits above and passes with the fix.npx vitest run: 85 files, 1,121 passed, 1 skipped.npx eslint . --max-warnings 0: clean.npx prettier --checkon the new test: clean.astro devserver.🤖 Posted by AspireAgent (AI Agent)