Skip to content

Cosmos DB NoSQL samples: no LocalStack CA, the endpoint is publicly trusted - #55

Merged
paolosalvatori merged 1 commit into
mainfrom
cosmos-nosql-public-certificate
Nov 10, 2026
Merged

paolosalvatori merged 1 commit into
mainfrom
cosmos-nosql-public-certificate

Conversation

@paolosalvatori

Copy link
Copy Markdown
Collaborator

Motivation

The Python and .NET web-app-cosmosdb-nosql-api samples installed the LocalStack root CA so that the app would trust the emulated Cosmos DB endpoint: 05-deploy-app.sh stored it in a localstack-ca ConfigMap, deployment.yml mounted it and pointed REQUESTS_CA_BUNDLE (Python) or SSL_CERT_FILE (.NET) at it, 03-run-docker-container.sh mounted it into the local Docker run, and 00-variables.sh carried a LOCALSTACK_URL that readers had to empty before a run on Azure. Those steps existed only for the emulator, and deployment.yml asked readers to remove them when switching to Azure.

localstack/localstack-pro pull request 10406 makes the emulator serve the Cosmos DB for NoSQL endpoint, now <account>.cosmos.azure.localhost.localstack.cloud, with the LocalStack public certificate. The samples then verify it with their default trust store, as they verify <account>.documents.azure.com on Azure, so the steps go. Left in place, the Python sample's REQUESTS_CA_BUNDLE, which holds only the LocalStack root CA, would make its pods reject the endpoint, and also every other emulator endpoint served with the public certificate, such as Key Vault and Blob Storage.

Fixes SMF-1138

Changes

  • samples/web-app-cosmosdb-nosql-api/python and samples/web-app-cosmosdb-nosql-api/dotnet:
    • scripts/05-deploy-app.sh: no longer downloads the LocalStack root CA or creates the localstack-ca ConfigMap.
    • scripts/deployment.yml: no REQUESTS_CA_BUNDLE / SSL_CERT_FILE variable, volume mount or localstack-ca volume.
    • scripts/03-run-docker-container.sh: no CA download or mount, and no native_path, which only the CA file used.
    • scripts/00-variables.sh: no LOCALSTACK_URL.
    • README.md: the LocalStack note about LOCALSTACK_URL and the root CA is removed.
  • .gitignore: the entry for the CA file that 03-run-docker-container.sh wrote is removed.

The MongoDB API samples need no change: they install no CA, and their endpoint does not use TLS in the emulator.

Tests

The same scripts ran on both targets, 01 to 05 in order, after a cluster created by scripts/01-user-assigned-managed-identity.sh; the Python and .NET samples share the account and the namespace, so each language ran in turn.

  • LocalStack for Azure, an image built from localstack/localstack-pro pull request 10406:
    • The account reports https://local-nosql-test.cosmos.azure.localhost.localstack.cloud:4511/, and the endpoint presents the Google Trust Services chain.
    • 03-run-docker-container.sh: both apps answer /health with ok and store and list an activity, with no CA variable in the container.
    • 05-deploy-app.sh and tests/test-vacation-planner.sh: both languages pass (health, add, delete). In a Python pod, with no CA variable, TLS to Cosmos DB, Key Vault and Blob Storage verifies with certifi. With the previous version of the sample, Key Vault and Blob Storage failed in that pod.
  • Azure (italynorth), on a real AKS cluster with the same cluster script (only its prefix, a node ceiling of 4 and the admin credentials changed for the run):
    • 03-run-docker-container.sh: both apps answer /health with ok and store and list an activity.
    • 05-deploy-app.sh and tests/test-vacation-planner.sh: both languages pass (health, add, delete).
    • The resource group was deleted afterwards.
  • bash -n passes on the changed scripts, yq parses both manifests, and pre-commit run: gitleaks passed, zizmor skipped.

Related

  • localstack/localstack-pro pull request 10406 (SMF-1137): the emulator change. This pull request should merge once that one ships in localstack/localstack-azure:latest. Until then the Cosmos DB for NoSQL jobs of this repository's Samples CI fail, because the published image still serves a LocalStack-CA certificate the samples no longer trust.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FvNuJLfY2KkMwaymfFnz7R

…LocalStack CA

