diff --git a/extensions/azurecore/resources/azureArcPostgresServer.svg b/extensions/azurecore/resources/azureArcPostgresServer.svg
new file mode 100644
index 0000000000..8c4cb91c17
--- /dev/null
+++ b/extensions/azurecore/resources/azureArcPostgresServer.svg
@@ -0,0 +1,21 @@
+
diff --git a/extensions/azurecore/resources/azureArcService.svg b/extensions/azurecore/resources/azureArcService.svg
new file mode 100644
index 0000000000..5e2274e46b
--- /dev/null
+++ b/extensions/azurecore/resources/azureArcService.svg
@@ -0,0 +1,23 @@
+
diff --git a/extensions/azurecore/resources/azureArcSqlManagedInstance.svg b/extensions/azurecore/resources/azureArcSqlManagedInstance.svg
new file mode 100644
index 0000000000..789ed2f565
--- /dev/null
+++ b/extensions/azurecore/resources/azureArcSqlManagedInstance.svg
@@ -0,0 +1,21 @@
+
diff --git a/extensions/azurecore/resources/postgresServer.svg b/extensions/azurecore/resources/postgresServer.svg
new file mode 100644
index 0000000000..e247e4e717
--- /dev/null
+++ b/extensions/azurecore/resources/postgresServer.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/extensions/azurecore/resources/sqlDatabase.svg b/extensions/azurecore/resources/sqlDatabase.svg
new file mode 100644
index 0000000000..9eeb03c9f4
--- /dev/null
+++ b/extensions/azurecore/resources/sqlDatabase.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/extensions/azurecore/resources/sqlManagedInstance.svg b/extensions/azurecore/resources/sqlManagedInstance.svg
new file mode 100644
index 0000000000..cbd2f2df84
--- /dev/null
+++ b/extensions/azurecore/resources/sqlManagedInstance.svg
@@ -0,0 +1,24 @@
+
diff --git a/extensions/azurecore/resources/sqlServer.svg b/extensions/azurecore/resources/sqlServer.svg
new file mode 100644
index 0000000000..64420a8c9d
--- /dev/null
+++ b/extensions/azurecore/resources/sqlServer.svg
@@ -0,0 +1,20 @@
+
diff --git a/extensions/azurecore/src/constants.ts b/extensions/azurecore/src/constants.ts
index 029ae4e2ee..cfc9a2080e 100644
--- a/extensions/azurecore/src/constants.ts
+++ b/extensions/azurecore/src/constants.ts
@@ -6,6 +6,8 @@
export const extensionConfigSectionName = 'azure';
export const ViewType = 'view';
+export const dataGridProviderId = 'azure-resources';
+
export enum BuiltInCommands {
SetContext = 'setContext'
}
diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts
index 406985ea01..a5a080d106 100644
--- a/extensions/azurecore/src/extension.ts
+++ b/extensions/azurecore/src/extension.ts
@@ -43,6 +43,7 @@ import * as loc from './localizedConstants';
import * as constants from './constants';
import { AzureResourceGroupService } from './azureResource/providers/resourceGroup/resourceGroupService';
import { Logger } from './utils/Logger';
+import { TokenCredentials } from '@azure/ms-rest-js';
let extensionContext: vscode.ExtensionContext;
@@ -88,6 +89,63 @@ export async function activate(context: vscode.ExtensionContext): Promise onDidChangeConfiguration(e), this));
registerAzureResourceCommands(appContext, azureResourceTree);
+ const typesClause = [
+ azureResource.AzureResourceType.sqlDatabase,
+ azureResource.AzureResourceType.sqlServer,
+ azureResource.AzureResourceType.sqlManagedInstance,
+ azureResource.AzureResourceType.postgresServer,
+ azureResource.AzureResourceType.azureArcService,
+ azureResource.AzureResourceType.azureArcSqlManagedInstance,
+ azureResource.AzureResourceType.azureArcPostgresServer
+ ].map(type => `type == "${type}"`).join(' or ');
+ azdata.dataprotocol.registerDataGridProvider({
+ providerId: constants.dataGridProviderId,
+ getDataGridItems: async () => {
+ const accounts = await azdata.accounts.getAllAccounts();
+ const items: any[] = [];
+ await Promise.all(accounts.map(async (account) => {
+ await Promise.all(account.properties.tenants.map(async (tenant: { id: string; }) => {
+ try {
+ const tokenResponse = await azdata.accounts.getAccountSecurityToken(account, tenant.id, azdata.AzureResource.ResourceManagement);
+ const token = tokenResponse.token;
+ const tokenType = tokenResponse.tokenType;
+ const credential = new TokenCredentials(token, tokenType);
+ const subscriptionService = appContext.getService(AzureResourceServiceNames.subscriptionService);
+ const subscriptions = await subscriptionService.getSubscriptions(account, credential, tenant.id);
+ try {
+ const newItems = (await azureResourceUtils.runResourceQuery(account, subscriptions, true, `where ${typesClause}`)).resources
+ .map(item => {
+ return {
+ ...item,
+ subscriptionName: subscriptions.find(subscription => subscription.id === item.subscriptionId)?.name ?? item.subscriptionId,
+ locationDisplayName: utils.getRegionDisplayName(item.location),
+ typeDisplayName: utils.getResourceTypeDisplayName(item.type),
+ iconPath: utils.getResourceTypeIcon(appContext, item.type)
+ };
+ });
+ items.push(...newItems);
+ } catch (err) {
+ console.log(err);
+ }
+ } catch (err) {
+ console.log(err);
+ }
+ }));
+ }));
+ return items;
+ },
+ getDataGridColumns: async () => {
+ return [
+ { id: 'icon', type: 'image', field: 'iconPath', name: '', width: 25, sortable: false, filterable: false, resizable: false, tooltip: loc.typeIcon },
+ { id: 'name', type: 'text', field: 'name', name: loc.name, width: 150 },
+ { id: 'type', type: 'text', field: 'typeDisplayName', name: loc.resourceType, width: 150 },
+ { id: 'type', type: 'text', field: 'resourceGroup', name: loc.resourceGroup, width: 150 },
+ { id: 'location', type: 'text', field: 'locationDisplayName', name: loc.location, width: 150 },
+ { id: 'subscriptionId', type: 'text', field: 'subscriptionName', name: loc.subscription, width: 150 }
+ ];
+ }
+ });
+
return {
getSubscriptions(account?: azdata.Account, ignoreErrors?: boolean): Thenable { return azureResourceUtils.getSubscriptions(appContext, account, ignoreErrors); },
getResourceGroups(account?: azdata.Account, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Thenable { return azureResourceUtils.getResourceGroups(appContext, account, subscription, ignoreErrors); },
diff --git a/extensions/azurecore/src/localizedConstants.ts b/extensions/azurecore/src/localizedConstants.ts
index 056d27b274..0ce436c632 100644
--- a/extensions/azurecore/src/localizedConstants.ts
+++ b/extensions/azurecore/src/localizedConstants.ts
@@ -57,6 +57,7 @@ export const resourceType = localize('azurecore.resourceType', "Resource type");
export const resourceGroup = localize('azurecore.resourceGroup', "Resource group");
export const location = localize('azurecore.location', "Location");
export const subscription = localize('azurecore.subscription', "Subscription");
+export const typeIcon = localize('azurecore.typeIcon', "Type Icon");
// Azure Resource Types
export const sqlServer = localize('azurecore.sqlServer', "SQL server");
diff --git a/extensions/azurecore/src/utils.ts b/extensions/azurecore/src/utils.ts
index 2fe319faa0..abfe76aa4d 100644
--- a/extensions/azurecore/src/utils.ts
+++ b/extensions/azurecore/src/utils.ts
@@ -6,6 +6,7 @@
import { azureResource } from 'azureResource';
import * as loc from './localizedConstants';
import { AzureRegion } from 'azurecore';
+import { AppContext } from './appContext';
/**
* Converts a region value (@see AzureRegion) into the localized Display Name
@@ -108,6 +109,8 @@ export function getResourceTypeDisplayName(type: string): string {
return loc.sqlDatabase;
case azureResource.AzureResourceType.sqlManagedInstance:
return loc.sqlManagedInstance;
+ case azureResource.AzureResourceType.postgresServer:
+ return loc.postgresServer;
case azureResource.AzureResourceType.azureArcSqlManagedInstance:
return loc.azureArcsqlManagedInstance;
case azureResource.AzureResourceType.azureArcService:
@@ -117,3 +120,23 @@ export function getResourceTypeDisplayName(type: string): string {
}
return type;
}
+
+export function getResourceTypeIcon(appContext: AppContext, type: string): string {
+ switch (type) {
+ case azureResource.AzureResourceType.sqlServer:
+ return appContext.extensionContext.asAbsolutePath('resources/sqlServer.svg');
+ case azureResource.AzureResourceType.sqlDatabase:
+ return appContext.extensionContext.asAbsolutePath('resources/sqlDatabase.svg');
+ case azureResource.AzureResourceType.sqlManagedInstance:
+ return appContext.extensionContext.asAbsolutePath('resources/sqlManagedInstance.svg');
+ case azureResource.AzureResourceType.postgresServer:
+ return appContext.extensionContext.asAbsolutePath('resources/postgresServer.svg');
+ case azureResource.AzureResourceType.azureArcSqlManagedInstance:
+ return appContext.extensionContext.asAbsolutePath('resources/azureArcSqlManagedInstance.svg');
+ case azureResource.AzureResourceType.azureArcService:
+ return appContext.extensionContext.asAbsolutePath('resources/azureArcService.svg');
+ case azureResource.AzureResourceType.azureArcPostgresServer:
+ return appContext.extensionContext.asAbsolutePath('resources/azureArcPostgresServer.svg');
+ }
+ return '';
+}