diff --git a/extensions/azurecore/resources/dark/cosmosdb_inverse.svg b/extensions/azurecore/resources/dark/cosmosdb_inverse.svg
new file mode 100644
index 0000000000..adf007cc74
--- /dev/null
+++ b/extensions/azurecore/resources/dark/cosmosdb_inverse.svg
@@ -0,0 +1,19 @@
+
diff --git a/extensions/azurecore/resources/light/cosmosdb.svg b/extensions/azurecore/resources/light/cosmosdb.svg
new file mode 100644
index 0000000000..e952b3bce8
--- /dev/null
+++ b/extensions/azurecore/resources/light/cosmosdb.svg
@@ -0,0 +1,19 @@
+
diff --git a/extensions/azurecore/src/azureResource/constants.ts b/extensions/azurecore/src/azureResource/constants.ts
index 660918fc3c..96c151029e 100644
--- a/extensions/azurecore/src/azureResource/constants.ts
+++ b/extensions/azurecore/src/azureResource/constants.ts
@@ -16,6 +16,7 @@ export enum AzureResourceItemType {
message = 'azure.resource.itemType.message',
azureMonitor = 'azure.resource.itemType.azureMonitor',
azureMonitorContainer = 'azure.resource.itemType.azureMonitorContainer',
+ cosmosDBMongoAccount = 'azure.resource.itemType.cosmosDBMongoAccount'
}
export enum AzureResourceServiceNames {
diff --git a/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider.ts b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider.ts
new file mode 100644
index 0000000000..3755827250
--- /dev/null
+++ b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider.ts
@@ -0,0 +1,26 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the Source EULA. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { ExtensionContext } from 'vscode';
+
+import { azureResource } from 'azurecore';
+import { IAzureResourceService } from '../../../interfaces';
+import { CosmosDbMongoTreeDataProvider } from './cosmosDbMongoTreeDataProvider';
+
+export class CosmosDbMongoProvider implements azureResource.IAzureResourceProvider {
+ public constructor(
+ private _databaseServerService: IAzureResourceService,
+ private _extensionContext: ExtensionContext
+ ) {
+ }
+
+ public getTreeDataProvider(): azureResource.IAzureResourceTreeDataProvider {
+ return new CosmosDbMongoTreeDataProvider(this._databaseServerService, this._extensionContext);
+ }
+
+ public get providerId(): string {
+ return 'azure.resource.providers.cosmosDbMongo';
+ }
+}
diff --git a/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoService.ts b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoService.ts
new file mode 100644
index 0000000000..ad61a439e4
--- /dev/null
+++ b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoService.ts
@@ -0,0 +1,40 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the Source EULA. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+
+import { ResourceServiceBase, GraphData } from '../../resourceTreeDataProviderBase';
+import { azureResource } from 'azurecore';
+
+
+interface DbServerGraphData extends GraphData {
+ properties: {
+ fullyQualifiedDomainName: string;
+ administratorLogin: string;
+ };
+}
+
+const serversQuery = `where type == "${azureResource.AzureResourceType.cosmosDbAccount}" and kind == "MongoDB"`;
+
+export class CosmosDbMongoService extends ResourceServiceBase {
+
+ protected get query(): string {
+ return serversQuery;
+ }
+
+ protected convertResource(resource: DbServerGraphData): azureResource.AzureResourceDatabaseServer {
+ return {
+ id: resource.id,
+ name: resource.name,
+ fullName: resource.properties.fullyQualifiedDomainName,
+ loginName: resource.properties.administratorLogin,
+ defaultDatabaseName: '',
+ tenant: resource.tenantId,
+ subscription: {
+ id: resource.subscriptionId,
+ name: resource.subscriptionName
+ }
+ };
+ }
+}
diff --git a/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoTreeDataProvider.ts
new file mode 100644
index 0000000000..754fb03687
--- /dev/null
+++ b/extensions/azurecore/src/azureResource/providers/cosmosdb/mongo/cosmosDbMongoTreeDataProvider.ts
@@ -0,0 +1,79 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the Source EULA. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
+import * as nls from 'vscode-nls';
+const localize = nls.loadMessageBundle();
+
+import { AzureResourceItemType } from '../../../constants';
+import { generateGuid } from '../../../utils';
+import { IAzureResourceService } from '../../../interfaces';
+import { ResourceTreeDataProviderBase } from '../../resourceTreeDataProviderBase';
+import { azureResource } from 'azurecore';
+import * as azdata from 'azdata';
+
+export class CosmosDbMongoTreeDataProvider extends ResourceTreeDataProviderBase {
+ private static readonly COSMOSDG_MONGO_PROVIDER_ID = 'COSMOSDB_MONGO';
+ private static readonly CONTAINER_ID = 'azure.resource.providers.databaseServer.treeDataProvider.cosmosDbMongoContainer';
+ private static readonly CONTAINER_LABEL = localize('azure.resource.providers.databaseServer.treeDataProvider.cosmosDbMongoContainerLabel', "CosmosDB for Mongo");
+
+ public constructor(
+ databaseServerService: IAzureResourceService,
+ private _extensionContext: ExtensionContext
+ ) {
+ super(databaseServerService);
+ }
+
+ protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: azdata.Account): azdata.TreeItem {
+ return {
+ id: `Cosmosdb_${databaseServer.id ? databaseServer.id : databaseServer.name}`,
+ label: `${databaseServer.name} (CosmosDB Mongo API)`,
+ iconPath: {
+ dark: this._extensionContext.asAbsolutePath('resources/dark/cosmosdb_inverse.svg'),
+ light: this._extensionContext.asAbsolutePath('resources/light/cosmosdb.svg')
+ },
+ collapsibleState: TreeItemCollapsibleState.None,
+ contextValue: AzureResourceItemType.cosmosDBMongoAccount,
+ payload: {
+ id: generateGuid(),
+ connectionName: databaseServer.name,
+ serverName: databaseServer.name,
+ userName: databaseServer.loginName,
+ password: '',
+ authenticationType: 'AzureMFA',
+ savePassword: true,
+ groupFullName: '',
+ groupId: '',
+ providerName: CosmosDbMongoTreeDataProvider.COSMOSDG_MONGO_PROVIDER_ID,
+ saveProfile: false,
+ options: {},
+ azureAccount: account.key.accountId,
+ azureTenantId: databaseServer.tenant,
+ azureResourceId: databaseServer.id,
+ azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
+ },
+ childProvider: CosmosDbMongoTreeDataProvider.COSMOSDG_MONGO_PROVIDER_ID,
+ type: azdata.ExtensionNodeType.Server
+ };
+ }
+
+ protected createContainerNode(): azureResource.IAzureResourceNode {
+ return {
+ account: undefined,
+ subscription: undefined,
+ tenantId: undefined,
+ treeItem: {
+ id: CosmosDbMongoTreeDataProvider.CONTAINER_ID,
+ label: CosmosDbMongoTreeDataProvider.CONTAINER_LABEL,
+ iconPath: {
+ dark: this._extensionContext.asAbsolutePath('resources/dark/folder_inverse.svg'),
+ light: this._extensionContext.asAbsolutePath('resources/light/folder.svg')
+ },
+ collapsibleState: TreeItemCollapsibleState.Collapsed,
+ contextValue: AzureResourceItemType.databaseServerContainer
+ }
+ };
+ }
+}
diff --git a/extensions/azurecore/src/azurecore.d.ts b/extensions/azurecore/src/azurecore.d.ts
index 97de711686..223d841f7d 100644
--- a/extensions/azurecore/src/azurecore.d.ts
+++ b/extensions/azurecore/src/azurecore.d.ts
@@ -345,7 +345,8 @@ declare module 'azurecore' {
postgresServer = 'microsoft.dbforpostgresql/servers',
azureArcService = 'microsoft.azuredata/datacontrollers',
storageAccount = 'microsoft.storage/storageaccounts',
- logAnalytics = 'microsoft.operationalinsights/workspaces'
+ logAnalytics = 'microsoft.operationalinsights/workspaces',
+ cosmosDbAccount = 'microsoft.documentdb/databaseaccounts'
}
export interface IAzureResourceProvider extends azdata.DataProvider {
diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts
index 483bac4a1c..e43821612a 100644
--- a/extensions/azurecore/src/extension.ts
+++ b/extensions/azurecore/src/extension.ts
@@ -37,6 +37,8 @@ import { SqlInstanceArcProvider } from './azureResource/providers/sqlinstanceArc
import { SqlInstanceArcResourceService } from './azureResource/providers/sqlinstanceArc/sqlInstanceArcService';
import { PostgresServerArcProvider } from './azureResource/providers/postgresArcServer/postgresServerProvider';
import { PostgresServerArcService } from './azureResource/providers/postgresArcServer/postgresServerService';
+import { CosmosDbMongoProvider } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider';
+import { CosmosDbMongoService } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoService';
import * as azurecore from 'azurecore';
import * as azureResourceUtils from './azureResource/utils';
import * as utils from './utils';
@@ -134,6 +136,7 @@ export async function activate(context: vscode.ExtensionContext): Promise([
['PGSQL', 'microsoft.azuredatastudio-postgresql'],
['KUSTO', 'microsoft.kusto'],
- ['LOGANALYTICS', 'microsoft.azuremonitor']
+ ['LOGANALYTICS', 'microsoft.azuremonitor'],
+ ['COSMOSDB_MONGO', 'microsoft.azure-cosmosdb-ads-extension']
]);
/**