mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-16 20:08:09 +00:00
handle issue from azure-mgmt-resource 17.0.0 upgrade (#893)
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
@ -130,7 +131,19 @@ def get_scaleset_principal_id() -> UUID:
|
|||||||
credential=get_identity(), subscription_id=get_subscription()
|
credential=get_identity(), subscription_id=get_subscription()
|
||||||
)
|
)
|
||||||
uid = client.resources.get_by_id(get_scaleset_identity_resource_path(), api_version)
|
uid = client.resources.get_by_id(get_scaleset_identity_resource_path(), api_version)
|
||||||
return UUID(uid.properties["principalId"])
|
|
||||||
|
# workaround issue from azure-mgmt-resource, where properties is now a str
|
||||||
|
# instead of an obj.
|
||||||
|
# https://github.com/Azure/azure-sdk-for-python/pull/18686/files
|
||||||
|
if isinstance(uid.properties, str):
|
||||||
|
as_str = uid.properties
|
||||||
|
if as_str.startswith("{'"):
|
||||||
|
as_str = as_str.replace("'", '"')
|
||||||
|
prop = json.loads(as_str)
|
||||||
|
else:
|
||||||
|
prop = uid.properties
|
||||||
|
|
||||||
|
return UUID(prop["principalId"])
|
||||||
|
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
|
Reference in New Issue
Block a user