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
23 changes: 11 additions & 12 deletions src/commands/createFunctionApp/FunctionAppHostingPlanStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,39 @@ import { type IFunctionAppWizardContext } from './IFunctionAppWizardContext';
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('flexConsumption', 'Flex Consumption'), data: [false, undefined] },
{ label: localize('consumption', 'Consumption'), data: [true, undefined] },
{ label: localize('premium', 'Premium'), data: [false, /^EP$/i] },
{ label: localize('dedicated', 'App Service Plan'), data: [false, /^((?!EP|Y|FC).)*$/i] }
const picks: IAzureQuickPickItem<[boolean, boolean, RegExp | undefined]>[] = [
{ label: localize('flexConsumption', 'Flex Consumption'), data: [false, true, undefined] },
{ label: localize('consumption', 'Linux Consumption'), description: localize('legacy', 'Legacy'), data: [true, false, undefined] },
{ label: localize('premium', 'Premium'), data: [false, false, /^EP$/i] },
{ label: localize('dedicated', 'App Service Plan'), data: [false, false, /^((?!EP|Y|FC).)*$/i] }
];

[context.useConsumptionPlan, context.planSkuFamilyFilter] = (await context.ui.showQuickPick(picks, { placeHolder })).data;
[context.useConsumptionPlan, context.useFlexConsumptionPlan, context.planSkuFamilyFilter] = (await context.ui.showQuickPick(picks, { placeHolder, learnMoreLink: 'aka.ms/flexconsumption' })).data;
await setLocationsTask(context);
if (context.useConsumptionPlan) {
setConsumptionPlanProperties(context);
} else if (!context.useConsumptionPlan && !context.planSkuFamilyFilter) {
// if it's not consumption and has no filter, then it's flex consumption
} else if (context.useFlexConsumptionPlan) {
setFlexConsumptionPlanProperties(context);
}
}

public shouldPrompt(context: IFunctionAppWizardContext): boolean {
return context.useConsumptionPlan === undefined && context.dockerfilePath === undefined;
return context.useFlexConsumptionPlan === undefined && context.dockerfilePath === undefined;
}

public configureBeforePrompt(context: IFunctionAppWizardContext): void | Promise<void> {
if (!context.advancedCreation) {
if (context.useFlexConsumptionPlan) {
setFlexConsumptionPlanProperties(context);
}
}
}

export function setConsumptionPlanProperties(context: IFunctionAppWizardContext): void {
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 };
}

export function setFlexConsumptionPlanProperties(context: IAppServiceWizardContext): void {
function setFlexConsumptionPlanProperties(context: IAppServiceWizardContext): void {
context.newPlanName = `FLEX-${nonNullProp(context, 'newSiteName')}-${getRandomHexString(4)}`;
context.newPlanSku = { name: 'FC1', tier: 'FlexConsumption', size: 'FC', family: 'FC' };
// flex consumption only supports linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IFunctionAppWizardContext extends IAppServiceWizardContext, ICr
stackFilter?: string;
newSiteStack?: FullFunctionAppStack;
durableStorageType?: DurableBackendValues;
useFlexConsumptionPlan?: boolean;

// Detected local connection string
hasAzureStorageConnection?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function createCreateFunctionAppComponents(context: ICreateFunction

if (!wizardContext.advancedCreation) {
LocationListStep.addStep(wizardContext, promptSteps);
wizardContext.useConsumptionPlan = true;
wizardContext.useFlexConsumptionPlan = true;
wizardContext.stackFilter = getRootFunctionsWorkerRuntime(wizardContext.language);
promptSteps.push(new ConfigureCommonNamesStep());
executeSteps.push(new ResourceGroupCreateStep());
Expand Down