66import random
77import uuid
88
9- from azure .ai .ml ._azure_environments import _get_base_url_from_metadata
9+ from azure .ai .ml ._azure_environments import _get_base_url_from_metadata , _resource_to_scopes
1010from azure .ai .ml ._vendor .azure_resources ._resource_management_client import ResourceManagementClient
1111from azure .ai .ml ._vendor .azure_resources .models import GenericResource
1212from azure .ai .ml .constants ._common import ArmConstants
@@ -31,11 +31,13 @@ def get_deployment_name(name: str):
3131
3232
3333def get_resource_group_location (credentials : TokenCredential , subscription_id : str , resource_group_name : str ) -> str :
34+ arm_hostname = _get_base_url_from_metadata ()
3435 client = ResourceManagementClient (
3536 credential = credentials ,
3637 subscription_id = subscription_id ,
37- base_url = _get_base_url_from_metadata () ,
38+ base_url = arm_hostname ,
3839 api_version = ArmConstants .AZURE_MGMT_RESOURCE_API_VERSION ,
40+ credential_scopes = _resource_to_scopes (arm_hostname ),
3941 )
4042 rg = client .resource_groups .get (resource_group_name )
4143 return rg .location
@@ -48,11 +50,13 @@ def get_generic_arm_resource_by_arm_id(
4850 api_version : str ,
4951) -> GenericResource :
5052 if arm_id :
53+ arm_hostname = _get_base_url_from_metadata ()
5154 client = ResourceManagementClient (
5255 credential = credentials ,
5356 subscription_id = subscription_id ,
54- base_url = _get_base_url_from_metadata () ,
57+ base_url = arm_hostname ,
5558 api_version = ArmConstants .AZURE_MGMT_RESOURCE_API_VERSION ,
59+ credential_scopes = _resource_to_scopes (arm_hostname ),
5660 )
5761 return client .resources .get_by_id (arm_id , api_version )
5862 return None
@@ -65,11 +69,13 @@ def delete_resource_by_arm_id(
6569 api_version : str ,
6670) -> None :
6771 if arm_id :
72+ arm_hostname = _get_base_url_from_metadata ()
6873 client = ResourceManagementClient (
6974 credential = credentials ,
7075 subscription_id = subscription_id ,
71- base_url = _get_base_url_from_metadata () ,
76+ base_url = arm_hostname ,
7277 api_version = ArmConstants .AZURE_MGMT_RESOURCE_API_VERSION ,
78+ credential_scopes = _resource_to_scopes (arm_hostname ),
7379 )
7480 client .resources .begin_delete_by_id (arm_id , api_version )
7581
0 commit comments