Fix Deployment ARM Id Parse Error
@@ -213,13 +213,22 @@ class AzureResourceId:
"""
REGEX_PATTERN = "^/?subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/Microsoft.([^/]+)/([^/]+)/([^/]+)"
+ RESOURCEGROUP_PATTERN = "^/?subscriptions/([^/]+)/providers/Microsoft.([^/]+)/([^/]+)/([^/]+)"
def __init__(self, arm_id=None):
if arm_id:
match = re.match(AzureResourceId.REGEX_PATTERN, arm_id)
+ rg_match = re.match(AzureResourceId.RESOURCEGROUP_PATTERN, arm_id)
if match:
- self.asset_name = match.group(5)
+ self.subscription_id = match.group(1)
+ self.resource_group_name = match.group(2)
self.asset_type = match.group(4)
+ self.asset_name = match.group(5)
+ elif rg_match:
+ self.subscription_id = rg_match.group(1)
+ self.resource_group_name = None
+ self.asset_name = rg_match.group(4)
+ self.asset_type = rg_match.group(3)
else:
msg = "Invalid ARM Id {}"
raise ValidationException(
@@ -230,9 +239,6 @@ class AzureResourceId:
target=ErrorTarget.ARM_RESOURCE,
)
- self.subscription_id = match.group(1)
- self.resource_group_name = match.group(2)
-
def _parse_endpoint_name_from_deployment_id(deployment_id: str) -> str:
REGEX_PATTERN = (
