Python용 Azure Purview 검사 클라이언트 라이브러리 - 버전 1.0.0b2

Azure Purview Scanning은 사용자가 데이터를 데이터 자산( 카탈로그라고도 함)으로 스캔할 수 있는 완전 관리형 클라우드 서비스입니다. 스캔은 사용자가 지정한 일정에 따라 카탈로그가 데이터 원본에 직접 연결하는 프로세스입니다.

  • 카탈로그로 데이터 검사
  • 데이터 검사
  • 데이터에서 스키마 추출

이 라이브러리를 사용하려면 서비스의 설명서클라이언트 문서에 크게 의존하세요.

소스 코드 | 패키지(PyPI) | API 참조 설명서| 제품 설명서

고지 사항

Python 2.7에 대한 Azure SDK Python 패키지 지원은 2022년 1월 1일에 종료됩니다. 자세한 내용과 질문은 을 참조하세요. https://github.com/Azure/azure-sdk-for-python/issues/20691

시작

필수 조건

  • 이 패키지를 사용하려면 Python 2.7 또는 3.6 이상이 필요합니다.
  • 이 패키지를 사용하려면 Azure 구독Purview 가 있어야 합니다.

Purview 리소스 만들기

다음 지침에 따라 Purview 리소스를 만듭니다.

패키지 설치

pip를 사용하여 Python용 Azure Purview 검사 클라이언트 라이브러리를 설치합니다.

pip install azure-purview-scanning

클라이언트 인증

AAD(Azure Active Directory) 토큰 자격 증명을 사용하려면 azure-identity 라이브러리에서 가져온 원하는 자격 증명 형식의 인스턴스를 제공합니다.

AAD로 인증하려면 먼저 Purview 리소스에서 AAD 인증을 설치 azure-identity 하고 사용하도록 설정해야 합니다.

설치 후 azure.identity에서 사용할 자격 증명 유형을 선택할 수 있습니다. 예를 들어 DefaultAzureCredential을 사용하여 클라이언트를 인증할 수 있습니다.

AAD 애플리케이션의 클라이언트 ID, 테넌트 ID 및 클라이언트 암호 값을 환경 변수(AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

반환된 토큰 자격 증명을 사용하여 클라이언트를 인증합니다.

from azure.purview.scanning import PurviewScanningClient
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
client = PurviewScanningClient(endpoint="https://<my-account-name>.scan.purview.azure.com", credential=credential)

주요 개념

클라이언트

이 패키지는 http 요청을 빌드하고 메서드를 사용하여 send_request 서비스에 이러한 요청을 보낼 수 있도록 요청 작성기를 제공합니다. 요청 작성기 및 클라이언트를 사용하는 방법에 대한 자세한 내용은 여기를 참조 하세요.

예제

다음 섹션에서는 클라이언트를 초기화 및 인증한 다음 모든 데이터 원본을 나열하는 방법을 보여 줍니다.

모든 데이터 원본 나열

from azure.purview.scanning import PurviewScanningClient
from azure.identity import DefaultAzureCredential
from azure.core.exceptions import HttpResponseError

credential = DefaultAzureCredential()
client = PurviewScanningClient(endpoint="https://<my-account-name>.scan.purview.azure.com", credential=credential)
try:
    response = client.data_sources.list_all()
    result = [item for item in response]
    print(result)
except HttpResponseError as e:
    print(e)

문제 해결

일반

Purview 검사 클라이언트는 응답을 호출 .raise_for_status() 하는 경우 [Azure Core][azure_core]에 정의된 예외를 발생합니다.

로깅

이 라이브러리는 로깅에 표준 로깅 라이브러리를 사용합니다. HTTP 세션(URL, 헤더 등)에 대한 기본 정보는 INFO 수준에서 기록됩니다.

logging_enable 키워드 인수를 통해 클라이언트에서 요청/응답 본문 및 미작성 헤더를 포함한 상세 디버그 수준 로깅을 사용할 수 있습니다.

import sys
import logging
from azure.identity import DefaultAzureCredential
from azure.purview.scanning import PurviewScanningClient

# Create a logger for the 'azure' SDK
logger = logging.getLogger('azure')
logger.setLevel(logging.DEBUG)

# Configure a console output
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)

endpoint = "https://<my-account-name>.scan.purview.azure.com"
credential = DefaultAzureCredential()

# This client will log detailed information about its HTTP sessions, at DEBUG level
client = PurviewScanningClient(endpoint=endpoint, credential=credential, logging_enable=True)

마찬가지로 는 logging_enable 클라이언트에 대해 사용하도록 설정되지 않은 경우에도 단일 send_request 호출에 대해 자세한 로깅을 사용하도록 설정할 수 있습니다.

result = client.data_sources.list_all(logging_enable=True)

다음 단계

더 일반적인 샘플은 클라이언트 문서를 참조하세요.

참여

이 프로젝트에 대한 기여와 제안을 환영합니다. 대부분의 경우 기여하려면 권한을 부여하며 실제로 기여를 사용할 권한을 당사에 부여한다고 선언하는 CLA(기여자 라이선스 계약)에 동의해야 합니다. 자세한 내용은 cla.microsoft.com.

끌어오기 요청을 제출하면 CLA-bot은 CLA를 제공하고 PR을 적절하게 데코레이팅해야 하는지 여부를 자동으로 결정합니다(예: 레이블, 설명). 봇에서 제공하는 지침을 따르기만 하면 됩니다. 이 작업은 CLA를 사용하여 모든 리포지토리에서 한 번만 수행하면 됩니다.

이 프로젝트에는 Microsoft Open Source Code of Conduct(Microsoft 오픈 소스 준수 사항)가 적용됩니다. 자세한 내용은 Code of Conduct FAQ(규정 FAQ)를 참조하세요. 또는 추가 질문이나 의견은 opencode@microsoft.com으로 문의하세요.