Skip to content

Commit 6bf6008

Browse files
Initial code to add support for --managed-instance-enabled
1 parent c3be90f commit 6bf6008

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def load_arguments(self, _):
102102
help='get regions which support hosting web apps on Windows Container workers')
103103
c.argument('linux_workers_enabled', action='store_true',
104104
help='get regions which support hosting web apps on Linux workers')
105+
c.argument('managed_instance_enabled', action='store_true',
106+
help='get regions which support hosting web apps on Managed Instance workers')
105107
c.argument('sku', arg_type=sku_arg_type)
106108

107109
with self.argument_context('appservice plan') as c:

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
get_resource_if_exists, repo_url_to_name, get_token,
7575
app_service_plan_exists, is_centauri_functionapp, is_flex_functionapp,
7676
_remove_list_duplicates, get_raw_functionapp,
77-
register_app_provider)
77+
register_app_provider,
78+
is_sku_tier_enabled_for_managed_instance)
7879
from ._create_util import (zip_contents_from_dir, get_runtime_version_details, create_resource_group, get_app_details,
7980
check_resource_group_exists, set_location, get_site_availability,
8081
get_regional_site_availability, get_profile_username,
@@ -8125,13 +8126,19 @@ def list_flexconsumption_zone_redundant_locations(cmd):
81258126
return [{'name': x.name.lower().replace(' ', '')} for x in regions]
81268127

81278128

8128-
def list_locations(cmd, sku, linux_workers_enabled=None, hyperv_workers_enabled=None):
8129+
def list_locations(cmd, sku, linux_workers_enabled=None, hyperv_workers_enabled=None, managed_instance_enabled=None):
81298130
web_client = web_client_factory(cmd.cli_ctx)
81308131
full_sku = get_sku_tier(sku)
8131-
# Temporary fix due to regression in this specific API with 2021-03-01, should be removed with the next SDK update
8132-
web_client_geo_regions = web_client.list_geo_regions(sku=full_sku,
8133-
linux_workers_enabled=linux_workers_enabled,
8134-
xenon_workers_enabled=hyperv_workers_enabled)
8132+
8133+
if managed_instance_enabled:
8134+
# managed_instance_enabled needs to be specially handled due to requiring version 2025-03-01
8135+
# and due to additional validation needed for SKU
8136+
web_client_geo_regions = _list_managed_instance_locations(cmd, full_sku)
8137+
else:
8138+
# Temporary fix due to regression in this specific API with 2021-03-01, should be removed with the next SDK update
8139+
web_client_geo_regions = web_client.list_geo_regions(sku=full_sku,
8140+
linux_workers_enabled=linux_workers_enabled,
8141+
xenon_workers_enabled=hyperv_workers_enabled)
81358142

81368143
providers_client = providers_client_factory(cmd.cli_ctx)
81378144
providers_client_locations_list = getattr(providers_client.get('Microsoft.Web'), 'resource_types', [])
@@ -8143,6 +8150,11 @@ def list_locations(cmd, sku, linux_workers_enabled=None, hyperv_workers_enabled=
81438150
return [geo_region for geo_region in web_client_geo_regions if geo_region.name in providers_client_locations_list]
81448151

81458152

8153+
def _list_managed_instance_locations(cmd, sku_tier):
8154+
if not is_sku_tier_enabled_for_managed_instance(sku_tier):
8155+
return []
8156+
8157+
81468158
def _check_zip_deployment_status(cmd, rg_name, name, deployment_status_url, slot, timeout=None):
81478159
import requests
81488160
from azure.cli.core.util import should_disable_connection_verify

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ def get_sku_name(tier):
109109
return get_sku_tier(name=tier)
110110

111111

112+
def is_sku_tier_enabled_for_managed_instance(sku_tier):
113+
sku_tier = sku_tier.upper()
114+
enabled_skus = ['PREMIUMV4', 'PREMIUMMV4']
115+
return sku_tier in enabled_skus
116+
117+
112118
# resource is client.web_apps for webapps, client.app_service_plans for ASPs, etc.
113119
def get_resource_if_exists(resource, **kwargs):
114120
from azure.core.exceptions import ResourceNotFoundError as R

0 commit comments

Comments
 (0)