Python용 Azure 권한 부여 라이브러리

관리 API

pip install azure-mgmt-authorization

관리 클라이언트 만들기

다음 코드는 관리 클라이언트의 인스턴스를 만듭니다.

구독 목록에서 검색할 수 있는 를 제공해야 subscription_id 합니다.

Python SDK를 사용하여 Azure Active Directory 인증을 처리하고 Credentials 인스턴스를 만드는 방법에 대한 자세한 내용은 리소스 관리 인증을 참조하세요.

from azure.mgmt.authorization import AuthorizationManagementClient
from azure.common.credentials import UserPassCredentials

# Replace this with your subscription id
subscription_id = '33333333-3333-3333-3333-333333333333'

# See above for details on creating different types of AAD credentials
credentials = UserPassCredentials(
    'user@domain.com',	# Your user
    'my_password' 		# Your password
)

authorization_client = AuthorizationManagementClient(
    credentials,
    subscription_id
)

리소스 그룹의 사용 권한 확인

다음 코드는 지정된 리소스 그룹에서 사용 권한을 확인합니다. 리소스 그룹을 만들거나 관리하려면 리소스 관리를 참조하세요.

from azure.mgmt.redis.models import Sku, RedisCreateOrUpdateParameters

group_name = 'myresourcegroup'
permissions = self.authorization_client.permissions.list_for_resource_group(
    group_name
)
# permissions is a iterable of Permissions instances