Allow attaching a cosmos db account with tenantId.#2895
Merged
Conversation
sevoku
previously approved these changes
Jan 22, 2026
Member
sevoku
left a comment
There was a problem hiding this comment.
LGTM, tried with using a connection string with a specific tenant Id that is not my default and it works like a charm.
48698ec to
780a5fb
Compare
bk201-
previously approved these changes
Feb 2, 2026
f00f8c0 to
fa712c8
Compare
fa712c8 to
f761783
Compare
sevoku
reviewed
Mar 3, 2026
83d0009 to
4018945
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for attaching Cosmos DB accounts using Entra ID by accepting/storing a TenantId (in addition to AccountKey) across connection-string parsing, URI handling, and workspace persistence.
Changes:
- Extend Cosmos DB connection string parsing/model to extract and propagate
TenantId, and update masking accordingly. - Persist optional
tenantIdin attached account workspace storage and use it when building account credentials. - Add a new “select tenant” wizard step for connection strings that don’t include
AccountKeyorTenantId, plus parsing tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscodeUriHandler.ts | Accept tenantId via URI params / parsed connection string and persist it into workspace storage items. |
| src/tree/workspace-view/cosmosdb/CosmosDBWorkspaceItem.ts | Read tenantId from stored workspace item properties into the attached account model. |
| src/tree/workspace-view/cosmosdb/CosmosDBAttachedAccountModel.ts | Add optional tenantId to the attached account model type. |
| src/tree/cosmosdb/AccountInfo.ts | Flow tenantId into credential creation for connection-string and attached-account paths. |
| src/cosmosdb/cosmosDBConnectionStrings.ts | Parse TenantId from connection strings and store it on ParsedCosmosDBConnectionString. |
| src/cosmosdb/cosmosDBConnectionStrings.test.ts | Add tests for parsing connection strings with TenantId and with AccountEndpoint only. |
| src/commands/newConnection/newConnection.ts | Add the new tenant prompt step to the “New Connection” wizard flow. |
| src/commands/newConnection/NewConnectionWizardContext.ts | Add tenantId to wizard context for cross-step propagation. |
| src/commands/newConnection/CosmosDBTenantStep.ts | New step: prompt tenant selection when neither AccountKey nor TenantId is present. |
| src/commands/newConnection/CosmosDBExecuteStep.ts | Persist tenantId into storage item properties when available. |
| src/commands/newConnection/CosmosDBConnectionStringStep.ts | Extract tenantId from the entered connection string into wizard context. |
| l10n/bundle.l10n.json | Add localized strings for updated validation text and tenant selection UI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…TenantId When a user attaches a Cosmos DB account with a connection string that contains only AccountEndpoint (no AccountKey or TenantId), prompt them to select an Azure tenant via VSCodeAzureSubscriptionProvider for Entra ID authentication. - Add CosmosDBTenantStep using VSCodeAzureSubscriptionProvider.getTenants() - Auto-select tenant when only one is available - Add tenantId to NewConnectionWizardContext - Extract tenantId from connection string in CosmosDBConnectionStringStep - Use context.tenantId in CosmosDBExecuteStep (from prompt or connection string) - Relax validation: only AccountEndpoint is required
4018945 to
b613ee5
Compare
sevoku
approved these changes
Mar 5, 2026
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.
This pull request adds support for handling Azure Cosmos DB connection strings that use either an
AccountKeyor aTenantIdfor authentication, instead of requiring only anAccountKey. The changes update validation, parsing, and storage logic throughout the codebase to recognize and propagateTenantIdvalues, and they add tests to ensure correct parsing. Additionally, the URI handler and workspace model are updated to support the new field.Cosmos DB connection string handling:
AccountEndpointand eitherAccountKeyorTenantId, and clarified error messages and placeholders accordingly. [1] [2] [3]parseCosmosDBConnectionStringfunction andParsedCosmosDBConnectionStringclass to extract and store theTenantIdproperty if present. [1] [2] [3]TenantIdand with onlyAccountEndpoint. [1] [2]Workspace and storage model updates:
CosmosDBAttachedAccountModeland related logic to include an optionaltenantIdfield, and ensured the field is persisted and propagated where appropriate (e.g., in storage items and account info). [1] [2] [3] [4] [5]URI handler and parameter propagation:
tenantIdparameter from URIs, and to store it in attached account storage items if present. [1] [2] [3] [4] [5] [6] [7] [8] [9]Fixes #2620