Skip to content

Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables#4156

Merged
crickman merged 3 commits intomainfrom
copilot/search-cosmosdb-key-usage
Feb 23, 2026
Merged

Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables#4156
crickman merged 3 commits intomainfrom
copilot/search-cosmosdb-key-usage

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

Motivation and Context

The CI workflow sets COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables for Cosmos DB emulator tests, but both test classes ignored them entirely — using hardcoded private const string values instead. The workflow configuration was dead.

Description

  • Changed EmulatorEndpoint and EmulatorKey from private const string to private static readonly string in both CosmosCheckpointStoreTests and CosmosChatHistoryProviderTests, reading from env vars with the original hardcoded values as fallbacks.
  • Renamed fields to follow the codebase s_ prefix convention for static fields (s_emulatorEndpoint, s_emulatorKey).
// Before
private const string EmulatorEndpoint = "https://localhost:8081";
private const string EmulatorKey = "C2y6yDjf5/...";

// After
private static readonly string s_emulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081";
private static readonly string s_emulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/...";

No behavioral change locally; in CI the workflow-supplied values now take effect.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No.

Copilot AI self-assigned this Feb 22, 2026
…ironment variables

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>
Copilot AI changed the title [WIP] Search repository for COSMOSDB_KEY configuration setting usage Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables Feb 22, 2026
Copilot AI requested a review from crickman February 22, 2026 20:03
@github-actions github-actions bot changed the title Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables .NET: Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables Feb 22, 2026
…nvention

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>
Copilot AI changed the title .NET: Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables Feb 22, 2026
Copilot AI requested a review from crickman February 22, 2026 20:16
@crickman crickman marked this pull request as ready for review February 22, 2026 20:42
Copilot AI review requested due to automatic review settings February 22, 2026 20:42
@crickman crickman moved this to In Review in Agent Framework Feb 22, 2026
@crickman crickman added the samples Issue relates to the samples label Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables Cosmos DB tests to respect environment variables set by the CI workflow, which were previously ignored due to hardcoded connection settings. The changes align the test classes with the CI configuration while maintaining backward compatibility for local development.

Changes:

  • Converted hardcoded Cosmos DB connection constants to read from COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables with fallback to original default values
  • Renamed fields from EmulatorEndpoint/EmulatorKey to s_emulatorEndpoint/s_emulatorKey following the codebase's static field naming convention

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs Updated to read Cosmos DB connection settings from environment variables, renamed fields to follow s_ prefix convention, updated all 2 usages
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs Updated to read Cosmos DB connection settings from environment variables, renamed fields to follow s_ prefix convention, updated all 4 usages

@crickman crickman enabled auto-merge February 23, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET samples Issue relates to the samples

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants