Skip to content

Commit 5422d0f

Browse files
authored
[App Service] az functionapp list-flexconsumption-locations: Check if flex region is enabled for subscription (#30607)
1 parent 7580cba commit 5422d0f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5709,6 +5709,13 @@ def list_consumption_locations(cmd):
57095709
return [{'name': x.name.lower().replace(' ', '')} for x in regions]
57105710

57115711

5712+
def get_subscription_locations(cli_ctx):
5713+
from azure.cli.core.commands.client_factory import get_subscription_service_client
5714+
subscription_client, subscription_id = get_subscription_service_client(cli_ctx)
5715+
result = list(subscription_client.subscriptions.list_locations(subscription_id))
5716+
return [item.name for item in result]
5717+
5718+
57125719
def list_flexconsumption_locations(cmd, zone_redundant=False):
57135720
if zone_redundant:
57145721
return list_flexconsumption_zone_redundant_locations(cmd)
@@ -5717,8 +5724,10 @@ def list_flexconsumption_locations(cmd, zone_redundant=False):
57175724
sub_id = get_subscription_id(cmd.cli_ctx)
57185725
geo_regions_api = 'subscriptions/{}/providers/Microsoft.Web/geoRegions?sku=FlexConsumption&api-version=2023-01-01'
57195726
request_url = cmd.cli_ctx.cloud.endpoints.resource_manager + geo_regions_api.format(sub_id)
5720-
regions = send_raw_request(cmd.cli_ctx, "GET", request_url).json()['value']
5721-
return [{'name': x['name'].lower().replace(' ', '')} for x in regions]
5727+
flex_regions = send_raw_request(cmd.cli_ctx, "GET", request_url).json()['value']
5728+
flex_regions_list = [{'name': x['name'].lower().replace(' ', '')} for x in flex_regions]
5729+
sub_regions_list = get_subscription_locations(cmd.cli_ctx)
5730+
return [x for x in flex_regions_list if x['name'] in sub_regions_list]
57225731

57235732

57245733
def list_locations(cmd, sku, linux_workers_enabled=None, hyperv_workers_enabled=None):

src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def test_functionapp_update_enabled_dapr(self, resource_group, storage_account):
777777
class FunctionAppFlex(LiveScenarioTest):
778778
def test_functionapp_list_flexconsumption_locations(self):
779779
locations = self.cmd('functionapp list-flexconsumption-locations').get_output_in_json()
780-
self.assertTrue(len(locations) == 13)
780+
self.assertTrue(len(locations) == 12)
781781

782782
def test_functionapp_list_flexconsumption_locations_zone_redundant(self):
783783
locations = self.cmd('functionapp list-flexconsumption-locations --zone-redundant').get_output_in_json()

0 commit comments

Comments
 (0)