Skip to content

Commit 6f89fce

Browse files
authored
Add DTS deploy activity log integration (#4574)
1 parent c942bf7 commit 6f89fce

12 files changed

+218
-25
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@
14841484
"@microsoft/vscode-azext-azureappservice": "^3.6.4",
14851485
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
14861486
"@microsoft/vscode-azext-azureutils": "^3.4.0",
1487-
"@microsoft/vscode-azext-utils": "^3.1.1",
1487+
"@microsoft/vscode-azext-utils": "^3.2.0",
14881488
"@microsoft/vscode-azureresources-api": "^2.0.4",
14891489
"@microsoft/vscode-container-client": "^0.1.2",
14901490
"cross-fetch": "^4.0.0",

src/commands/appSettings/connectionSettings/durableTaskScheduler/DTSConnectionSetSettingStep.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { nonNullProp } from '@microsoft/vscode-azext-utils';
6+
import { ActivityChildItem, ActivityChildType, activityFailContext, activityFailIcon, activityProgressContext, activityProgressIcon, activitySuccessContext, activitySuccessIcon, createContextValue, nonNullProp, type ExecuteActivityOutput } from '@microsoft/vscode-azext-utils';
77
import { ConnectionKey } from '../../../../constants';
8+
import { localize } from '../../../../localize';
89
import { clientIdKey } from '../../../durableTaskScheduler/copySchedulerConnectionString';
910
import { SetConnectionSettingStepBase } from '../SetConnectionSettingStepBase';
1011
import { type IDTSAzureConnectionWizardContext, type IDTSConnectionWizardContext } from './IDTSConnectionWizardContext';
1112

1213
export class DTSConnectionSetSettingStep<T extends IDTSConnectionWizardContext | IDTSAzureConnectionWizardContext> extends SetConnectionSettingStepBase<T> {
1314
public priority: number = 240;
15+
public stepName: string = 'dtsConnectionSetSettingStep';
1416
public debugDeploySetting: ConnectionKey = ConnectionKey.DTS;
1517

1618
public async execute(context: T): Promise<void> {
@@ -24,4 +26,39 @@ export class DTSConnectionSetSettingStep<T extends IDTSConnectionWizardContext |
2426
public shouldExecute(context: T): boolean {
2527
return !!context.newDTSConnectionSetting;
2628
}
29+
30+
public createSuccessOutput(context: T): ExecuteActivityOutput {
31+
return {
32+
item: new ActivityChildItem({
33+
label: localize('prepareDTSConnectionProgressLabel', 'Prepare DTS connection: "{0}"', 'Endpoint=...'),
34+
contextValue: createContextValue([`${this.stepName}Item`, activitySuccessContext]),
35+
activityType: ActivityChildType.Success,
36+
iconPath: activitySuccessIcon,
37+
}),
38+
message: localize('prepareDTSConnectionSuccess', 'Successfully prepared DTS connection: "{0}".', context.newDTSConnectionSetting),
39+
};
40+
}
41+
42+
public createProgressOutput(): ExecuteActivityOutput {
43+
return {
44+
item: new ActivityChildItem({
45+
label: localize('prepareDTSConnectionProgressLabel', 'Prepare DTS connection: "{0}"', 'Endpoint=...'),
46+
contextValue: createContextValue([`${this.stepName}Item`, activityProgressContext]),
47+
activityType: ActivityChildType.Progress,
48+
iconPath: activityProgressIcon,
49+
}),
50+
};
51+
}
52+
53+
public createFailOutput(context: T): ExecuteActivityOutput {
54+
return {
55+
item: new ActivityChildItem({
56+
label: localize('prepareDTSConnectionProgressLabel', 'Prepare DTS connection: "{0}"', 'Endpoint=...'),
57+
contextValue: createContextValue([`${this.stepName}Item`, activityFailContext]),
58+
activityType: ActivityChildType.Fail,
59+
iconPath: activityFailIcon,
60+
}),
61+
message: localize('prepareDTSConnectionFail', 'Failed to prepare DTS connection: "{0}".', context.newDTSConnectionSetting),
62+
};
63+
}
2764
}

src/commands/appSettings/connectionSettings/durableTaskScheduler/DTSHubNameSetSettingStep.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { nonNullProp } from '@microsoft/vscode-azext-utils';
6+
import { ActivityChildItem, ActivityChildType, activityFailIcon, activityProgressContext, activityProgressIcon, activitySuccessContext, activitySuccessIcon, createContextValue, nonNullProp, type ExecuteActivityOutput } from '@microsoft/vscode-azext-utils';
77
import { ConnectionKey } from '../../../../constants';
8+
import { localize } from '../../../../localize';
89
import { SetConnectionSettingStepBase } from '../SetConnectionSettingStepBase';
910
import { type IDTSConnectionWizardContext } from './IDTSConnectionWizardContext';
1011

1112
export class DTSHubNameSetSettingStep<T extends IDTSConnectionWizardContext> extends SetConnectionSettingStepBase<T> {
1213
public priority: number = 241;
14+
public stepName: string = 'dtsHubNameSetSettingStep';
1315
public debugDeploySetting: ConnectionKey = ConnectionKey.DTSHub;
1416

1517
public async execute(context: T): Promise<void> {
@@ -19,4 +21,39 @@ export class DTSHubNameSetSettingStep<T extends IDTSConnectionWizardContext> ext
1921
public shouldExecute(context: T): boolean {
2022
return !!context.newDTSHubNameConnectionSetting;
2123
}
24+
25+
public createSuccessOutput(context: T): ExecuteActivityOutput {
26+
return {
27+
item: new ActivityChildItem({
28+
label: localize('prepareDTSHubNameLabel', 'Prepare DTS hub connection: "{0}"', context.newDTSHubNameConnectionSetting),
29+
contextValue: createContextValue([`${this.stepName}Item`, activitySuccessContext]),
30+
activityType: ActivityChildType.Success,
31+
iconPath: activitySuccessIcon,
32+
}),
33+
message: localize('prepareDTSHubNameSuccess', 'Successfully prepared DTS hub connection: "{0}".', context.newDTSConnectionSetting),
34+
};
35+
}
36+
37+
public createProgressOutput(): ExecuteActivityOutput {
38+
return {
39+
item: new ActivityChildItem({
40+
label: localize('prepareDTSHubNameProgressLabel', 'Prepare DTS hub connection: "..."'),
41+
contextValue: createContextValue([`${this.stepName}Item`, activityProgressContext]),
42+
activityType: ActivityChildType.Progress,
43+
iconPath: activityProgressIcon,
44+
}),
45+
};
46+
}
47+
48+
public createFailOutput(context: T): ExecuteActivityOutput {
49+
return {
50+
item: new ActivityChildItem({
51+
label: localize('prepareDTSHubNameLabel', 'Prepare DTS hub connection: "{0}"', context.newDTSHubNameConnectionSetting),
52+
contextValue: createContextValue([`${this.stepName}Item`, activitySuccessContext]),
53+
activityType: ActivityChildType.Fail,
54+
iconPath: activityFailIcon,
55+
}),
56+
message: localize('prepareDTSHubNameFail', 'Failed to prepare DTS hub connection: "{0}".', context.newDTSConnectionSetting),
57+
};
58+
}
2259
}

src/commands/appSettings/connectionSettings/durableTaskScheduler/IDTSConnectionWizardContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { type IActionContext } from "@microsoft/vscode-azext-utils";
6+
import { type ExecuteActivityContext, type IActionContext } from "@microsoft/vscode-azext-utils";
77
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
88
import { type ConnectionType } from "../../../../constants";
99
import { type DurableTaskHubResource, type DurableTaskSchedulerResource } from "../../../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
@@ -20,7 +20,7 @@ export interface IDTSConnectionWizardContext extends IActionContext, ISetConnect
2020
newDTSHubNameConnectionSetting?: string;
2121
}
2222

23-
export interface IDTSAzureConnectionWizardContext extends IFunctionAppUserAssignedIdentitiesContext, IDTSConnectionWizardContext {
23+
export interface IDTSAzureConnectionWizardContext extends IFunctionAppUserAssignedIdentitiesContext, IDTSConnectionWizardContext, Partial<ExecuteActivityContext> {
2424
subscription?: AzureSubscription;
2525

2626
/**
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { ActivityChildItem, ActivityChildType, activityInfoContext, activityInfoIcon, AzureWizardPromptStep, createContextValue, prependOrInsertAfterLastInfoChild, type ActivityInfoChild } from "@microsoft/vscode-azext-utils";
7+
import { ext } from "../../../../../extensionVariables";
8+
import { localize } from "../../../../../localize";
9+
import { type IDTSAzureConnectionWizardContext } from "../IDTSConnectionWizardContext";
10+
11+
const startingResourcesContext: string = 'startingResourcesLogStepItem';
12+
13+
export class DTSStartingResourcesLogStep<T extends IDTSAzureConnectionWizardContext> extends AzureWizardPromptStep<T> {
14+
public hideStepCount: boolean = true;
15+
protected hasLogged: boolean = false;
16+
17+
public async configureBeforePrompt(context: T): Promise<void> {
18+
if (this.hasLogged) {
19+
return;
20+
}
21+
22+
if (context.resourceGroup) {
23+
prependOrInsertAfterLastInfoChild(context,
24+
new ActivityChildItem({
25+
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
26+
label: localize('useResourceGroup', 'Use resource group "{0}"', context.resourceGroup.name),
27+
activityType: ActivityChildType.Info,
28+
iconPath: activityInfoIcon
29+
}) as ActivityInfoChild
30+
);
31+
ext.outputChannel.appendLog(localize('usingResourceGroup', 'Using resource group "{0}".', context.resourceGroup.name));
32+
}
33+
34+
if (context.site) {
35+
prependOrInsertAfterLastInfoChild(context,
36+
new ActivityChildItem({
37+
label: localize('useFunctionApp', 'Use function app "{0}"', context.site.fullName),
38+
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
39+
activityType: ActivityChildType.Info,
40+
iconPath: activityInfoIcon,
41+
}) as ActivityInfoChild,
42+
);
43+
ext.outputChannel.appendLog(localize('usingFunctionApp', 'Using function app "{0}".', context.site.fullName));
44+
}
45+
46+
if (context.dts) {
47+
prependOrInsertAfterLastInfoChild(context,
48+
new ActivityChildItem({
49+
label: localize('useDTS', 'Use durable task scheduler "{0}"', context.dts.name),
50+
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
51+
activityType: ActivityChildType.Info,
52+
iconPath: activityInfoIcon
53+
}) as ActivityInfoChild,
54+
);
55+
ext.outputChannel.appendLog(localize('usingDTS', 'Using durable task scheduler "{0}".', context.dts.name));
56+
}
57+
58+
if (context.dtsHub) {
59+
prependOrInsertAfterLastInfoChild(context,
60+
new ActivityChildItem({
61+
label: localize('useDTSHub', 'Use durable task hub "{0}"', context.dtsHub.name),
62+
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
63+
activityType: ActivityChildType.Info,
64+
iconPath: activityInfoIcon,
65+
}) as ActivityInfoChild,
66+
);
67+
ext.outputChannel.appendLog(localize('usingDTSHub', 'Using durable task hub "{0}".', context.dtsHub.name));
68+
}
69+
70+
ext.outputChannel.appendLog(localize('prioritizingSiteLocation', 'Prioritizing site location: "{0}".', context.site?.location));
71+
this.hasLogged = true;
72+
}
73+
74+
public async prompt(): Promise<void> {
75+
// Don't prompt, just use to log starting resources
76+
}
77+
78+
public shouldPrompt(): boolean {
79+
return false;
80+
}
81+
}

src/commands/appSettings/connectionSettings/durableTaskScheduler/azure/DurableTaskHubCreateStep.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,31 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { AzureWizardExecuteStep, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
6+
import { AzureWizardExecuteStepWithActivityOutput, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
77
import { type Progress } from "vscode";
88
import { localize } from "../../../../../localize";
99
import { HttpDurableTaskSchedulerClient, type DurableTaskSchedulerClient } from "../../../../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
1010
import { type IDTSAzureConnectionWizardContext } from "../IDTSConnectionWizardContext";
1111

12-
export class DurableTaskHubCreateStep<T extends IDTSAzureConnectionWizardContext> extends AzureWizardExecuteStep<T> {
13-
priority: number = 160;
14-
private readonly schedulerClient: DurableTaskSchedulerClient;
12+
export class DurableTaskHubCreateStep<T extends IDTSAzureConnectionWizardContext> extends AzureWizardExecuteStepWithActivityOutput<T> {
13+
public priority: number = 160;
14+
public stepName: string = 'durableTaskHubCreateStep';
15+
16+
protected getOutputLogSuccess = (context: T) => localize('createTaskHubSuccess', 'Created durable task hub "{0}"', context.dtsHub?.name);
17+
protected getOutputLogFail = (context: T) => localize('createTaskHubFail', 'Failed to create durable task hub "{0}"', context.newDTSHubName);
18+
protected getTreeItemLabel = (context: T) => localize('createTaskHubLabel', 'Create durable task hub "{0}"', context.newDTSHubName);
19+
20+
private readonly _schedulerClient: DurableTaskSchedulerClient;
1521

1622
constructor(schedulerClient?: DurableTaskSchedulerClient) {
1723
super();
18-
this.schedulerClient = schedulerClient ?? new HttpDurableTaskSchedulerClient();
24+
this._schedulerClient = schedulerClient ?? new HttpDurableTaskSchedulerClient();
1925
}
2026

2127
public async execute(context: T, progress: Progress<{ message?: string; increment?: number; }>): Promise<void> {
2228
progress.report({ message: localize('createTaskHub', 'Creating durable task hub...') });
2329

24-
context.dtsHub = await this.schedulerClient.createTaskHub(
30+
context.dtsHub = await this._schedulerClient.createTaskHub(
2531
nonNullProp(context, 'subscription'),
2632
nonNullValueAndProp(context.resourceGroup, 'name'),
2733
nonNullValueAndProp(context.dts, 'name'),

src/commands/appSettings/connectionSettings/durableTaskScheduler/azure/DurableTaskSchedulerCreateStep.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { LocationListStep } from "@microsoft/vscode-azext-azureutils";
7-
import { AzureWizardExecuteStep, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
7+
import { ActivityChildItem, ActivityChildType, activityProgressContext, activityProgressIcon, AzureWizardExecuteStepWithActivityOutput, createContextValue, nonNullProp, nonNullValueAndProp, type ExecuteActivityOutput } from "@microsoft/vscode-azext-utils";
88
import { type Progress } from "vscode";
99
import { localize } from "../../../../../localize";
1010
import { HttpDurableTaskSchedulerClient, type DurableTaskSchedulerClient } from "../../../../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
1111
import { withCancellation } from "../../../../../utils/cancellation";
1212
import { getSchedulerConnectionString, SchedulerAuthenticationType } from "../../../../durableTaskScheduler/copySchedulerConnectionString";
1313
import { type IDTSAzureConnectionWizardContext } from "../IDTSConnectionWizardContext";
1414

15-
export class DurableTaskSchedulerCreateStep<T extends IDTSAzureConnectionWizardContext> extends AzureWizardExecuteStep<T> {
16-
priority: number = 150;
17-
private readonly schedulerClient: DurableTaskSchedulerClient;
15+
export class DurableTaskSchedulerCreateStep<T extends IDTSAzureConnectionWizardContext> extends AzureWizardExecuteStepWithActivityOutput<T> {
16+
public priority: number = 150;
17+
public stepName: string = 'durableTaskSchedulerCreateStep';
18+
19+
protected getOutputLogSuccess = (context: T) => localize('createTaskSchedulerSuccess', 'Created durable task scheduler "{0}"', context.dts?.name);
20+
protected getOutputLogFail = (context: T) => localize('createTaskSchedulerFail', 'Failed to create durable task scheduler "{0}"', context.newDTSName);
21+
protected getTreeItemLabel = (context: T) => localize('createTaskSchedulerLabel', 'Create durable task scheduler "{0}"', context.newDTSName);
22+
23+
private readonly _schedulerClient: DurableTaskSchedulerClient;
1824

1925
public constructor(schedulerClient?: DurableTaskSchedulerClient) {
2026
super();
21-
this.schedulerClient = schedulerClient ?? new HttpDurableTaskSchedulerClient();
27+
this._schedulerClient = schedulerClient ?? new HttpDurableTaskSchedulerClient();
2228
}
2329

2430
public async execute(context: T, progress: Progress<{ message?: string; increment?: number; }>): Promise<void> {
2531
progress.report({ message: localize('createTaskScheduler', 'Creating durable task scheduler...') });
2632

27-
const response = (await this.schedulerClient.createScheduler(
33+
const response = (await this._schedulerClient.createScheduler(
2834
nonNullProp(context, 'subscription'),
2935
nonNullValueAndProp(context.resourceGroup, 'name'),
3036
(await LocationListStep.getLocation(context)).name,
@@ -44,4 +50,16 @@ export class DurableTaskSchedulerCreateStep<T extends IDTSAzureConnectionWizardC
4450
public shouldExecute(context: T): boolean {
4551
return !context.dts;
4652
}
53+
54+
public createProgressOutput(context: T): ExecuteActivityOutput {
55+
return {
56+
item: new ActivityChildItem({
57+
label: this.getTreeItemLabel(context),
58+
description: localize('dtsCreateWarning', 'This could take a while...'),
59+
contextValue: createContextValue([`${this.stepName}Item`, activityProgressContext]),
60+
activityType: ActivityChildType.Progress,
61+
iconPath: activityProgressIcon,
62+
}),
63+
};
64+
}
4765
}

0 commit comments

Comments
 (0)