@@ -8,23 +8,41 @@ import { createHttpHeaders, createPipelineRequest } from '@azure/core-rest-pipel
88import { setLocationsTask , WebsiteOS , type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice' ;
99import { createGenericClient , LocationListStep , type AzExtPipelineResponse , type AzExtRequestPrepareOptions } from '@microsoft/vscode-azext-azureutils' ;
1010import { AzureWizardPromptStep , type IAzureQuickPickItem } from '@microsoft/vscode-azext-utils' ;
11- import { DurableBackend } from '../../constants' ;
1211import { localize } from '../../localize' ;
1312import { getRandomHexString } from '../../utils/fs' ;
1413import { nonNullProp } from '../../utils/nonNull' ;
1514import { type IFunctionAppWizardContext } from './IFunctionAppWizardContext' ;
1615
17- const premiumSkuFilter = / ^ E P $ / i;
16+ export enum FunctionAppHostingPlans {
17+ Flex ,
18+ Consumption ,
19+ Premium ,
20+ AppService ,
21+ }
22+
23+ export const allAvailableFunctionAppHostingPlans = new Set ( [ FunctionAppHostingPlans . Flex , FunctionAppHostingPlans . Consumption , FunctionAppHostingPlans . Premium , FunctionAppHostingPlans . AppService ] ) ;
24+
1825export class FunctionAppHostingPlanStep extends AzureWizardPromptStep < IFunctionAppWizardContext > {
26+ constructor ( private readonly availablePlans : Set < FunctionAppHostingPlans > ) {
27+ super ( ) ;
28+ }
29+
1930 public async prompt ( context : IFunctionAppWizardContext ) : Promise < void > {
20- const placeHolder : string = localize ( 'selectHostingPlan' , 'Select a hosting plan.' ) ;
21- const picks : IAzureQuickPickItem < [ boolean , boolean , RegExp | undefined ] > [ ] = [
22- { label : localize ( 'flexConsumption' , 'Flex Consumption' ) , data : [ false , true , undefined ] } ,
23- { label : localize ( 'consumption' , 'Consumption' ) , description : localize ( 'legacy' , 'Legacy' ) , data : [ true , false , undefined ] } ,
24- { label : localize ( 'premium' , 'Premium' ) , data : [ false , false , premiumSkuFilter ] } ,
25- { label : localize ( 'dedicated' , 'App Service Plan' ) , data : [ false , false , / ^ ( (? ! E P | Y | F C ) .) * $ / i] }
26- ] ;
31+ const picks : IAzureQuickPickItem < [ boolean , boolean , RegExp | undefined ] > [ ] = [ ] ;
32+ if ( this . availablePlans . has ( FunctionAppHostingPlans . Flex ) ) {
33+ picks . push ( { label : localize ( 'flexConsumption' , 'Flex Consumption' ) , data : [ false , true , undefined ] } ) ;
34+ }
35+ if ( this . availablePlans . has ( FunctionAppHostingPlans . Consumption ) ) {
36+ picks . push ( { label : localize ( 'consumption' , 'Consumption' ) , description : localize ( 'legacy' , 'Legacy' ) , data : [ true , false , undefined ] } ) ;
37+ }
38+ if ( this . availablePlans . has ( FunctionAppHostingPlans . Premium ) ) {
39+ picks . push ( { label : localize ( 'premium' , 'Premium' ) , data : [ false , false , / ^ E P $ / i] } ) ;
40+ }
41+ if ( this . availablePlans . has ( FunctionAppHostingPlans . AppService ) ) {
42+ picks . push ( { label : localize ( 'dedicated' , 'App Service Plan' ) , data : [ false , false , / ^ ( (? ! E P | Y | F C ) .) * $ / i] } ) ;
43+ }
2744
45+ const placeHolder : string = localize ( 'selectHostingPlan' , 'Select a hosting plan.' ) ;
2846 [ context . useConsumptionPlan , context . useFlexConsumptionPlan , context . planSkuFamilyFilter ] = ( await context . ui . showQuickPick ( picks , { placeHolder, learnMoreLink : 'aka.ms/flexconsumption' } ) ) . data ;
2947 await setLocationsTask ( context ) ;
3048 if ( context . useConsumptionPlan ) {
@@ -39,15 +57,7 @@ export class FunctionAppHostingPlanStep extends AzureWizardPromptStep<IFunctionA
3957 }
4058
4159 public configureBeforePrompt ( context : IFunctionAppWizardContext ) : void | Promise < void > {
42- if ( context . durableStorageType === DurableBackend . DTS ) {
43- // premium is required for DTS
44- if ( context . advancedCreation ) {
45- // allows users to select/create a Elastic Premium plan
46- context . planSkuFamilyFilter = premiumSkuFilter ;
47- } else {
48- setPremiumPlanProperties ( context ) ;
49- }
50- } else if ( context . useFlexConsumptionPlan ) {
60+ if ( context . useFlexConsumptionPlan ) {
5161 setFlexConsumptionPlanProperties ( context ) ;
5262 }
5363 }
@@ -66,16 +76,6 @@ function setFlexConsumptionPlanProperties(context: IAppServiceWizardContext): vo
6676 LocationListStep . setLocationSubset ( context , getFlexLocations ( context ) , 'Microsoft.WebFlex' ) ;
6777}
6878
69- function setPremiumPlanProperties ( context : IAppServiceWizardContext ) : void {
70- context . newPlanName = `PREMIUM-${ nonNullProp ( context , 'newSiteName' ) } -${ getRandomHexString ( 4 ) } ` ;
71- context . newPlanSku = {
72- name : 'P1v2' ,
73- tier : 'Premium V2' ,
74- size : 'P1v2' ,
75- family : 'Pv2'
76- } ;
77- }
78-
7979async function getFlexLocations ( context : IAppServiceWizardContext ) : Promise < string [ ] > {
8080 const headers = createHttpHeaders ( {
8181 'Content-Type' : 'application/json' ,
0 commit comments