Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def default_api_version(self):
ResourceType.MGMT_EVENTHUB: None,
ResourceType.MGMT_MONITOR: None,
ResourceType.MGMT_MSI: '2024-11-30',
ResourceType.MGMT_APPSERVICE: '2024-11-01',
ResourceType.MGMT_APPSERVICE: None,
ResourceType.MGMT_IOTHUB: None,
ResourceType.MGMT_IOTDPS: None,
ResourceType.MGMT_IOTCENTRAL: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,10 @@ def set_location(cmd, sku, location):

def get_site_availability(cmd, name):
""" This is used by az webapp up to verify if a site needs to be created or should just be deployed"""
from azure.mgmt.web.models import ResourceNameAvailabilityRequest
client = web_client_factory(cmd.cli_ctx)
availability = client.check_name_availability(name, 'Site')
request = ResourceNameAvailabilityRequest(name=name, type='Site')
availability = client.check_name_availability(request)

# check for "." in app name. it is valid for hostnames to contain it, but not allowed for webapp names
if "." in name:
Expand All @@ -342,12 +344,15 @@ def get_site_availability(cmd, name):
def get_regional_site_availability(cmd, location, name, resource_group_name, auto_generated_domain_name_label_scope):
""" This is used by az webapp up to verify if a site needs to be created or should just be deployed
(regional check)"""
from azure.mgmt.web.models import ResourceNameAvailabilityRequest
client = web_client_factory(cmd.cli_ctx)
availability = client.regional_check_name_availability(location,
name,
"Site",
resource_group_name,
auto_generated_domain_name_label_scope)
# Note: In azure-mgmt-web 11.0.0+, resource_group_name and auto_generated_domain_name_label_scope
# are no longer supported parameters for ResourceNameAvailabilityRequest
request = ResourceNameAvailabilityRequest(
name=name,
type="Site"
)
availability = client.regional_check_name_availability(location, request)

# check for "." in app name. it is valid for hostnames to contain it, but not allowed for webapp names
if "." in name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ def _get_app_region_and_plan_sku(cmd, resource_group_name, webapp_name):
try:
from ._client_factory import web_client_factory
from azure.mgmt.core.tools import parse_resource_id
from .utils import get_site_server_farm_id
client = web_client_factory(cmd.cli_ctx)
app = client.web_apps.get(resource_group_name, webapp_name)
region = app.location if app else "Unknown"
sku = "Unknown"
if app and app.server_farm_id:
plan_parts = parse_resource_id(app.server_farm_id)
server_farm_id = get_site_server_farm_id(app) if app else None
if app and server_farm_id:
plan_parts = parse_resource_id(server_farm_id)
plan = client.app_service_plans.get(plan_parts['resource_group'], plan_parts['name'])
if plan and plan.sku:
sku = plan.sku.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ._client_factory import web_client_factory
from .utils import (_normalize_sku, get_sku_tier, get_resource_name_and_group,
get_resource_if_exists, is_functionapp, is_logicapp, is_webapp, is_centauri_functionapp,
_normalize_location)
_normalize_location, get_site_server_farm_id)

from .aaz.latest.network import ListServiceTags
from .aaz.latest.network.vnet import List as VNetList, Show as VNetShow
Expand Down Expand Up @@ -82,10 +82,12 @@ def validate_site_create(cmd, namespace):

def validate_ase_create(cmd, namespace):
# Validate the ASE Name availability
from azure.mgmt.web.models import ResourceNameAvailabilityRequest
client = web_client_factory(cmd.cli_ctx)
resource_type = 'Microsoft.Web/hostingEnvironments'
if isinstance(namespace.name, str):
name_validation = client.check_name_availability(namespace.name, resource_type)
request = ResourceNameAvailabilityRequest(name=namespace.name, type=resource_type)
name_validation = client.check_name_availability(request)
if not name_validation.name_available:
raise ValidationError(name_validation.message)

Expand Down Expand Up @@ -175,9 +177,10 @@ def validate_functionapp_on_flex_plan(cmd, namespace):
resource_group_name = namespace.resource_group_name
name = _get_app_name(namespace)
functionapp = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get')
if functionapp.server_farm_id is None:
server_farm_id = get_site_server_farm_id(functionapp)
if server_farm_id is None:
return
parsed_plan_id = parse_resource_id(functionapp.server_farm_id)
parsed_plan_id = parse_resource_id(server_farm_id)
client = web_client_factory(cmd.cli_ctx)
plan_info = client.app_service_plans.get(parsed_plan_id['resource_group'], parsed_plan_id['name'])
if plan_info is None:
Expand All @@ -191,9 +194,10 @@ def validate_is_flex_functionapp(cmd, namespace):
resource_group_name = namespace.resource_group_name
name = namespace.name
functionapp = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get')
if functionapp.server_farm_id is None:
server_farm_id = get_site_server_farm_id(functionapp)
if server_farm_id is None:
raise ValidationError('This command is only valid for Azure Functions on the FlexConsumption plan.')
parsed_plan_id = parse_resource_id(functionapp.server_farm_id)
parsed_plan_id = parse_resource_id(server_farm_id)
client = web_client_factory(cmd.cli_ctx)
plan_info = client.app_service_plans.get(parsed_plan_id['resource_group'], parsed_plan_id['name'])
if plan_info is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

def show_webapp_access_restrictions(cmd, resource_group_name, name, slot=None):
configs = get_site_configs(cmd, resource_group_name, name, slot)
access_restrictions = [r.serialize() for r in (configs.ip_security_restrictions or [])]
scm_access_restrictions = [r.serialize() for r in (configs.scm_ip_security_restrictions or [])]
access_restrictions = [r.as_dict() for r in (configs.ip_security_restrictions or [])]
scm_access_restrictions = [r.as_dict() for r in (configs.scm_ip_security_restrictions or [])]
access_rules = {
"scmIpSecurityRestrictionsUseMain": configs.scm_ip_security_restrictions_use_main,
"ipSecurityRestrictionsDefaultAction": configs.ip_security_restrictions_default_action,
Expand Down
Loading
Loading