Skip to content

Commit 30f50ae

Browse files
committed
Update location capabilites feature support checks
1 parent 11384b7 commit 30f50ae

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ def _postgres_parse_list_capability(result):
4646
if not result:
4747
raise InvalidArgumentValueError("No available SKUs in this location")
4848

49-
offer_restricted = [feature for feature in result[0].supported_features if feature.name == "OfferRestricted"]
49+
supported_features = result[0].supported_features if result[0].supported_features is not None else []
50+
offer_restricted = [feature for feature in supported_features if feature.name == "OfferRestricted"]
51+
restricted = offer_restricted[0].status if offer_restricted else None
52+
zone_redundant = [feature for feature in supported_features if feature.name == "ZoneRedundantHa"]
53+
geo_backup = [feature for feature in supported_features if feature.name == "GeoBackup"]
5054

51-
if offer_restricted[0].status == "Enabled":
55+
if restricted == "Enabled":
5256
raise InvalidArgumentValueError("The location is restricted for provisioning of flexible servers. Please try using another region.")
5357

54-
if offer_restricted[0].status != "Disabled":
58+
if restricted != "Disabled":
5559
raise InvalidArgumentValueError("No available SKUs in this location.")
5660

57-
single_az = result[0].zone_redundant_ha_supported != "Enabled"
58-
geo_backup_supported = result[0].geo_backup_supported == "Enabled"
61+
single_az = zone_redundant[0].status != "Enabled" if zone_redundant else True
62+
geo_backup_supported = geo_backup[0].status == "Enabled" if geo_backup else False
5963

6064
tiers = result[0].supported_server_editions
6165
tiers_dict = {}

0 commit comments

Comments
 (0)