diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py b/src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py index ebe33d91bbe..5511d71e473 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py @@ -10,16 +10,16 @@ from collections import defaultdict -def get_postgres_location_capability_info(cmd, location): +def get_postgres_location_capability_info(cmd, location, is_offer_restriction_check_required=False): list_location_capability_client = cf_postgres_flexible_location_capabilities(cmd.cli_ctx, '_') list_location_capability_result = list_location_capability_client.execute(location) - return _postgres_parse_list_capability(list_location_capability_result) + return _postgres_parse_list_capability(list_location_capability_result, is_offer_restriction_check_required) -def get_postgres_server_capability_info(cmd, resource_group, server_name): +def get_postgres_server_capability_info(cmd, resource_group, server_name, is_offer_restriction_check_required=False): list_server_capability_client = cf_postgres_flexible_server_capabilities(cmd.cli_ctx, '_') list_server_capability_result = list_server_capability_client.list(resource_group_name=resource_group, server_name=server_name) - return _postgres_parse_list_capability(list_server_capability_result) + return _postgres_parse_list_capability(list_server_capability_result, is_offer_restriction_check_required) def get_performance_tiers_for_storage(storage_edition, storage_size): @@ -41,7 +41,8 @@ def get_performance_tiers(storage_edition): return performance_tiers -def _postgres_parse_list_capability(result): +# pylint: disable=too-many-locals +def _postgres_parse_list_capability(result, is_offer_restriction_check_required=False): result = _get_list_from_paged_response(result) if not result: @@ -54,10 +55,10 @@ def _postgres_parse_list_capability(result): geo_backup = [feature for feature in supported_features if feature.name == "GeoBackup"] index_tuning = [feature for feature in supported_features if feature.name == "IndexTuning"] - if restricted == "Enabled": + if restricted == "Enabled" and not is_offer_restriction_check_required: raise InvalidArgumentValueError("The location is restricted for provisioning of flexible servers. Please try using another region.") - if restricted != "Disabled": + if restricted != "Disabled" and not is_offer_restriction_check_required: raise InvalidArgumentValueError("No available SKUs in this location.") single_az = zone_redundant[0].status != "Enabled" if zone_redundant else True diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py index 05c4a828418..128690231a9 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py @@ -1673,7 +1673,7 @@ def index_tuning_update(cmd, client, resource_group_name, server_name, index_tun postgres_source_client = get_postgresql_flexible_management_client(cmd.cli_ctx, subscription) source_server_object = postgres_source_client.servers.get(resource_group_name, server_name) location = ''.join(source_server_object.location.lower().split()) - list_location_capability_info = get_postgres_location_capability_info(cmd, location) + list_location_capability_info = get_postgres_location_capability_info(cmd, location, is_offer_restriction_check_required=True) index_tuning_supported = list_location_capability_info['index_tuning_supported'] if not index_tuning_supported: raise CLIError("Index tuning is not supported for the server.")