Skip to content

Commit 7958816

Browse files
authored
Add output to containerized steps and fix basic create (#4518)
1 parent bbe4c66 commit 7958816

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed

src/commands/createFunctionApp/containerImage/ContainerizedFunctionAppCreateStep.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type Site, type WebSiteManagementClient } from "@azure/arm-appservice";
77
import { type ServiceClient } from "@azure/core-client";
88
import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
99
import { LocationListStep, createGenericClient } from "@microsoft/vscode-azext-azureutils";
10-
import { AzureWizardExecuteStep, nonNullProp } from "@microsoft/vscode-azext-utils";
10+
import { AzureWizardExecuteStepWithActivityOutput, nonNullProp } from "@microsoft/vscode-azext-utils";
1111
import { type AppResource } from "@microsoft/vscode-azext-utils/hostapi";
1212
import { type Progress } from "vscode";
1313
import { webProvider } from "../../../constants";
@@ -16,15 +16,33 @@ import { createWebSiteClient } from "../../../utils/azureClients";
1616
import { getStorageConnectionString } from "../../appSettings/connectionSettings/getLocalConnectionSetting";
1717
import { type IFunctionAppWizardContext } from "../IFunctionAppWizardContext";
1818

19-
export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
19+
export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOutput<IFunctionAppWizardContext> {
20+
public stepName: string = 'containerizedFunctionAppCreateStep';
2021
public priority: number = 140;
2122

23+
protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
24+
const siteName: string = nonNullProp(context, 'newSiteName');
25+
return localize('creatingNewApp', 'Create containerized function app "{0}"', siteName);
26+
}
27+
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
28+
const siteName: string = nonNullProp(context, 'newSiteName');
29+
return localize('createdNewApp', 'Successfully created containerized function app "{0}".', siteName);
30+
}
31+
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
32+
const siteName: string = nonNullProp(context, 'newSiteName');
33+
return localize('failedToCreateNewApp', 'Failed to create containerized function app "{0}".', siteName);
34+
}
35+
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
36+
const siteName: string = nonNullProp(context, 'newSiteName');
37+
return localize('creatingNewApp', 'Creating containerized function app "{0}"...', siteName);
38+
}
39+
2240
public async execute(context: IFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
2341
if (!context.deployWorkspaceResult?.registryLoginServer || !context.deployWorkspaceResult?.imageName) {
24-
throw new Error(localize('failToCreateApp', 'Failed to create function app. There was an error creating the necessary container resources.'));
42+
throw new Error(localize('failToCreateApp', 'Failed to create containerized function app. There was an error creating the necessary container resources.'));
2543
}
2644

27-
const message: string = localize('creatingNewApp', 'Creating function app "{0}"...', context.newSiteName);
45+
const message: string = localize('creatingNewApp', 'Creating containerized function app "{0}"...', context.newSiteName);
2846
progress.report({ message });
2947

3048
const siteName: string = nonNullProp(context, 'newSiteName');
@@ -77,23 +95,6 @@ export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<I
7795
}
7896
}
7997
}
80-
81-
protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
82-
const siteName: string = nonNullProp(context, 'newSiteName');
83-
return localize('creatingNewApp', 'Create function app "{0}"', siteName);
84-
}
85-
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
86-
const siteName: string = nonNullProp(context, 'newSiteName');
87-
return localize('createdNewApp', 'Successfully created function app "{0}".', siteName);
88-
}
89-
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
90-
const siteName: string = nonNullProp(context, 'newSiteName');
91-
return localize('failedToCreateNewApp', 'Failed to create function app "{0}".', siteName);
92-
}
93-
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
94-
const siteName: string = nonNullProp(context, 'newSiteName');
95-
return localize('creatingNewApp', 'Creating function app "{0}"...', siteName);
96-
}
9798
}
9899

99100
async function pingContainerizedFunctionApp(context: IFunctionAppWizardContext, client: WebSiteManagementClient, site: Site): Promise<void> {

src/commands/createFunctionApp/containerImage/DeployWorkspaceProjectStep.ts

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

6-
import { AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
6+
import { AzureWizardExecuteStepWithActivityOutput } from "@microsoft/vscode-azext-utils";
77
import { type Progress } from "vscode";
8-
import { ext } from "../../../extensionVariables";
98
import { getAzureContainerAppsApi } from "../../../getExtensionApi";
109
import { localize } from "../../../localize";
1110
import { type IFunctionAppWizardContext } from "../IFunctionAppWizardContext";
1211

13-
export class DeployWorkspaceProjectStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
12+
export class DeployWorkspaceProjectStep extends AzureWizardExecuteStepWithActivityOutput<IFunctionAppWizardContext> {
1413
public priority: number = 137;
14+
public stepName: string = 'deployWorkspaceProjectStep';
15+
16+
public getOutputLogSuccess(context: IFunctionAppWizardContext): string {
17+
return localize('deployWorkspaceProjectSuccess', 'Successfully created container resources for "{0}".', context.deployWorkspaceResult?.imageName);
18+
}
19+
public getOutputLogFail(_context: IFunctionAppWizardContext): string {
20+
return localize('deployWorkspaceProjectFail', 'Failed to create container resources.');
21+
}
22+
23+
public getOutputLogProgress(_context: IFunctionAppWizardContext): string {
24+
return localize('deployWorkspaceProjectProgress', 'Creating container resources; this may take a few minutes...');
25+
}
26+
public getTreeItemLabel(context: IFunctionAppWizardContext): string {
27+
return context.deployWorkspaceResult ?
28+
localize('deployWorkspaceProjectLabel', 'Create container resources for "{0}"', context.deployWorkspaceResult.imageName) :
29+
localize('deployWorkspaceProjectLabel', 'Create container resources; this may take a few minutes...'); '';
30+
}
1531

1632
public async execute(context: IFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
1733
const message: string = localize('creatingCAResources', 'Creating container resources; this may take a few minutes...');
18-
ext.outputChannel.appendLog(message);
1934
progress.report({ message });
2035

2136
const containerAppsApi = await getAzureContainerAppsApi(context);

src/commands/createFunctionApp/createCreateFunctionAppComponents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export async function createCreateFunctionAppComponents(context: ICreateFunction
6969

7070
if (!wizardContext.advancedCreation) {
7171
LocationListStep.addStep(wizardContext, promptSteps);
72-
wizardContext.useFlexConsumptionPlan = true;
72+
// if the user is deploying to a container app, do not use a flex consumption plan
73+
wizardContext.useFlexConsumptionPlan = true && !context.dockerfilePath;
7374
wizardContext.stackFilter = getRootFunctionsWorkerRuntime(wizardContext.language);
7475
promptSteps.push(new ConfigureCommonNamesStep());
7576
executeSteps.push(new ResourceGroupCreateStep());

0 commit comments

Comments
 (0)