Align Azure Cosmos DB emulator with GA vnext-latest image#18161
Align Azure Cosmos DB emulator with GA vnext-latest image#18161guanzhousongmicrosoft wants to merge 8 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18161Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18161" |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR renames the internal "preview emulator" concept to "vNext emulator" throughout the Azure Cosmos DB hosting code, and updates the container image tag from vnext-preview to vnext-latest. It also refines the WithDataVolume behavior to conditionally set the persistence environment variable only for the classic emulator, and adds explicit ENABLE_EXPLORER environment variable support for the vNext Data Explorer.
Changes:
- Renamed
IsPreviewEmulator→IsVNextEmulator,TagVNextPreview→TagVNextLatest, anduseVNextPreview→useVNextacross the codebase, updating the image tag fromvnext-previewtovnext-latest. - Updated
WithDataVolumeso theAZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCEenv var is only set for the classic emulator (not vNext), and added explicitENABLE_EXPLORER=truetoWithDataExplorer. - Added comprehensive unit tests covering the new emulator image tags, data volume paths, partition count validation, data explorer, and connection string format.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs |
Rename constant and tag value from vnext-preview to vnext-latest |
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs |
Rename IsPreviewEmulator to IsVNextEmulator with updated doc |
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs |
Rename parameters, update conditional logic for data volume and data explorer |
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorConnectionString.cs |
Rename parameter from isPreviewEmulator to isVNext |
.agents/skills/update-container-images/UpdateImageTags.cs |
Update unversioned tag check to vnext-latest |
.agents/skills/update-container-images/SKILL.md |
Update documentation for the new tag name |
tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs |
Add tests for vNext emulator behaviors |
The vNext (Linux-based) Cosmos DB emulator is GA and the image tag is vnext-latest, so the 'preview' terminology was misleading. Rename internal members IsPreviewEmulator -> IsVNextEmulator, useVNextPreview -> useVNext, and the isPreviewEmulator parameter -> isVNext, and update internal comments, XML doc descriptions, and NotSupportedException messages accordingly. The public RunAsPreviewEmulator API and the [Experimental] ASPIRECOSMOSDB001 attribute are intentionally left unchanged to avoid a breaking API-surface change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
Two consistency fixes surfaced while validating against the GA vnext-latest emulator source: - WithDataVolume no longer sets AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE for the vNext emulator. That variable is only honored by the classic emulator; the vNext emulator persists implicitly when a volume is mounted at /data, so setting it was a no-op. - WithDataExplorer now sets ENABLE_EXPLORER=true explicitly instead of relying on the image's default remaining true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
…orer, and vNext connection string Locks in the behavior aligned with the GA vnext-latest image: default image tags (vnext-latest for the vNext emulator, stable for classic), data volume path/persistence env var per emulator, WithPartitionCount guards, WithDataExplorer custom port + ENABLE_EXPLORER, and the URL-based vNext connection string format. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
b342687 to
96c63eb
Compare
The GA vnext-latest image defaults ENABLE_EXPLORER=true, which runs an otherwise-unused Node Data Explorer process and, because the readiness probe is 'ready = postgres && gateway && (explorer || !ENABLE_EXPLORER)', makes /ready wait on the explorer even when it is never exposed to the host. Set ENABLE_EXPLORER=false as a baseline on the vNext emulator; WithDataExplorer re-enables it (environment callbacks are last-write-wins). This makes the explorer opt-in - matching Aspire only exposing port 1234 when WithDataExplorer is called - avoids an unused process, and decouples readiness from the explorer. Adds tests for the default/opt-in/classic ENABLE_EXPLORER states and applies minor test polish (TryGetValue for clearer failures, shared CosmosConstants.EmulatorAccountKey, symmetric IsReadOnly assertion). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
Covers the WithCertificateTrustConfiguration callback that sets NODE_EXTRA_CA_CERTS so the vNext emulator's Node-based Data Explorer trusts the Aspire-managed certificate bundle. This was the last unit-coverable emulator code path not already exercised; the remaining uncovered paths (OnConnectionStringAvailable/OnResourceReady/CreateCosmosClient) require a live emulator container and are covered only by the skipped functional tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
Extracts CreateCosmosClient from a static local into an internal static method so its three branches (absolute-URI/token-credential, emulator connection string with Gateway+LimitToEndpoint, and non-emulator) can be unit-tested directly. Adds tests for: the vNext health endpoint (emulatorhealth/8080, ExcludeReferenceEndpoint, health check), classic health-check annotation, WithDataVolume custom name, WithPartitionCount boundary values (1/250), WithDataExplorer default port, OnResourceReady throwing when the client is uninitialized (ResourceReadyEvent), OnConnectionStringAvailable initializing the client (ConnectionStringAvailableEvent), and CreateCosmosClient branches. Also strengthens the HTTPS cert callback tests to assert values (PROTOCOL/EXPLORER_PROTOCOL/CERT_PATH) rather than only key presence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
Adds: explicit publish-mode no-op tests for RunAsEmulator/RunAsPreviewEmulator (the early return was already covered cross-file by AzureRunAsEmulatorModeTests, but a local test makes it explicit); a health-check factory guard test (the classic emulator CosmosClient factory throws 'CosmosClient is not initialized.' until the connection string is available); and URL display-callback tests for the vNext health endpoint (DisplayLocation=DetailsOnly) and the Data Explorer (DisplayText='Data Explorer'). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
Per Copilot review on microsoft#18161: clarify that 'postgres' in the readiness-probe formula refers to the vNext emulator's internal PostgreSQL storage engine, and document that 1234 is the emulator's fixed internal Data Explorer port (vs the configurable host port) in the Data Explorer tests. Comment-only changes; no behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Description
#18158 (merged) bumped the Azure Cosmos DB Linux-based (vNext) emulator image
tag to the GA
vnext-latest. This PR completes the GA alignment of the Aspireintegration: it updates the integration's internal naming and docs from
"preview" to "vNext", fixes emulator environment-variable inconsistencies, and
adds comprehensive test coverage for the emulator surface.
What changes for users:
WithDataVolume()on the vNext emulator no longer emits theAZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCEenvironment variable. Thatvariable is only honored by the classic (Windows) emulator; the vNext emulator
persists implicitly when a volume is mounted at
/data, so setting it was ano-op. It is still emitted for the classic emulator.
RunAsPreviewEmulator()setsENABLE_EXPLORER=falseby default, andWithDataExplorer()re-enables it (ENABLE_EXPLORER=true). Previously theexplorer ran unconditionally (the GA image defaults it on), which also made the
emulator's
/readyreadiness probe wait on the explorer even when it was neverexposed (the probe is
ready = postgres && gateway && (explorer || !ENABLE_EXPLORER)).RunAsPreviewEmulator()continues to pull the GAvnext-latestimage (fromUpdate Cosmos DB preview emulator tag to vnext-latest #18158). The public API and call site are unchanged.
Implementation details:
IsPreviewEmulator->IsVNextEmulator,useVNextPreview->useVNext, parameterisPreviewEmulator->isVNext, plus comments, XML doc descriptions, andNotSupportedExceptionmessages updated from "preview" to "Linux-based (vNext)".CreateCosmosClientwas extracted from a static local into aninternal staticmethod so its branches can be unit-tested directly.
RunAsPreviewEmulatormethod and the[Experimental("ASPIRECOSMOSDB001")]attribute are intentionally kept to avoida breaking API-surface change.
This change was validated against the GA emulator source: the gateway advertises
endpoints from
GATEWAY_PUBLIC_ENDPOINT, and Aspire neutralizes the dynamichost-port mapping by setting
LimitToEndpoint = truefor emulator connectionstrings in the hosting seeding client and both the Cosmos and EF Core Cosmos
client integrations. The configured ports (gateway 8081, health
/readyon8080, Data Explorer 1234),
PROTOCOL/EXPLORER_PROTOCOL/CERT_PATH/CERT_SECRET/NODE_EXTRA_CA_CERTSenv vars, and the
/datapersistence path all match the GA image.User-facing usage
Testing
Added comprehensive unit coverage for the emulator surface in
AzureCosmosDBExtensionsTests(141 Cosmos tests pass; build is clean, 0 warnings,0 errors):
vnext-latest/stable); publish-mode no-op for bothRunAsEmulatorandRunAsPreviewEmulator.WithDataVolumevNext (/data, no persistence env) vs classic (/tmp/cosmos/appdata+ env), and a custom volume name.WithPartitionCounthappy path, boundary values (1/250), out-of-range throw, and vNextNotSupportedException.WithDataExploreropt-in (ENABLE_EXPLORER=true), default/custom host port, non-vNext throw, HTTPS endpoint flip, and the Data Explorer display-text URL callback.emulatorhealth/8080,ExcludeReferenceEndpoint,/ready, DetailsOnly URL) and classic health-check registration + factory guard.OnConnectionStringAvailableinitializes the client;OnResourceReadythrows when the client is uninitialized.CreateCosmosClientall three branches (emulator connection string → Gateway/LimitToEndpoint, non-emulator, absolute URI).PROTOCOL/EXPLORER_PROTOCOL/CERT_PATH/CERT_SECRETvalues, with/without password) and the certificate-trust callback (NODE_EXTRA_CA_CERTS).DisableServerCertificateValidation) and classic connection string.Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?