다음을 통해 공유


Azure Machine Learning SDK 및 CLI를 사용하여 허브 만들기

Important

이 문서에 설명된 기능 중 일부는 미리 보기로만 제공될 수 있습니다. 이 미리 보기는 서비스 수준 계약 없이 제공되며, 프로덕션 워크로드에는 권장되지 않습니다. 특정 기능이 지원되지 않거나 기능이 제한될 수 있습니다. 자세한 내용은 Microsoft Azure Preview에 대한 추가 사용 약관을 참조하세요.

이 문서에서는 Azure Machine Learning SDK 및 Azure CLI(기계 학습 확장 사용)를 사용하여 다음 AI Studio 리소스를 만드는 방법을 알아봅니다.

  • Azure AI 스튜디오 허브
  • Azure AI 서비스 연결

필수 구성 요소

환경 설정

다음 탭을 사용하여 Python SDK 또는 Azure CLI를 사용할지 여부를 선택합니다.

  1. SDK 빠른 시작에 설명된 대로 Python을 설치합니다.

  2. Azure Machine Learning SDK v2를 설치합니다.

  3. azure-identity 설치: pip install azure-identity. Notebook 셀에 있는 경우 %pip install azure-identity를 사용합니다.

  4. 구독 세부 정보를 제공합니다.

    # Enter details of your subscription
    subscription_id = "<SUBSCRIPTION_ID>"
    resource_group = "<RESOURCE_GROUP>"
  5. 구독에 대한 핸들을 가져옵니다. 이 문서에서 모든 Python 코드는 ml_client를 사용합니다.

    # get a handle to the subscription
    
    from azure.ai.ml import MLClient
    from azure.identity import DefaultAzureCredential
    
    ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group)
  6. (선택 사항) 계정이 여러 개인 경우 사용하려는 Microsoft Entra ID의 테넌트 ID를 DefaultAzureCredential에 추가합니다. Azure PortalMicrosoft Entra ID, 외부 ID에서 테넌트 ID를 찾습니다.

    DefaultAzureCredential(interactive_browser_tenant_id="<TENANT_ID>")
    
  7. (선택 사항) Azure Government - 미국 또는 Azure 중국 21Vianet 지역에서 작업하는 경우 인증할 지역을 지정합니다. DefaultAzureCredential을 사용하여 지역을 지정할 수 있습니다. 다음 예제에서는 Azure Government - 미국 지역에 대해 인증합니다.

    from azure.identity import AzureAuthorityHosts
    DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
    

AI 스튜디오 허브 및 AI 서비스 연결 만들기

다음 예제를 사용하여 새 허브를 만듭니다. 예제 문자열 값을 고유한 값으로 바꿉니다.

from azure.ai.ml.entities import Hub

my_hub_name = "myexamplehub"
my_location = "East US"
my_display_name = "My Example Hub"

# construct a basic hub
my_hub = Hub(name=my_hub_name, 
            location=my_location,
            display_name=my_display_name)

created_hub = ml_client.workspaces.begin_create(my_hub).result()

AI 서비스 연결 만들기

사용자 고유의 AI 서비스를 만든 후 허브에 연결할 수 있습니다.

from azure.ai.ml.entities import AzureAIServicesConnection

# constrict an AI Services connection
my_connection_name = "myaiservivce"
my_endpoint = "demo.endpoint" # this could also be called target
my_api_keys = None # leave blank for Authentication type = AAD
my_ai_services_resource_id = "" # ARM id required

my_connection = AzureAIServicesConnection(name=my_connection_name,
                                    endpoint=my_endpoint, 
                                    api_key= my_api_keys,
                                    ai_services_resource_id=my_ai_services_resource_id)

# Create the connection
ml_client.connections.create_or_update(my_connection)