Fix advanced function app creation failing for containerized function apps (#4009)

* move functionapphostingplanstep

* move where createFunctionAppWizard gets called

* use shouldPrompt
This commit is contained in:
Megan Mott 2024-03-08 10:04:58 -08:00 коммит произвёл GitHub
Родитель 2844ce2d62
Коммит 5909b52c89
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 20 добавлений и 16 удалений

Просмотреть файл

@ -3,14 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AppServicePlanListStep, setLocationsTask, type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice';
import { AppServicePlanListStep, setLocationsTask } from '@microsoft/vscode-azext-azureappservice';
import { AzureWizardPromptStep, type IAzureQuickPickItem, type IWizardOptions } from '@microsoft/vscode-azext-utils';
import { localize } from '../../localize';
import { getRandomHexString } from '../../utils/fs';
import { nonNullProp } from '../../utils/nonNull';
import { type IFunctionAppWizardContext } from './IFunctionAppWizardContext';
export class FunctionAppHostingPlanStep extends AzureWizardPromptStep<IAppServiceWizardContext> {
public async prompt(context: IAppServiceWizardContext): Promise<void> {
export class FunctionAppHostingPlanStep extends AzureWizardPromptStep<IFunctionAppWizardContext> {
public async prompt(context: IFunctionAppWizardContext): Promise<void> {
const placeHolder: string = localize('selectHostingPlan', 'Select a hosting plan.');
const picks: IAzureQuickPickItem<[boolean, RegExp | undefined]>[] = [
{ label: localize('consumption', 'Consumption'), data: [true, undefined] },
@ -25,16 +26,16 @@ export class FunctionAppHostingPlanStep extends AzureWizardPromptStep<IAppServic
}
}
public shouldPrompt(context: IAppServiceWizardContext): boolean {
return context.useConsumptionPlan === undefined;
public shouldPrompt(context: IFunctionAppWizardContext): boolean {
return context.useConsumptionPlan === undefined || context.dockerfilePath !== undefined;
}
public async getSubWizard(_context: IAppServiceWizardContext): Promise<IWizardOptions<IAppServiceWizardContext> | undefined> {
public async getSubWizard(_context: IFunctionAppWizardContext): Promise<IWizardOptions<IFunctionAppWizardContext> | undefined> {
return { promptSteps: [new AppServicePlanListStep()] };
}
}
export function setConsumptionPlanProperties(context: IAppServiceWizardContext): void {
export function setConsumptionPlanProperties(context: IFunctionAppWizardContext): void {
context.newPlanName = `ASP-${nonNullProp(context, 'newSiteName')}-${getRandomHexString(4)}`;
context.newPlanSku = { name: 'Y1', tier: 'Dynamic', size: 'Y1', family: 'Y', capacity: 0 };
}

Просмотреть файл

@ -29,6 +29,8 @@ export interface IFunctionAppWizardContext extends IAppServiceWizardContext, ICr
hasAzureStorageConnection?: boolean;
hasEventHubsConnection?: boolean;
hasSqlDbConnection?: boolean;
}
export interface IFunctionAppAgentWizardContext extends IFunctionAppWizardContext {
ui: IAzureAgentInput;
}

Просмотреть файл

@ -118,6 +118,16 @@ export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
await detectDockerfile(context);
if (context.dockerfilePath) {
const containerizedfunctionAppWizard = await createContainerizedFunctionAppWizard();
promptSteps.push(...containerizedfunctionAppWizard.promptSteps);
executeSteps.push(...containerizedfunctionAppWizard.executeSteps);
} else {
const functionAppWizard = await createFunctionAppWizard(wizardContext);
promptSteps.push(...functionAppWizard.promptSteps);
executeSteps.push(...functionAppWizard.executeSteps);
}
if (!wizardContext.advancedCreation) {
LocationListStep.addStep(wizardContext, promptSteps);
wizardContext.useConsumptionPlan = true;
@ -152,15 +162,6 @@ export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
promptSteps.push(new AppInsightsListStep());
}
if (context.dockerfilePath) {
const containerizedfunctionAppWizard = await createContainerizedFunctionAppWizard();
promptSteps.push(...containerizedfunctionAppWizard.promptSteps);
executeSteps.push(...containerizedfunctionAppWizard.executeSteps);
} else {
const functionAppWizard = await createFunctionAppWizard(wizardContext);
promptSteps.push(...functionAppWizard.promptSteps);
executeSteps.push(...functionAppWizard.executeSteps);
}
const storageProvider = 'Microsoft.Storage';
LocationListStep.addProviderForFiltering(wizardContext, storageProvider, 'storageAccounts');