Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/zones/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.0b3
++++++
* Minor bugfixes to improve command loading

1.0.0b2
++++++
* Minor bugfixes to improve command loading
Expand Down
5 changes: 5 additions & 0 deletions src/zones/azext_zones/resource_type_validators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""Validators for resource types supported by Zones"""
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.apimanagement")
class microsoft_apimanagement:
@staticmethod
Expand All @@ -33,7 +34,6 @@ def validate(resource):
zones = resource.get("zones") or []
if len(zones) > 1 and resource["sku"]["name"] == "Premium":
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.app")
class microsoft_app:
@staticmethod
Expand All @@ -32,7 +33,6 @@ def validate(resource):
# https://learn.microsoft.com/azure/reliability/reliability-azure-container-apps#availability-zone-support
if resource["properties"].get("zoneRedundant", {}) is True:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.authorization")
class microsoft_authorization:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.automation")
class microsoft_automation:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.botservice")
class microsoft_botservice:
@staticmethod
Expand All @@ -32,8 +33,8 @@ def validate(resource):
"Your bot service resource in westeurope may be zone redundant, \
but only if it's configured as a regional (not global) bot. Please check manually."
)
else:
# Bot services cannot be ZR in any other region
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.Unknown
# Bot services cannot be ZR in any other region
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.cache")
class microsoft_cache:
@staticmethod
Expand All @@ -27,15 +28,13 @@ def validate(resource):
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# Redis Enterprise
if resourceSubType == "redisenterprise":
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.cdn")
class microsoft_cdn:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.chaos")
class microsoft_chaos:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods,too-many-return-statements
@register_resource_type("microsoft.compute")
class microsoft_compute:
@staticmethod
Expand All @@ -25,26 +26,23 @@ def validate(resource):
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# VM ScaleSets
if resourceSubType == "virtualmachinescalesets":
# VMSS is ZR if deployed to more than one zone
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# Virtual Machines
if resourceSubType == "virtualmachines":
# VM is ZR if deployed to more than one zone
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# VM Extensions
if resourceSubType == "virtualmachines/extensions":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.containerinstance")
class microsoft_containerinstance:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.containerregistry")
class microsoft_containerregistry:
@staticmethod
Expand All @@ -28,14 +29,12 @@ def validate(resource):
# https://learn.microsoft.com/azure/container-registry/zone-redundancy
if resource["properties"]["zoneRedundancy"] == "Enabled":
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# Registry Regional Replications
if resourceSubType == "registries/replications":
if resource["properties"]["zoneRedundancy"] == "Enabled":
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.containerservice")
class microsoft_containerservice:
@staticmethod
Expand All @@ -32,10 +33,8 @@ def validate(resource):
or []
)
poolZoneCount = len(poolZones)
return (
ZoneRedundancyValidationResult.Yes
if poolZoneCount > 1
else ZoneRedundancyValidationResult.No
)
if poolZoneCount > 1:
return ZoneRedundancyValidationResult.Yes
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.dashboard")
class microsoft_dashboard:
@staticmethod
Expand All @@ -27,7 +28,6 @@ def validate(resource):
zr = resource.get("properties", {}).get("zoneRedundancy", "")
if zr == "Enabled":
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.dbformysql")
class microsoft_mysql:
@staticmethod
Expand All @@ -27,8 +28,7 @@ def validate(resource):
)
if haConfig == "ZoneRedundant":
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# Azure Database for MySQL Single Servers
if resourceSubType == "servers":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.dbforpostgresql")
class microsoft_dbforpostgresql:
@staticmethod
Expand All @@ -29,8 +30,7 @@ def validate(resource):
== "ZoneRedundant"
):
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# PostgreSQL Single Servers
if resourceSubType == "servers":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.documentdb")
class microsoft_documentdb:
@staticmethod
Expand All @@ -29,16 +30,14 @@ def validate(resource):
# setting enabled on the region
if resource["properties"]["locations"][0]["isZoneRedundant"]:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

# CosmosDB MongoDB API Accounts
if resourceSubType == "mongoClusters":
# https://learn.microsoft.com/azure/reliability/reliability-cosmos-mongodb#availability-zone-support
highAvailability = resource["properties"].get("highAvailability", "")
if highAvailability.get("targetMode", "") == "ZoneRedundantPreferred":
return ZoneRedundancyValidationResult.Yes
else:
ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.eventgrid")
class microsoft_eventgrid:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.eventhub")
class microsoft_eventhub:
@staticmethod
Expand All @@ -22,6 +23,7 @@ def validate(resource):
"Validating Microsoft.eventhub resource type: %s", resourceSubType
)

# If you create an Event Hubs namespace in a region that supports availability zones, zone redundancy is automatically enabled.
# If you create an Event Hubs namespace in a region that supports availability zones,
# zone redundancy is automatically enabled.
# https://learn.microsoft.com/azure/reliability/reliability-event-hubs#availability-zone-support
return ZoneRedundancyValidationResult.Always
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.hdinsight")
class microsoft_hdinsight:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.insights")
class microsoft_insights:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.iothub")
class microsoft_iothub:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.keyvault")
class microsoft_keyvault:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.kusto")
class microsoft_kusto:
@staticmethod
Expand All @@ -28,7 +29,6 @@ def validate(resource):
zones = resource.get("zones") or []
if len(zones) > 1:
return ZoneRedundancyValidationResult.Yes
else:
return ZoneRedundancyValidationResult.No
return ZoneRedundancyValidationResult.No

return ZoneRedundancyValidationResult.Unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.loadtestservice")
class microsoft_loadtestservice:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.machinelearningservices")
class microsoft_machinelearningservices:
@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from knack.log import get_logger


# pylint: disable=too-few-public-methods
@register_resource_type("microsoft.managedidentity")
class microsoft_managedidentity:
@staticmethod
Expand Down
Loading
Loading