in apps/vs-code-designer/src/app/commands/deploy/deploy.ts [77:218]
async function deploy(
actionContext: IActionContext,
target: Uri | string | SlotTreeItem | undefined,
functionAppId: string | Record<string, any> | undefined,
expectedContextValue?: string | RegExp
): Promise<void> {
addLocalFuncTelemetry(actionContext);
let deployProjectPathForWorkflowApp: string | undefined;
const settingsToExclude: string[] = [webhookRedirectHostUri];
const deployPaths = await getDeployFsPath(actionContext, target);
const context: IDeployContext = Object.assign(actionContext, deployPaths, { defaultAppSetting: 'defaultFunctionAppToDeploy' });
const { originalDeployFsPath, effectiveDeployFsPath, workspaceFolder } = deployPaths;
ext.deploymentFolderPath = originalDeployFsPath;
let node: SlotTreeItem;
if (expectedContextValue) {
node = await getDeployNode(context, ext.rgApi.appResourceTree, target, functionAppId, async () =>
ext.rgApi.pickAppResource(
{ ...context, suppressCreatePick: false },
{
filter: logicAppFilter,
expectedChildContextValue: expectedContextValue,
}
)
);
} else {
node = await getDeployNode(context, ext.rgApi.appResourceTree, target, functionAppId, async () => getDeployLogicAppNode(actionContext));
}
const isHybridLogicApp = !!node.isHybridLogicApp;
const nodeKind = (isHybridLogicApp ? node.hybridSite.type : node.site.kind).toLowerCase();
const isWorkflowApp = nodeKind?.includes(logicAppKind);
const isDeployingToKubernetes = nodeKind && nodeKind.indexOf(kubernetesKind) !== -1;
const [language, version]: [ProjectLanguage, FuncVersion] = await verifyInitForVSCode(context, effectiveDeployFsPath);
context.telemetry.properties.projectLanguage = language;
context.telemetry.properties.projectRuntime = version;
const identityWizardContext: IIdentityWizardContext = {
clientId: undefined,
clientSecret: undefined,
objectId: undefined,
tenantId: undefined,
useAdvancedIdentity: undefined,
...context,
};
if (isDeployingToKubernetes) {
const managedApiConnectionExists = await managedApiConnectionsExists(workspaceFolder);
if (managedApiConnectionExists) {
const aadDetailsExist = await checkAADDetailsExistsInAppSettings(node, identityWizardContext);
if (!aadDetailsExist) {
const wizard: AzureWizard<IIdentityWizardContext> = new AzureWizard(identityWizardContext, {
promptSteps: [
new AdvancedIdentityObjectIdStep(),
new AdvancedIdentityClientIdStep(),
new AdvancedIdentityTenantIdStep(),
new AdvancedIdentityClientSecretStep(),
],
title: localize('aadDetails', 'Provide your AAD identity details to use with your Azure connections.'),
});
await wizard.prompt();
}
identityWizardContext.useAdvancedIdentity = true;
}
}
identityWizardContext?.useAdvancedIdentity ? await updateAppSettingsWithIdentityDetails(context, node, identityWizardContext) : undefined;
let isZipDeploy = false;
if (!isHybridLogicApp) {
await verifyAppSettings(context, node, version, language, originalDeployFsPath, !context.isNewApp);
const client = await node.site.createClient(actionContext);
const siteConfig: SiteConfigResource = await client.getSiteConfig();
isZipDeploy = siteConfig.scmType !== ScmType.LocalGit && siteConfig.scmType !== ScmType.GitHub;
if (getWorkspaceSetting<boolean>(showDeployConfirmationSetting, workspaceFolder.uri.fsPath) && !context.isNewApp && isZipDeploy) {
const warning: string = localize(
'confirmDeploy',
'Are you sure you want to deploy to "{0}"? This will overwrite any previous deployment and cannot be undone.',
client.fullName
);
context.telemetry.properties.cancelStep = 'confirmDestructiveDeployment';
const deployButton: MessageItem = { title: localize('deploy', 'Deploy') };
await context.ui.showWarningMessage(warning, { modal: true }, deployButton, DialogResponses.cancel);
context.telemetry.properties.cancelStep = '';
}
await runPreDeployTask(context, effectiveDeployFsPath, siteConfig.scmType);
if (isZipDeploy) {
validateGlobSettings(context, effectiveDeployFsPath);
}
}
await node.runWithTemporaryDescription(context, localize('deploying', 'Deploying...'), async () => {
// preDeploy tasks are only required for zipdeploy so subpath may not exist
let deployFsPath: string = effectiveDeployFsPath;
if (!isZipDeploy && !isPathEqual(effectiveDeployFsPath, originalDeployFsPath)) {
deployFsPath = originalDeployFsPath;
const noSubpathWarning = `WARNING: Ignoring deploySubPath "${getWorkspaceSetting(
deploySubpathSetting,
originalDeployFsPath
)}" for non-zip deploy.`;
ext.outputChannel.appendLog(noSubpathWarning);
}
if (isWorkflowApp) {
await cleanupPublishBinPath(context, effectiveDeployFsPath);
}
deployProjectPathForWorkflowApp = isWorkflowApp
? await getProjectPathToDeploy(node, workspaceFolder, settingsToExclude, deployFsPath, identityWizardContext, actionContext)
: undefined;
try {
if (isHybridLogicApp) {
await deployHybridLogicApp(context, node);
} else {
await innerDeploy(
node.site,
deployProjectPathForWorkflowApp !== undefined ? deployProjectPathForWorkflowApp : deployFsPath,
context
);
}
} finally {
if (deployProjectPathForWorkflowApp !== undefined && !isHybridLogicApp) {
await cleanAndRemoveDeployFolder(deployProjectPathForWorkflowApp);
}
}
});
if (!isHybridLogicApp) {
await node.loadAllChildren(context);
}
await notifyDeployComplete(node, context.workspaceFolder, isHybridLogicApp, settingsToExclude);
}