Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CV2 deployments #3760

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 15 additions & 3 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { notifyDeployComplete } from './notifyDeployComplete';
import { runPreDeployTask } from './runPreDeployTask';
import { shouldValidateConnections } from './shouldValidateConnection';
import { showCoreToolsWarning } from './showCoreToolsWarning';
import { showFlexDeployConfirmation } from './showFlexDeployConfirmation';
import { validateRemoteBuild } from './validateRemoteBuild';
import { verifyAppSettings } from './verifyAppSettings';

Expand Down Expand Up @@ -83,14 +84,19 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
context.deployMethod = 'zip';
}

const doRemoteBuild: boolean | undefined = getWorkspaceSetting<boolean>(remoteBuildSetting, deployPaths.effectiveDeployFsPath);
const isFlexConsumption: boolean = await client.getIsConsumptionV2(actionContext);
actionContext.telemetry.properties.isFlexConsumption = String(isFlexConsumption);
// don't use remote build setting for consumption v2
const doRemoteBuild: boolean | undefined = getWorkspaceSetting<boolean>(remoteBuildSetting, deployPaths.effectiveDeployFsPath) && !isFlexConsumption;
actionContext.telemetry.properties.scmDoBuildDuringDeployment = String(doRemoteBuild);
if (doRemoteBuild) {
await validateRemoteBuild(context, node.site, context.workspaceFolder, language);
}

if (isZipDeploy && node.site.isLinux && isConsumption && !doRemoteBuild) {
context.deployMethod = 'storage';
} else if (isFlexConsumption) {
context.deployMethod = 'flexconsumption';
}

const durableStorageType: DurableBackendValues | undefined = await durableUtils.getStorageTypeFromWorkspace(language, context.projectPath);
Expand All @@ -107,7 +113,12 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
}

if (getWorkspaceSetting<boolean>('showDeployConfirmation', context.workspaceFolder.uri.fsPath) && !context.isNewApp && isZipDeploy) {
await showDeployConfirmation(context, node.site, 'azureFunctions.deploy');
const deployCommandId = 'azureFunctions.deploy';
if (context.deployMethod === 'flexconsumption') {
await showFlexDeployConfirmation(context, node.site, deployCommandId);
} else {
await showDeployConfirmation(context, node.site, deployCommandId);
}
}

await runPreDeployTask(context, context.effectiveDeployFsPath, siteConfig.scmType);
Expand All @@ -120,7 +131,8 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
await updateWorkerProcessTo64BitIfRequired(context, siteConfig, node, language, durableStorageType);
}

if (isZipDeploy) {
// app settings shouldn't be checked with flex consumption plans
if (isZipDeploy && !isFlexConsumption) {
await verifyAppSettings({
context,
node,
Expand Down
19 changes: 19 additions & 0 deletions src/commands/deploy/showFlexDeployConfirmation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IDeployContext, ParsedSite, showCustomDeployConfirmation } from "@microsoft/vscode-azext-azureappservice";
import { MessageItem } from "vscode";
import { localize } from "../../localize";

export async function showFlexDeployConfirmation(context: IDeployContext, site: ParsedSite, deployCommandId: string): Promise<void> {
const learnMoreLink: string = 'https://aka.ms/flexconsumption-remotebuild';
const remoteDeploy: MessageItem = { title: localize('remoteDeploy', 'Deploy with Remote Build ') };
const input: MessageItem = await showCustomDeployConfirmation(context, site, deployCommandId, { items: [remoteDeploy], learnMoreLink });

// TODO: Allow users to have a "don't ask again option"
if (input === remoteDeploy) {
context.flexConsumptionRemoteBuild = true;
}
}