@@ -1810,13 +1810,19 @@ def list_function_app_runtimes(cmd, os_type=None):
18101810 return {WINDOWS_OS_NAME : windows_stacks , LINUX_OS_NAME : linux_stacks }
18111811
18121812
1813- def list_flex_function_app_runtimes (cmd , location , runtime ):
1814- runtime_helper = _FlexFunctionAppStackRuntimeHelper (cmd , location , runtime )
1815- runtimes = [r for r in runtime_helper .stacks if runtime == r .name ]
1816- if not runtimes :
1817- raise ValidationError ("Runtime '{}' not supported for function apps on the Flex Consumption plan."
1818- .format (runtime ))
1819- return runtimes
1813+ def list_flex_function_app_runtimes (cmd , location , runtime , ignore_error = False ):
1814+ try :
1815+ runtime_helper = _FlexFunctionAppStackRuntimeHelper (cmd , location , runtime )
1816+ runtimes = [r for r in runtime_helper .stacks if runtime == r .name ]
1817+ if not runtimes :
1818+ raise ValidationError ("Runtime '{}' not supported for function apps on the Flex Consumption plan."
1819+ .format (runtime ))
1820+ return runtime_helper .stacks
1821+ except Exception as e :
1822+ if ignore_error :
1823+ return []
1824+ else :
1825+ raise # Rethrow the caught exception
18201826
18211827
18221828def delete_logic_app (cmd , resource_group_name , name , slot = None ):
@@ -4576,7 +4582,7 @@ def stacks(self):
45764582
45774583 def get_flex_raw_function_app_stacks (self , cmd , location , runtime ):
45784584 stacks_api_url = '/providers/Microsoft.Web/locations/{}/functionAppStacks?' \
4579- 'api-version=2020-10 -01&removeHiddenStacks=true&removeDeprecatedStacks=true&stack={}'
4585+ 'api-version=2023-12 -01&removeHiddenStacks=true&removeDeprecatedStacks=true&stack={}'
45804586 if runtime == "dotnet-isolated" :
45814587 runtime = "dotnet"
45824588 request_url = cmd .cli_ctx .cloud .endpoints .resource_manager + stacks_api_url .format (location , runtime )
@@ -5125,13 +5131,6 @@ def is_exactly_one_true(*args):
51255131 return found
51265132
51275133
5128- def list_flexconsumption_zone_redundant_locations (cmd ):
5129- client = web_client_factory (cmd .cli_ctx )
5130- regions = client .list_geo_regions (sku = "FlexConsumption" )
5131- regions = [x for x in regions if "FCZONEREDUNDANCY" in x .org_domain ]
5132- return [{'name' : x .name .lower ().replace (' ' , '' )} for x in regions ]
5133-
5134-
51355134def create_functionapp (cmd , resource_group_name , name , storage_account , plan = None ,
51365135 os_type = None , functions_version = None , runtime = None , runtime_version = None ,
51375136 consumption_plan_location = None , app_insights = None , app_insights_key = None ,
@@ -6132,19 +6131,35 @@ def get_subscription_locations(cli_ctx):
61326131 return [item .name for item in result ]
61336132
61346133
6135- def list_flexconsumption_locations (cmd , zone_redundant = False ):
6134+ def list_flexconsumption_locations (cmd , zone_redundant = False , details = False , runtime = None ):
6135+ client = web_client_factory (cmd .cli_ctx )
6136+
6137+ if runtime and not details :
6138+ raise ArgumentUsageError (
6139+ '--runtime is only valid with --details parameter. '
6140+ 'Please try again without the --details parameter.' )
6141+
6142+ regions = client .list_geo_regions (sku = "FlexConsumption" )
6143+
61366144 if zone_redundant :
6137- return list_flexconsumption_zone_redundant_locations ( cmd )
6145+ regions = [ x for x in regions if "FCZONEREDUNDANCY" in x . org_domain ]
61386146
6139- from azure .cli .core .commands .client_factory import get_subscription_id
6140- sub_id = get_subscription_id (cmd .cli_ctx )
6141- geo_regions_api = 'subscriptions/{}/providers/Microsoft.Web/geoRegions?sku=FlexConsumption&api-version=2023-01-01'
6142- request_url = cmd .cli_ctx .cloud .endpoints .resource_manager + geo_regions_api .format (sub_id )
6143- flex_regions = send_raw_request (cmd .cli_ctx , "GET" , request_url ).json ()['value' ]
6144- flex_regions_list = [{'name' : x ['name' ].lower ().replace (' ' , '' )} for x in flex_regions ]
6145- sub_regions_list = get_subscription_locations (cmd .cli_ctx )
6146- return [x for x in flex_regions_list if x ['name' ] in sub_regions_list ]
6147+ regions = [x .name .lower ().replace (' ' , '' ) for x in regions ]
6148+ return [{x : list_flex_function_app_all_runtimes (cmd , x , "java" )} for x in regions ]
6149+
6150+
6151+ def list_flex_function_app_all_runtimes (cmd , location , runtime = None ):
6152+ runtimes = ["dotnet-isolated" , "node" , "python" , "java" , "powershell" ]
6153+ if runtime :
6154+ runtimes = [runtime ]
6155+
6156+ return [{x : list_flex_function_app_runtimes (cmd , location , x , True )} for x in runtimes ]
61476157
6158+ def list_flexconsumption_zone_redundant_locations (cmd ):
6159+ client = web_client_factory (cmd .cli_ctx )
6160+ regions = client .list_geo_regions (sku = "FlexConsumption" )
6161+ regions = [x for x in regions if "FCZONEREDUNDANCY" in x .org_domain ]
6162+ return [{'name' : x .name .lower ().replace (' ' , '' )} for x in regions ]
61486163
61496164def list_locations (cmd , sku , linux_workers_enabled = None , hyperv_workers_enabled = None ):
61506165 web_client = web_client_factory (cmd .cli_ctx )
0 commit comments