Skip to content

Introduce "Service Discovery" for MongoDB (RU) resources#245

Merged
tnaum-ms merged 14 commits into
nextfrom
copilot/fix-244
Sep 8, 2025
Merged

Introduce "Service Discovery" for MongoDB (RU) resources#245
tnaum-ms merged 14 commits into
nextfrom
copilot/fix-244

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 5, 2025

This PR implements a new Service Discovery provider for Azure Cosmos DB MongoDB (RU) resources, creating a parallel discovery mechanism alongside the existing vCore provider.

Overview

The implementation adds support for discovering and connecting to Azure Cosmos DB MongoDB Request Unit (RU) provisioned accounts through the VS Code extension's Discovery View. This complements the existing vCore discovery while using RU-specific Azure APIs.

Key Features

  • Dedicated RU Discovery Provider: New "Azure Cosmos DB for MongoDB (RU)" option in Discovery View
  • Shared Infrastructure: Reuses existing subscription filtering and authentication flows
  • RU-Specific APIs: Uses CosmosDB Management Client with MongoDB kind filtering instead of resource type filtering
  • Automatic Authentication: Seamless credential extraction from Azure without user prompts
  • Consistent UX: Follows established wizard patterns (subscription selection → cluster selection → connection)

Implementation Details

Core Components Added

  • AzureMongoRUDiscoveryProvider - Main provider class extending the discovery interface
  • AzureMongoRUServiceRootItem - Root tree node with Azure sign-in handling
  • AzureMongoRUSubscriptionItem - Subscription-level resource discovery
  • MongoRUResourceItem - Individual RU cluster tree items with authentication
  • SelectRUClusterStep - RU cluster selection wizard step
  • AzureMongoRUExecuteStep - Connection establishment logic
  • ruClusterHelpers - RU-specific credential extraction utilities

API Integration

The key difference from vCore discovery is the Azure API usage:

vCore (existing):

// Uses Resource Management Client with resource type filtering
client.resources.list({ 
    filter: "resourceType eq 'Microsoft.DocumentDB/mongoClusters'" 
})

RU (new):

// Uses CosmosDB Management Client with kind filtering
const allAccounts = await managementClient.databaseAccounts.list();
const accounts = allAccounts.filter(account => account.kind === 'MongoDB');

Authentication Flow

RU clusters use connection string-based authentication extracted directly from Azure:

  1. Retrieve account information via databaseAccounts.get()
  2. List connection strings via databaseAccounts.listConnectionStrings()
  3. Extract primary connection string and parse credentials
  4. Cache credentials and establish connection via ClustersClient

Registration & Availability

The provider is registered in ClustersExtension.registerDiscoveryServices() without feature flags, making it immediately available alongside existing discovery options:

registerDiscoveryServices(_activateContext: IActionContext) {
    DiscoveryService.registerProvider(new AzureDiscoveryProvider());        // vCore
    DiscoveryService.registerProvider(new AzureMongoRUDiscoveryProvider()); // RU (new)
    DiscoveryService.registerProvider(new AzureVMDiscoveryProvider());      // VM
}

Quality Assurance

  • ✅ TypeScript strict mode compliance
  • ✅ ESLint validation with zero errors
  • ✅ Localization support for all user-facing strings
  • ✅ Consistent error handling and telemetry patterns
  • ✅ Clean build without compilation issues

The implementation provides a complete, production-ready discovery mechanism for RU resources that integrates seamlessly with the existing extension architecture.

Fixes #244.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: node /home/REDACTED/work/vscode-documentdb/vscode-documentdb/node_modules/.bin/vscode-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Copilot AI changed the title [WIP] Introduce "Service Discovery" for MongoDB (RU) resources Introduce "Service Discovery" for MongoDB (RU) resources Sep 5, 2025
Copilot AI requested a review from tnaum-ms September 5, 2025 07:05
@tnaum-ms tnaum-ms marked this pull request as ready for review September 5, 2025 12:33
Copilot AI review requested due to automatic review settings September 5, 2025 12:33
@tnaum-ms tnaum-ms requested a review from a team as a code owner September 5, 2025 12:33

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
sajeetharan
sajeetharan previously approved these changes Sep 5, 2025
Copy link
Copy Markdown
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 introduces Service Discovery for Azure Cosmos DB MongoDB Request Unit (RU) provisioned accounts, creating a new discovery provider alongside the existing vCore provider. The implementation provides a complete discovery mechanism that allows users to discover and connect to RU MongoDB resources through the VS Code extension's Discovery View.

  • Adds dedicated Azure Cosmos DB MongoDB (RU) discovery provider with RU-specific Azure APIs
  • Refactors shared Azure wizard components into reusable modules
  • Updates provider IDs and telemetry for better distinction between vCore and RU resources

Reviewed Changes

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

Show a summary per file
File Description
src/tree/discovery-view/DiscoveryBranchDataProvider.ts Adds auto-promotion logic for new RU provider and legacy provider renaming
src/plugins/service-azure-mongo-ru/ New RU discovery provider implementation with tree items, wizard steps, and utilities
src/plugins/service-azure-mongo-vcore/ Updates vCore provider to use refactored shared components and new provider ID
src/plugins/api-shared/azure/wizard/ Refactored shared Azure wizard components for reuse across providers
src/documentdb/ClustersExtension.ts Registers the new RU discovery provider
l10n/bundle.l10n.json Adds localized strings for RU-specific UI elements

@khelanmodi khelanmodi self-requested a review September 5, 2025 15:03
@tnaum-ms tnaum-ms merged commit 5db14ae into next Sep 8, 2025
8 checks passed
@tnaum-ms tnaum-ms deleted the copilot/fix-244 branch September 8, 2025 07:46
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.

Introduce "Service Discovery" for MongoDB (RU) resources

5 participants