Skip to content

Commit 9a99d06

Browse files
authored
Decoupling from Azure Account extension (#212)
* #178 * version 6.5.1 * review fixes
1 parent 55e7874 commit 9a99d06

10 files changed

+430
-404
lines changed

durablefunctionsmonitor-vscodeext/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
# Version 6.5.1
4+
5+
- Decoupled from (soon deprecated) [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account). NOTE: you might need to re-authenticate to Azure.
6+
37
# Version 6.5
48

59
- New feature - `Execute Batch Operations...` (https://github.com/microsoft/DurableFunctionsMonitor/issues/169). Prepare a list of instances in the main screen, and then use this context menu to execute operations against all of them:

durablefunctionsmonitor-vscodeext/package-lock.json

+300-211
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

durablefunctionsmonitor-vscodeext/package.json

+28-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "durablefunctionsmonitor",
33
"displayName": "Durable Functions Monitor",
44
"description": "Monitoring/debugging UI tool for Azure Durable Functions",
5-
"version": "6.5.0",
5+
"version": "6.5.1",
66
"engines": {
77
"vscode": "^1.39.0"
88
},
@@ -30,13 +30,13 @@
3030
"license": "MIT",
3131
"activationEvents": [
3232
"onView:durableFunctionsMonitorTreeView",
33-
"onCommand:extension.durableFunctionsMonitor",
34-
"onCommand:extension.durableFunctionsMonitorPurgeHistory",
35-
"onCommand:extension.durableFunctionsMonitorCleanEntityStorage",
36-
"onCommand:extension.durableFunctionsMonitorBatchOps",
33+
"onCommand:durable-functions-monitor.durableFunctionsMonitor",
34+
"onCommand:durable-functions-monitor.durableFunctionsMonitorPurgeHistory",
35+
"onCommand:durable-functions-monitor.durableFunctionsMonitorCleanEntityStorage",
36+
"onCommand:durable-functions-monitor.durableFunctionsMonitorBatchOps",
3737
"onCommand:durableFunctionsMonitorTreeView.attachToAnotherTaskHub",
38-
"onCommand:extension.durableFunctionsMonitorGotoInstanceId",
39-
"onCommand:extension.durableFunctionsMonitorVisualizeAsGraph",
38+
"onCommand:durable-functions-monitor.durableFunctionsMonitorGotoInstanceId",
39+
"onCommand:durable-functions-monitor.durableFunctionsMonitorVisualizeAsGraph",
4040
"onCommand:durableFunctionsMonitorTreeView.startNewInstance",
4141
"onDebug"
4242
],
@@ -52,27 +52,31 @@
5252
},
5353
"commands": [
5454
{
55-
"command": "extension.durableFunctionsMonitor",
55+
"command": "durable-functions-monitor.signInToAzure",
56+
"title": "Sign in to Azure..."
57+
},
58+
{
59+
"command": "durable-functions-monitor.durableFunctionsMonitor",
5660
"title": "Durable Functions Monitor"
5761
},
5862
{
59-
"command": "extension.durableFunctionsMonitorPurgeHistory",
63+
"command": "durable-functions-monitor.durableFunctionsMonitorPurgeHistory",
6064
"title": "Durable Functions Monitor: Purge History..."
6165
},
6266
{
63-
"command": "extension.durableFunctionsMonitorCleanEntityStorage",
67+
"command": "durable-functions-monitor.durableFunctionsMonitorCleanEntityStorage",
6468
"title": "Durable Functions Monitor: Clean Entity Storage..."
6569
},
6670
{
67-
"command": "extension.durableFunctionsMonitorBatchOps",
71+
"command": "durable-functions-monitor.durableFunctionsMonitorBatchOps",
6872
"title": "Durable Functions Monitor: Execute Batch Operations..."
6973
},
7074
{
71-
"command": "extension.durableFunctionsMonitorGotoInstanceId",
75+
"command": "durable-functions-monitor.durableFunctionsMonitorGotoInstanceId",
7276
"title": "Durable Functions Monitor: Go to instanceId..."
7377
},
7478
{
75-
"command": "extension.durableFunctionsMonitorVisualizeAsGraph",
79+
"command": "durable-functions-monitor.durableFunctionsMonitorVisualizeAsGraph",
7680
"title": "Visualize Functions as a Graph..."
7781
},
7882
{
@@ -147,32 +151,32 @@
147151
"menus": {
148152
"explorer/context": [
149153
{
150-
"command": "extension.durableFunctionsMonitor",
154+
"command": "durable-functions-monitor.durableFunctionsMonitor",
151155
"when": "resourceFilename == host.json",
152156
"group": "DurableFunctionMonitorGroup@1"
153157
},
154158
{
155-
"command": "extension.durableFunctionsMonitorPurgeHistory",
159+
"command": "durable-functions-monitor.durableFunctionsMonitorPurgeHistory",
156160
"when": "resourceFilename == host.json",
157161
"group": "DurableFunctionMonitorGroup@2"
158162
},
159163
{
160-
"command": "extension.durableFunctionsMonitorCleanEntityStorage",
164+
"command": "durable-functions-monitor.durableFunctionsMonitorCleanEntityStorage",
161165
"when": "resourceFilename == host.json",
162166
"group": "DurableFunctionMonitorGroup@3"
163167
},
164168
{
165-
"command": "extension.durableFunctionsMonitorBatchOps",
169+
"command": "durable-functions-monitor.durableFunctionsMonitorBatchOps",
166170
"when": "resourceFilename == host.json",
167171
"group": "DurableFunctionMonitorGroup@4"
168172
},
169173
{
170-
"command": "extension.durableFunctionsMonitorGotoInstanceId",
174+
"command": "durable-functions-monitor.durableFunctionsMonitorGotoInstanceId",
171175
"when": "resourceFilename == host.json",
172176
"group": "DurableFunctionMonitorGroup@5"
173177
},
174178
{
175-
"command": "extension.durableFunctionsMonitorVisualizeAsGraph",
179+
"command": "durable-functions-monitor.durableFunctionsMonitorVisualizeAsGraph",
176180
"when": "resourceFilename == host.json",
177181
"group": "DurableFunctionMonitorGroup@6"
178182
}
@@ -341,16 +345,18 @@
341345
"@types/node": "^14.6.4",
342346
"@types/vscode": "^1.39.0",
343347
"@vscode/test-electron": "^2.3.5",
348+
"@vscode/vsce": "^2.26.1",
344349
"glob": "^7.1.4",
345350
"mocha": "^10.0.0",
346351
"tslint": "^5.12.1",
347-
"typescript": "^4.4.4",
348-
"@vscode/vsce": "^2.26.1"
352+
"typescript": "^4.4.4"
349353
},
350354
"dependencies": {
351355
"@azure/arm-resourcegraph": "^4.2.1",
352356
"@azure/arm-storage": "^18.1.0",
357+
"@azure/identity": "^4.4.1",
353358
"@azure/ms-rest-nodeauth": "^3.1.0",
359+
"@microsoft/vscode-azext-azureauth": "^2.5.0",
354360
"@types/crypto-js": "^3.1.47",
355361
"@types/rimraf": "^3.0.0",
356362
"axios": "1.6.2",
@@ -360,7 +366,5 @@
360366
"portscanner": "^2.2.0",
361367
"rimraf": "^3.0.2"
362368
},
363-
"extensionDependencies": [
364-
"ms-vscode.azure-account"
365-
]
369+
"extensionDependencies": []
366370
}

durablefunctionsmonitor-vscodeext/src/ConnStringUtils.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { StorageAccount } from '@azure/arm-storage';
55
import { Settings } from './Settings';
66
import { ResourceGraphClient } from '@azure/arm-resourcegraph';
7-
import { DeviceTokenCredentials } from '@azure/ms-rest-nodeauth';
7+
import { TokenCredential } from '@azure/identity';
88

99
export class ConnStringUtils {
1010

@@ -105,7 +105,7 @@ export class ConnStringUtils {
105105
}
106106

107107
// Queries Azure Resource Manager API for the list of resources of a given type
108-
static async getAzureResources(creds: DeviceTokenCredentials, subscriptionId: string, resourceType: string, resourceName?: string): Promise<any[]>{
108+
static async getAzureResources(creds: TokenCredential, subscriptionId: string, resourceType: string, resourceName?: string): Promise<any[]>{
109109

110110
const resourceGraphClient = new ResourceGraphClient(creds);
111111
const response = await resourceGraphClient.resources({
@@ -115,14 +115,4 @@ export class ConnStringUtils {
115115

116116
return response.data ?? [];
117117
}
118-
119-
// Polyfills ADAL's and MSAL's getToken()
120-
static async getAccessTokenForAzureResourceManager(creds: any): Promise<string>{
121-
122-
const tokenWrapper = await creds.getToken();
123-
// Depending on whether ADAL or MSAL is used, the field is called either 'accessToken' or 'token'
124-
const accessToken = tokenWrapper.accessToken ?? tokenWrapper.token;
125-
126-
return accessToken;
127-
}
128118
}

durablefunctionsmonitor-vscodeext/src/EventHubPicker.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
import * as vscode from 'vscode';
55
import axios from 'axios';
6-
import { ConnStringUtils } from './ConnStringUtils';
6+
import { AzureSubscription } from '@microsoft/vscode-azext-azureauth';
77

8-
// Full typings for this can be found here: https://github.com/microsoft/vscode-azure-account/blob/master/src/azure-account.api.d.ts
9-
export type AzureSubscription = { session: { credentials2: any }, subscription: { subscriptionId: string, displayName: string } };
8+
import { ConnStringUtils } from './ConnStringUtils';
109

1110
export class EventHubPicker {
1211

@@ -15,9 +14,8 @@ export class EventHubPicker {
1514
// Asks user to choose an Event Hub connection string
1615
async pickEventHubConnectionString(subscription: AzureSubscription): Promise<string | undefined> {
1716

18-
// Depending on whether ADAL or MSAL is used, this will contain either DeviceTokenCredentials or TokenCredential
19-
const creds: any = subscription.session.credentials2;
20-
const subscriptionId = subscription.subscription.subscriptionId;
17+
const creds = subscription.credential;
18+
const subscriptionId = subscription.subscriptionId;
2119

2220
const namespaces = await ConnStringUtils.getAzureResources(
2321
creds,
@@ -46,7 +44,7 @@ export class EventHubPicker {
4644
return;
4745
}
4846

49-
const accessToken = await ConnStringUtils.getAccessTokenForAzureResourceManager(creds);
47+
const accessToken = (await creds.getToken(['https://management.core.windows.net/user_impersonation']))!.token;
5048

5149
let authRule: string | undefined = '';
5250

0 commit comments

Comments
 (0)