빠른 시작: Python을 사용하여 Microsoft Purview(이전의 Azure Purview) 계정 만들기
참고
Microsoft Purview 데이터 카탈로그(클래식) 및 Data Health Insights(클래식)는 더 이상 새 고객을 이용하지 않으며 이러한 서비스(이전의 Azure Purview)는 이제 고객 지원 모드에 있습니다.
중요
테넌트당 하나의 Microsoft Purview 계정만 만들 수 있습니다. organization 이미 Microsoft Purview 계정이 있는 경우 organization 이미 여러 계정이 있고 기존 할당량 미만이 아니면 새 Microsoft Purview 계정을 만들 수 없습니다. 자세한 내용은 FAQ를 참조하세요.
이 빠른 시작에서는 Python을 사용하여 프로그래밍 방식으로 Microsoft Purview(이전의 Azure Purview) 계정을 만듭니다. Microsoft Purview에 대한 Python 참조 를 사용할 수 있지만 이 문서에서는 Python을 사용하여 계정을 만드는 데 필요한 모든 단계를 안내합니다.
Microsoft Purview 거버넌스 포털은 데이터 환경을 관리하고 관리하는 데 도움이 되는 Microsoft Purview 데이터 맵 및 Microsoft Purview 데이터 카탈로그 같은 도구를 제공합니다. 온-프레미스, 다중 클라우드 및 SaaS(Software-as-a-Service) 원본의 데이터에 연결하면 Microsoft Purview 데이터 맵 정보의 최신 맵을 만듭니다. 중요한 데이터를 식별하고 분류하며 엔드 투 엔드 Linage를 제공합니다. 데이터 소비자는 organization 전체에서 데이터를 검색할 수 있으며, 데이터 관리자는 데이터의 올바른 사용을 감사, 보안 및 보장할 수 있습니다.
Microsoft Purview의 클래식 거버넌스 기능에 대한 자세한 내용은 거버넌스 솔루션 개요 페이지를 참조하세요.
필수 구성 요소
Azure 구독이 없는 경우 시작하기 전에 무료 구독 을 만듭니다.
구독과 연결된 Microsoft Entra 테넌트입니다.
Azure에 로그인하는 데 사용하는 사용자 계정은 기여자 또는 소유자 역할의 구성원이거나 Azure 구독의 관리자여야 합니다. 구독에 있는 권한을 보려면 다음 단계를 수행합니다.
- Azure Portal
- 오른쪽 위 모서리에서 사용자 이름을 선택합니다.
- 더 많은 옵션을 보려면 줄임표 단추("...")를 선택합니다.
- 그런 다음 , 내 권한을 선택합니다.
- 여러 구독에 액세스할 수 있는 경우 적절한 구독을 선택합니다.
Azure에 로그인
Azure 계정으로 Azure Portal 로그인합니다.
Python 패키지 설치
관리자 권한으로 터미널 또는 명령 프롬프트를 엽니다.
먼저 Azure 관리 리소스용 Python 패키지를 설치합니다.
pip install azure-mgmt-resource
Microsoft Purview용 Python 패키지를 설치하려면 다음 명령을 실행합니다.
pip install azure-mgmt-purview
Microsoft Purview용 Python SDK는 Python 2.7, 3.3, 3.4, 3.5, 3.6 및 3.7을 지원합니다.
Azure ID 인증을 위한 Python 패키지를 설치하려면 다음 명령을 실행합니다.
pip install azure-identity
참고
"azure-identity" 패키지는 몇 가지 일반적인 종속성에서 "azure-cli"와 충돌할 수 있습니다. 인증 문제가 발생하는 경우 "azure-cli" 및 해당 종속성을 제거하거나 "azure-cli" 패키지를 설치하지 않고 클린 컴퓨터를 사용합니다.
purview 클라이언트 만들기
purview.py 파일을 만듭니다. 다음 문을 추가하여 네임스페이스에 대한 참조를 추가합니다.
from azure.identity import ClientSecretCredential from azure.mgmt.resource import ResourceManagementClient from azure.mgmt.purview import PurviewManagementClient from azure.mgmt.purview.models import * from datetime import datetime, timedelta import time
PurviewManagementClient 클래스의 instance 만드는 Main 메서드에 다음 코드를 추가합니다. 이 개체를 사용하여 purview 계정을 만들고, purview 계정을 삭제하고, 검사 이름 가용성 및 기타 리소스 공급자 작업을 수행합니다.
def main(): # Azure subscription ID subscription_id = '<subscription ID>' # This program creates this resource group. If it's an existing resource group, comment out the code that creates the resource group rg_name = '<resource group>' # The purview name. It must be globally unique. purview_name = '<purview account name>' # Location name, where Microsoft Purview account must be created. location = '<location name>' # Specify your Active Directory client ID, client secret, and tenant ID credentials = ClientSecretCredential(client_id='<service principal ID>', client_secret='<service principal key>', tenant_id='<tenant ID>') # resource_client = ResourceManagementClient(credentials, subscription_id) purview_client = PurviewManagementClient(credentials, subscription_id)
purview 계정 만들기
purview 계정을 만드는 Main 메서드에 다음 코드를 추가합니다. 리소스 그룹이 이미 있는 경우 첫 번째
create_or_update
문을 주석으로 처리합니다.# create the resource group # comment out if the resource group already exits resource_client.resource_groups.create_or_update(rg_name, rg_params) #Create a purview identity = Identity(type= "SystemAssigned") sku = AccountSku(name= 'Standard', capacity= 4) purview_resource = Account(identity=identity,sku=sku,location =location ) try: pa = (purview_client.accounts.begin_create_or_update(rg_name, purview_name, purview_resource)).result() print("location:", pa.location, " Microsoft Purview Account Name: ", pa.name, " Id: " , pa.id ," tags: " , pa.tags) except: print("Error") print_item(pa) while (getattr(pa,'provisioning_state')) != "Succeeded" : pa = (purview_client.accounts.get(rg_name, purview_name)) print(getattr(pa,'provisioning_state')) if getattr(pa,'provisioning_state') == "Failed" : print("Error in creating Microsoft Purview account") break time.sleep(30)
이제 다음 문을 추가하여 프로그램이 실행되면 기본 메서드를 호출합니다.
# Start the main method main()
전체 스크립트
전체 Python 코드는 다음과 같습니다.
from azure.identity import ClientSecretCredential
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.purview import PurviewManagementClient
from azure.mgmt.purview.models import *
from datetime import datetime, timedelta
import time
def main():
# Azure subscription ID
subscription_id = '<subscription ID>'
# This program creates this resource group. If it's an existing resource group, comment out the code that creates the resource group
rg_name = '<resource group>'
# The purview name. It must be globally unique.
purview_name = '<purview account name>'
# Location for your resource group and your Microsoft Purview account.
location ="<location>"
# Specify your Active Directory client ID, client secret, and tenant ID
credentials = ClientSecretCredential(client_id='<service principal ID>', client_secret='<service principal key>', tenant_id='<tenant ID>')
resource_client = ResourceManagementClient(credentials, subscription_id)
purview_client = PurviewManagementClient(credentials, subscription_id)
# create the resource group
# comment out if the resource group already exits
resource_client.resource_groups.create_or_update(rg_name, {"location": location})
#Create a purview
identity = Identity(type= "SystemAssigned")
sku = AccountSku(name= 'Standard', capacity= 4)
purview_resource = Account(identity=identity,sku=sku,location =location)
try:
pa = (purview_client.accounts.begin_create_or_update(rg_name, purview_name, purview_resource)).result()
print("location:", pa.location, " Microsoft Purview Account Name: ", purview_name, " Id: " , pa.id ," tags: " , pa.tags)
except:
print("Error in submitting job to create account")
print_item(pa)
while (getattr(pa,'provisioning_state')) != "Succeeded" :
pa = (purview_client.accounts.get(rg_name, purview_name))
print(getattr(pa,'provisioning_state'))
if getattr(pa,'provisioning_state') == "Failed" :
print("Error in creating Microsoft Purview account")
break
time.sleep(30)
# Start the main method
main()
코드 실행
애플리케이션을 빌드하고 시작합니다. 콘솔은 Microsoft Purview 계정 만들기의 진행률을 출력합니다. 완료될 때까지 기다립니다. 샘플 출력은 다음과 같습니다.
location: southcentralus Microsoft Purview Account Name: purviewpython7 Id: /subscriptions/8c2c7b23-848d-40fe-b817-690d79ad9dfd/resourceGroups/Demo_Catalog/providers/Microsoft.Purview/accounts/purviewpython7 tags: None
Creating
Creating
Succeeded
출력 확인
Azure Portal Microsoft Purview 계정 페이지로 이동하여 위의 코드를 사용하여 만든 계정을 확인합니다.
Microsoft Purview 계정 삭제
purview 계정을 삭제하려면 프로그램에 다음 코드를 추가한 다음, 를 실행합니다.
pa = purview_client.accounts.begin_delete(rg_name, purview_name).result()
다음 단계
이 빠른 시작에서는 Microsoft Purview(이전의 Azure Purview) 계정을 만들고, 계정을 삭제하고, 이름 가용성을 검사 방법을 알아보았습니다. 이제 Python SDK를 다운로드하고 Microsoft Purview 계정에 대해 수행할 수 있는 다른 리소스 공급자 작업에 대해 알아볼 수 있습니다.
다음 문서에 따라 Microsoft Purview 거버넌스 포털을 탐색하고, 컬렉션을 만들고, Microsoft Purview 거버넌스 포털에 대한 액세스 권한을 부여하는 방법을 알아봅니다.