From 70b73aaf8484fff9dbb4dab5d38208d3b7cf31d6 Mon Sep 17 00:00:00 2001 From: Konstantin Lepeshenkov Date: Tue, 30 Mar 2021 14:54:32 +0200 Subject: [PATCH] warning for V2 accounts --- .../src/MonitorTreeDataProvider.ts | 1 + .../src/SubscriptionTreeItems.ts | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/durablefunctionsmonitor-vscodeext/src/MonitorTreeDataProvider.ts b/durablefunctionsmonitor-vscodeext/src/MonitorTreeDataProvider.ts index 2480ecf..f3f3dbc 100644 --- a/durablefunctionsmonitor-vscodeext/src/MonitorTreeDataProvider.ts +++ b/durablefunctionsmonitor-vscodeext/src/MonitorTreeDataProvider.ts @@ -44,6 +44,7 @@ export class MonitorTreeDataProvider implements vscode.TreeDataProvider this._onDidChangeTreeData.fire(), diff --git a/durablefunctionsmonitor-vscodeext/src/SubscriptionTreeItems.ts b/durablefunctionsmonitor-vscodeext/src/SubscriptionTreeItems.ts index 7f34c4c..75f4d52 100644 --- a/durablefunctionsmonitor-vscodeext/src/SubscriptionTreeItems.ts +++ b/durablefunctionsmonitor-vscodeext/src/SubscriptionTreeItems.ts @@ -1,3 +1,4 @@ +import * as vscode from 'vscode'; import { StorageManagementClient } from "@azure/arm-storage"; import { StorageAccount } from "@azure/arm-storage/src/models"; @@ -15,7 +16,8 @@ type AzureSubscription = { session: { credentials2: any }, subscription: { subsc // Represents the list of Azure Subscriptions in the TreeView export class SubscriptionTreeItems { - constructor(private _azureAccount: any, + constructor(private _context: vscode.ExtensionContext, + private _azureAccount: any, private _storageAccounts: StorageAccountTreeItems, private _onStorageAccountsChanged: () => void, private _resourcesFolderPath: string, @@ -73,8 +75,29 @@ export class SubscriptionTreeItems { return result; } + private static HasAlreadyShownStorageV2Warning = false; + + private showWarning4V2StorageAccounts(v2AccountNames: string[]): void { + + const DfmDoNotShowStorageV2Warning = 'DfmDoNotShowStorageV2Warning'; + + if (!!SubscriptionTreeItems.HasAlreadyShownStorageV2Warning || !!this._context.globalState.get(DfmDoNotShowStorageV2Warning, false) || !v2AccountNames.length) { + return; + } + SubscriptionTreeItems.HasAlreadyShownStorageV2Warning = true; + + const prompt = `Looks like your Durable Functions are using the following General-purpose V2 Storage accounts: ${v2AccountNames.join(', ')}. Combined with Durable Functions, V2 Storage accounts can be more expensive under high loads. Consider using General-purpose V1 Storage instead.`; + vscode.window.showWarningMessage(prompt, 'OK', `Don't Show Again`).then(answer => { + + if (answer === `Don't Show Again`) { + this._context.globalState.update(DfmDoNotShowStorageV2Warning, true); + } + }); + } + private async tryLoadingTaskHubsForSubscription(storageManagementClient: StorageManagementClient, storageAccounts: StorageAccount[]): Promise { + const v2AccountNames: string[] = []; var taskHubsAdded = false; await Promise.all(storageAccounts.map(async storageAccount => { @@ -105,10 +128,14 @@ export class SubscriptionTreeItems { } const hubNames = await getTaskHubNamesFromTableStorage(storageAccount.name!, storageKey.value!, tableEndpoint); - if (!hubNames) { + if (!hubNames || !hubNames.length) { return; } + if (storageAccount.kind === 'StorageV2') { + v2AccountNames.push(storageAccount.name!); + } + for (const hubName of hubNames) { this._storageAccounts.addNodeForConnectionSettings( @@ -120,6 +147,9 @@ export class SubscriptionTreeItems { } })); + // Notifying about potentially higher costs of V2 accounts + this.showWarning4V2StorageAccounts(v2AccountNames); + return taskHubsAdded; }