The emulator now serves the Cosmos DB for NoSQL endpoint
(<account>.cosmos.azure.localhost.localstack.cloud) with the LocalStack public
certificate, so the Python and .NET Vacation Planner verify it with their
default trust store, on the emulator as on Azure. The LocalStack-only steps
that installed the LocalStack root CA are removed: the localstack-ca
ConfigMap, the REQUESTS_CA_BUNDLE / SSL_CERT_FILE variables and their
volume, the CA mount of the local Docker run and the LOCALSTACK_URL
variable. Left in place, the Python sample's REQUESTS_CA_BUNDLE would now
make it distrust the endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FvNuJLfY2KkMwaymfFnz7R
Copilot AI balanced review requested due to automatic review settings November 10, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The required rollout of localstack/localstack-pro#10406 to localstack/localstack-azure:latest remains unverified, while removing CA trust breaks NoSQL CI with the prior image and reported emulator tests used a custom image.

No open issues 🎉

What changed in this PR

Updates the Python and .NET Cosmos DB NoSQL samples to use default certificate trust stores instead of installing the LocalStack root CA. This aligns the samples with the emulator’s publicly trusted endpoint and removes Azure-specific configuration cleanup. The PR description notes that merging depends on the emulator change shipping in localstack/localstack-azure:latest.

Changes:

  • Removes CA downloads, Docker mounts, Kubernetes ConfigMap creation, and certificate environment overrides.
  • Removes the unused LOCALSTACK_URL setting and related README instructions.
  • Deletes the ignore rule for the CA file that scripts no longer generate.
File Description
samples/​web-app-cosmosdb-nosql-api/​python/​scripts/​deployment.yml Removes the CA mount and REQUESTS_CA_BUNDLE override.
samples/​web-app-cosmosdb-nosql-api/​python/​scripts/​05-deploy-app.sh Removes CA download and ConfigMap creation.
samples/​web-app-cosmosdb-nosql-api/​python/​scripts/​03-run-docker-container.sh Removes CA handling and its path-conversion helper.
samples/​web-app-cosmosdb-nosql-api/​python/​scripts/​00-variables.sh Removes LOCALSTACK_URL.
samples/​web-app-cosmosdb-nosql-api/​python/​README.md Removes obsolete CA setup guidance.
samples/​web-app-cosmosdb-nosql-api/​dotnet/​scripts/​deployment.yml Removes the CA mount and SSL_CERT_FILE override.
samples/​web-app-cosmosdb-nosql-api/​dotnet/​scripts/​05-deploy-app.sh Removes CA download and ConfigMap creation.
samples/​web-app-cosmosdb-nosql-api/​dotnet/​scripts/​03-run-docker-container.sh Removes CA handling and its path-conversion helper.
samples/​web-app-cosmosdb-nosql-api/​dotnet/​scripts/​00-variables.sh Removes LOCALSTACK_URL.
samples/​web-app-cosmosdb-nosql-api/​dotnet/​README.md Removes obsolete CA setup guidance.
.gitignore Removes the generated CA-file rule and updates its comment.

Review effort: Balanced

@paolosalvatori

Copy link
Copy Markdown
Collaborator Author

Answering Copilot's overview:

The required rollout of localstack/localstack-pro#10406 to localstack/localstack-azure:latest remains unverified, while removing CA trust breaks NoSQL CI with the prior image and reported emulator tests used a custom image.

Correct on all three counts, and it is the intended order:

  • This pull request merges only once the emulator change is in localstack/localstack-azure:latest, as Related says. Until then, the Cosmos DB for NoSQL jobs of this pull request's Samples CI fail: the published image still serves the endpoint with a certificate issued by the LocalStack root CA, which the samples no longer install. On that image, a pod without the CA fails with certificate verify failed: unable to get local issuer certificate (checked on 2026-11-10 with localstack/localstack-azure:latest, build 2026.11.0.dev837).
  • The emulator runs in Tests used an image built from that change because no published image carries it yet. The Azure runs depend on no emulator change, and both samples passed them on a real AKS cluster.
  • Once latest carries the change, the Samples CI of this pull request needs a re-run before it merges.

@paolosalvatori
paolosalvatori merged commit 19e15f2 into main Nov 10, 2026
6 of 8 checks passed
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.

2 participants