Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 47 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1410,10 +1410,10 @@
"@azure/core-client": "^1.7.3",
"@azure/core-rest-pipeline": "^1.11.0",
"@azure/storage-blob": "^12.5.0",
"@microsoft/vscode-azext-azureappservice": "^3.5.4",
"@microsoft/vscode-azext-azureappservice": "^3.6.0",
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
"@microsoft/vscode-azext-azureutils": "^3.1.8",
"@microsoft/vscode-azext-utils": "^2.6.8",
"@microsoft/vscode-azext-azureutils": "^3.2.1",
"@microsoft/vscode-azext-utils": "^3.0.1",
"@microsoft/vscode-azureresources-api": "^2.0.4",
"cross-fetch": "^4.0.0",
"escape-string-regexp": "^4.0.0",
Expand Down
12 changes: 8 additions & 4 deletions src/commands/addMIConnections/LocalSettingsAddStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { activitySuccessContext, activitySuccessIcon, AzExtFsExtra, AzureWizardExecuteStep, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ActivityChildItem, ActivityChildType, activitySuccessContext, activitySuccessIcon, AzExtFsExtra, AzureWizardExecuteStep, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ext } from "../../extensionVariables";
import { getLocalSettingsJsonwithEncryption } from "../../funcConfig/local.settings";
import { localize } from "../../localize";
Expand All @@ -12,6 +12,7 @@ import { type AddMIConnectionsContext } from "./AddMIConnectionsContext";

