Azure: add PostgresSQL support and refactor to use resource graph (#8046)

* Azure: add PostgresSQL support and refactor to use resource graph
- Refactored to use @azure/arm-resourcegraph for all queries
- Refactored database lookup to do just 2 queries
(all servers, all DBS) instead of waiting serially on 1 query per RG
- Added Azure Database for PostgresSQL Servers support in the tree
- Removed use of older azure APIs in preference to ones compatible with resource graph
- Note: Had to use v1.0 of new subscriptions package because resourcegraph is 2month out of date vs all other packages
This commit is contained in:
Kevin Cunnane
2019-10-28 09:47:38 -07:00
committed by GitHub
parent a7f597c943
commit 067af76904
21 changed files with 565 additions and 176 deletions

View File

@@ -6,11 +6,11 @@
import { window, QuickPickItem } from 'vscode';
import * as azdata from 'azdata';
import { TokenCredentials } from 'ms-rest';
import { AppContext } from '../appContext';
import { TokenCredentials } from '@azure/ms-rest-js';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { AppContext } from '../appContext';
import { azureResource } from './azure-resource';
import { TreeNode } from './treeNode';
import { AzureResourceCredentialError } from './errors';
@@ -46,7 +46,11 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
}
}
let selectedSubscriptions = (await subscriptionFilterService.getSelectedSubscriptions(accountNode.account)) || <azureResource.AzureResourceSubscription[]>[];
let selectedSubscriptions = await subscriptionFilterService.getSelectedSubscriptions(accountNode.account);
if (!selectedSubscriptions) {
selectedSubscriptions = [];
}
const selectedSubscriptionIds: string[] = [];
if (selectedSubscriptions.length > 0) {
selectedSubscriptionIds.push(...selectedSubscriptions.map((subscription) => subscription.id));
@@ -67,9 +71,9 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
};
}).sort((a, b) => a.label.localeCompare(b.label));
const selectedSubscriptionQuickPickItems = (await window.showQuickPick(subscriptionQuickPickItems, { canPickMany: true }));
const selectedSubscriptionQuickPickItems = await window.showQuickPick(subscriptionQuickPickItems, { canPickMany: true });
if (selectedSubscriptionQuickPickItems && selectedSubscriptionQuickPickItems.length > 0) {
tree.refresh(node, false);
await tree.refresh(node, false);
selectedSubscriptions = selectedSubscriptionQuickPickItems.map((subscriptionItem) => subscriptionItem.subscription);
await subscriptionFilterService.saveSelectedSubscriptions(accountNode.account, selectedSubscriptions);
@@ -79,7 +83,7 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
appContext.apiWrapper.registerCommand('azure.resource.refreshall', () => tree.notifyNodeChanged(undefined));
appContext.apiWrapper.registerCommand('azure.resource.refresh', async (node?: TreeNode) => {
tree.refresh(node, true);
await tree.refresh(node, true);
});
appContext.apiWrapper.registerCommand('azure.resource.signin', async (node?: TreeNode) => {