Skip to content

Commit f1783f4

Browse files
authored
Fix and improve scheduler creation with consumption sku (#4963)
1 parent 554aa38 commit f1783f4

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/commands/durableTaskScheduler/createScheduler.ts

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

6+
import { type ResourceManagementClient } from '@azure/arm-resources';
67
import { type AzExtClientContext, createAzureClient, type ILocationWizardContext, type IResourceGroupWizardContext, LocationListStep, parseClientContext, ResourceGroupCreateStep, ResourceGroupListStep, VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils";
7-
import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, createSubscriptionContext, type ExecuteActivityContext, type IAzureQuickPickItem, type IActionContext, type ISubscriptionActionContext, subscriptionExperience } from "@microsoft/vscode-azext-utils";
8+
import { AzureWizard, AzureWizardExecuteStepWithActivityOutput, AzureWizardPromptStep, createSubscriptionContext, type ExecuteActivityContext, type ExecuteActivityOutput, type IActionContext, type IAzureQuickPickItem, type ISubscriptionActionContext, subscriptionExperience } from "@microsoft/vscode-azext-utils";
89
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
10+
import { type Progress } from "vscode";
911
import { DurableTaskProvider, DurableTaskSchedulersResourceType } from "../../constants";
1012
import { defaultDescription } from "../../constants-nls";
1113
import { ext } from '../../extensionVariables';
1214
import { localize } from '../../localize';
13-
import { DurableTaskSchedulerSku, type DurableTaskSchedulerClient } from "../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
15+
import { type DurableTaskSchedulerClient, DurableTaskSchedulerSku } from "../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
1416
import { type DurableTaskSchedulerDataBranchProvider } from "../../tree/durableTaskScheduler/DurableTaskSchedulerDataBranchProvider";
1517
import { createActivityContext } from "../../utils/activityUtils";
1618
import { withCancellation } from "../../utils/cancellation";
17-
import { type Progress } from "vscode";
18-
import { type ResourceManagementClient } from '@azure/arm-resources';
1919

2020
interface ICreateSchedulerContext extends ISubscriptionActionContext, ILocationWizardContext, IResourceGroupWizardContext, ExecuteActivityContext {
2121
subscription?: AzureSubscription;
@@ -51,16 +51,30 @@ class SchedulerSkuStep extends AzureWizardPromptStep<ICreateSchedulerContext> {
5151
}
5252
}
5353

54-
class SchedulerCreationStep extends AzureWizardExecuteStep<ICreateSchedulerContext> {
55-
priority: number = 1;
54+
class SchedulerCreationStep extends AzureWizardExecuteStepWithActivityOutput<ICreateSchedulerContext> {
55+
priority: number = 110;
56+
readonly stepName: string = 'schedulerCreationStep';
57+
58+
protected getTreeItemLabel = (context: ICreateSchedulerContext) => localize('createSchedulerLabel', 'Create Durable Task Scheduler "{0}"', context.schedulerName);
59+
protected getOutputLogSuccess = (context: ICreateSchedulerContext) => localize('createSchedulerSuccess', 'Successfully created Durable Task Scheduler "{0}".', context.schedulerName);
60+
protected getOutputLogFail = (context: ICreateSchedulerContext) => localize('createSchedulerFail', 'Failed to create Durable Task Scheduler "{0}".', context.schedulerName);
61+
62+
public createProgressOutput(context: ICreateSchedulerContext): ExecuteActivityOutput {
63+
const output = super.createProgressOutput(context);
64+
if (output.item) {
65+
output.item.description = localize('schedulerProgressDescription', 'This may take a while...');
66+
}
67+
return output;
68+
}
5669

5770
constructor(private readonly schedulerClient: DurableTaskSchedulerClient) {
5871
super();
5972
}
6073

61-
async execute(wizardContext: ICreateSchedulerContext, _: Progress<{ message?: string; increment?: number; }>): Promise<void> {
62-
const location = await LocationListStep.getLocation(wizardContext);
74+
async execute(wizardContext: ICreateSchedulerContext, progress: Progress<{ message?: string; increment?: number; }>): Promise<void> {
75+
progress.report({ message: localize('creatingScheduler', 'Creating Durable Task Scheduler...') });
6376

77+
const location = await LocationListStep.getLocation(wizardContext);
6478
const response = await this.schedulerClient.createScheduler(
6579
wizardContext.subscription as AzureSubscription,
6680
wizardContext.resourceGroup?.name as string,
@@ -109,7 +123,7 @@ export function createSchedulerCommandFactory(dataBranchProvider: DurableTaskSch
109123

110124
...actionContext,
111125
...createSubscriptionContext(subscription),
112-
...await createActivityContext()
126+
...await createActivityContext({ withChildren: true }),
113127
};
114128

115129
if (!await isDtsProviderRegistered(wizardContext)) {

src/tree/durableTaskScheduler/DurableTaskSchedulerClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface DurableTaskSchedulerCreateRequest {
2323
readonly ipAllowlist: string[];
2424
readonly sku: {
2525
readonly name: string;
26-
readonly capacity: number;
26+
readonly capacity?: number;
2727
};
2828
};
2929
readonly tags: unknown;
@@ -95,7 +95,7 @@ export class HttpDurableTaskSchedulerClient implements DurableTaskSchedulerClien
9595
ipAllowlist: ['0.0.0.0/0'],
9696
sku: {
9797
name: sku,
98-
capacity: sku === DurableTaskSchedulerSku.Dedicated ? 1 : 0
98+
...(sku === DurableTaskSchedulerSku.Dedicated ? { capacity: 1 } : {})
9999
}
100100
},
101101
tags: {
@@ -187,7 +187,7 @@ export class HttpDurableTaskSchedulerClient implements DurableTaskSchedulerClien
187187

188188
private static getBaseUrl(subscription: AzureSubscription, resourceGroupName?: string, schedulerName?: string, relativeUrl?: string | undefined) {
189189
const provider = 'Microsoft.DurableTask';
190-
const apiVersion = '2024-10-01-preview';
190+
const apiVersion = '2025-11-01';
191191

192192
let url = `${subscription.environment.resourceManagerEndpointUrl}subscriptions/${subscription.subscriptionId}`;
193193

0 commit comments

Comments
 (0)