export class LocalSettingsAddStep extends AzureWizardExecuteStep<AddMIConnectionsContext> {
public priority: number = 160;
public stepName: string = 'localSettingsAddStep';

public async execute(context: AddMIConnectionsContext): Promise<void> {
// If right clicking on a connection we will have the connections to convert but not the local settings path
Expand All @@ -22,13 +23,16 @@ export class LocalSettingsAddStep extends AzureWizardExecuteStep<AddMIConnection

const localSettings = await getLocalSettingsJsonwithEncryption(context, context.localSettingsPath);
if (localSettings.Values) {
// Potentially split this up into multiple execute steps to allow for better progress reporting
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
localSettings.Values[connection.name] = connection.value;
// TODO: Convert to use createSuccessOutput
context.activityChildren?.push(
new GenericTreeItem(undefined, {
contextValue: createUniversallyUniqueContextValue(['useExistingResourceGroupInfoItem', activitySuccessContext]),
new ActivityChildItem({
contextValue: createContextValue([this.stepName, activitySuccessContext]),
label: localize('addedLocalSetting', 'Add local setting "{0}"', connection.name),
iconPath: activitySuccessIcon
iconPath: activitySuccessIcon,
activityType: ActivityChildType.Success
})
);
}
Expand Down
12 changes: 8 additions & 4 deletions src/commands/addMIConnections/RemoteSettingsAddStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { activitySuccessContext, activitySuccessIcon, AzureWizardExecuteStep, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ActivityChildItem, ActivityChildType, activitySuccessContext, activitySuccessIcon, AzureWizardExecuteStep, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ext } from "../../extensionVariables";
import { localize } from "../../localize";
import { type AddMIConnectionsContext } from "./AddMIConnectionsContext";

export class RemoteSettingsAddStep extends AzureWizardExecuteStep<AddMIConnectionsContext> {
public priority: number = 160;
public stepName: string = 'remoteSettingsAddStep';

public async execute(context: AddMIConnectionsContext): Promise<void> {
const client = await nonNullProp(context, 'functionapp').site.createClient(context);
const remoteSettings = await client.listApplicationSettings();
const properties = remoteSettings.properties || {};
// // Potentially split this up into multiple execute steps to allow for better progress reporting
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
properties[connection.name] = connection.value;
}

await client.updateApplicationSettings({ properties });
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
// TODO: Convert to use createSuccessOutput
context.activityChildren?.push(
new GenericTreeItem(undefined, {
contextValue: createUniversallyUniqueContextValue(['useExistingResourceGroupInfoItem', activitySuccessContext]),
new ActivityChildItem({
contextValue: createContextValue([this.stepName, activitySuccessContext]),
label: localize('addedAppSetting', 'Add app setting "{0}"', connection.name),
iconPath: activitySuccessIcon
iconPath: activitySuccessIcon,
activityType: ActivityChildType.Success
})
);
}
Expand Down
27 changes: 21 additions & 6 deletions src/commands/createFunctionApp/FunctionAppCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { type Identity } from '@azure/arm-resources';
import { BlobServiceClient } from '@azure/storage-blob';
import { ParsedSite, WebsiteOS, type CustomLocation, type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice';
import { LocationListStep } from '@microsoft/vscode-azext-azureutils';
import { AzureWizardExecuteStep, maskUserInfo, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
import { AzureWizardExecuteStepWithActivityOutput, maskUserInfo, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
import { type AppResource } from '@microsoft/vscode-azext-utils/hostapi';
import { type Progress } from 'vscode';
import { FuncVersion, getMajorVersion } from '../../FuncVersion';
Expand All @@ -22,11 +22,11 @@ import { nonNullProp } from '../../utils/nonNull';
import { getStorageConnectionString } from '../appSettings/connectionSettings/getLocalConnectionSetting';
import { enableFileLogging } from '../logstream/enableFileLogging';
import { type FullFunctionAppStack, type IFlexFunctionAppWizardContext, type IFunctionAppWizardContext } from './IFunctionAppWizardContext';
import { showSiteCreated } from './showSiteCreated';
import { type Sku } from './stacks/models/FlexSkuModel';
import { type FunctionAppRuntimeSettings, } from './stacks/models/FunctionAppStackModel';

export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOutput<IFunctionAppWizardContext> {
stepName: string = 'createFunctionAppStep';
public priority: number = 1000;

public async execute(context: IFlexFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
Expand All @@ -39,8 +39,7 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
context.telemetry.properties.newSiteMinorVersion = stack.minorVersion.value;
context.telemetry.properties.planSkuTier = context.plan?.sku?.tier;

const message: string = localize('creatingNewApp', 'Creating new function app "{0}"...', context.newSiteName);
ext.outputChannel.appendLog(message);
const message: string = localize('creatingFuncApp', 'Creating function app "{0}"...', context.newSiteName);
progress.report({ message });

const siteName: string = nonNullProp(context, 'newSiteName');
Expand All @@ -58,7 +57,6 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
context.telemetry.properties.fileLoggingError = maskUserInfo(parseError(error).message, []);
}
}
showSiteCreated(site, context);
}

public shouldExecute(context: IFunctionAppWizardContext): boolean {
Expand Down Expand Up @@ -249,6 +247,23 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi

return result;
}

protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('creatingNewApp', 'Create function app "{0}"', siteName);
}
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('createdNewApp', 'Successfully created function app "{0}".', siteName);
}
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('failedToCreateNewApp', 'Failed to create function app "{0}".', siteName);
}
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('creatingNewApp', 'Creating function app "{0}"...', siteName);
}
}

function getNewFileShareName(siteName: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,28 @@ import { AzureWizardExecuteStep, nonNullProp } from "@microsoft/vscode-azext-uti
import { type AppResource } from "@microsoft/vscode-azext-utils/hostapi";
import { type Progress } from "vscode";
import { webProvider } from "../../../constants";
import { ext } from "../../../extensionVariables";
import { localize } from "../../../localize";
import { createWebSiteClient } from "../../../utils/azureClients";
import { getStorageConnectionString } from "../../appSettings/connectionSettings/getLocalConnectionSetting";
import { type IFunctionAppWizardContext } from "../IFunctionAppWizardContext";
import { showSiteCreated } from "../showSiteCreated";

export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
public priority: number = 140;

public async execute(context: IFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
const message: string = localize('creatingNewApp', 'Creating new function app "{0}"...', context.newSiteName);
ext.outputChannel.appendLog(message);
progress.report({ message });

if (!context.deployWorkspaceResult?.registryLoginServer || !context.deployWorkspaceResult?.imageName) {
throw new Error(localize('failToCreateApp', 'Failed to create function app. There was an error creating the necessary container resources.'));
}

const message: string = localize('creatingNewApp', 'Creating function app "{0}"...', context.newSiteName);
progress.report({ message });

const siteName: string = nonNullProp(context, 'newSiteName');
const rgName: string = nonNullProp(nonNullProp(context, 'resourceGroup'), 'name');
const client: WebSiteManagementClient = await createWebSiteClient(context);
context.site = await client.webApps.beginCreateOrUpdateAndWait(rgName, siteName, await this.getNewSite(context));
context.activityResult = context.site as AppResource;

const containerSite = Object.assign(context.site, { defaultHostUrl: `https://${context.site.defaultHostName}`, fullName: context.site.name, isSlot: false });

await pingContainerizedFunctionApp(context, client, context.site);
showSiteCreated(containerSite, context);
}

public shouldExecute(context: IFunctionAppWizardContext): boolean {
Expand Down Expand Up @@ -84,6 +77,23 @@ export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<I
}
}
}

protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('creatingNewApp', 'Create function app "{0}"', siteName);
}
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('createdNewApp', 'Successfully created function app "{0}".', siteName);
}
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('failedToCreateNewApp', 'Failed to create function app "{0}".', siteName);
}
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
const siteName: string = nonNullProp(context, 'newSiteName');
return localize('creatingNewApp', 'Creating function app "{0}"...', siteName);
}
}

async function pingContainerizedFunctionApp(context: IFunctionAppWizardContext, client: WebSiteManagementClient, site: Site): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export async function createCreateFunctionAppComponents(context: ICreateFunction
...(await createActivityContext())
});

wizardContext.activityChildren = [];

const promptSteps: AzureWizardPromptStep<IFunctionAppWizardContext>[] = [];
const executeSteps: AzureWizardExecuteStep<IFunctionAppWizardContext>[] = [];

Expand Down
Loading