작업 영역 관리를 SDK v2로 업그레이드
작업 영역은 V2 개발 플랫폼에서 기능적으로 변경되지 않습니다. 그러나 알아두어야 할 네트워크 관련 변경 내용이 있습니다. 자세한 내용은 Azure Resource Manager에서 새로운 API 플랫폼으로 네트워크 격리 변경을 참조하세요.
이 문서에서는 SDK v1과 SDK v2의 시나리오를 비교합니다.
작업 영역 만들기
SDK v1
from azureml.core import Workspace ws = Workspace.create( name='my_workspace', location='eastus', subscription_id = '<SUBSCRIPTION_ID>' resource_group = '<RESOURCE_GROUP>' )
SDK v2
from azure.ai.ml import MLClient from azure.ai.ml.entities import Workspace from azure.identity import DefaultAzureCredential # specify the details of your subscription subscription_id = "<SUBSCRIPTION_ID>" resource_group = "<RESOURCE_GROUP>" # get a handle to the subscription ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group) # specify the workspace details ws = Workspace( name="my_workspace", location="eastus", display_name="My workspace", description="This example shows how to create a workspace", tags=dict(purpose="demo"), ) ml_client.workspaces.begin_create(ws)
Azure Private Link 엔드포인트와 함께 사용할 작업 영역 만들기
SDK v1
from azureml.core import Workspace ws = Workspace.create( name='my_workspace', location='eastus', subscription_id = '<SUBSCRIPTION_ID>' resource_group = '<RESOURCE_GROUP>' ) ple = PrivateEndPointConfig( name='my_private_link_endpoint', vnet_name='<VNET_NAME>', vnet_subnet_name='<VNET_SUBNET_NAME>', vnet_subscription_id='<SUBSCRIPTION_ID>', vnet_resource_group='<RESOURCE_GROUP>' ) ws.add_private_endpoint(ple, private_endpoint_auto_approval=True)
SDK v2
from azure.ai.ml import MLClient from azure.ai.ml.entities import Workspace from azure.identity import DefaultAzureCredential # specify the details of your subscription subscription_id = "<SUBSCRIPTION_ID>" resource_group = "<RESOURCE_GROUP>" # get a handle to the subscription ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group) ws = Workspace( name="private_link_endpoint_workspace, location="eastus", display_name="Private Link endpoint workspace", description="When using private link, you must set the image_build_compute property to a cluster name to use for Docker image environment building. You can also specify whether the workspace should be accessible over the internet.", image_build_compute="cpu-compute", public_network_access="Disabled", tags=dict(purpose="demonstration"), ) ml_client.workspaces.begin_create(ws)
매개 변수를 사용하여 작업 영역에 로드/연결
SDK v1
from azureml.core import Workspace ws = Workspace.from_config() # specify the details of your subscription subscription_id = "<SUBSCRIPTION_ID>" resource_group = "<RESOURCE_GROUP>" # get handle on the workspace ws = Workspace.get( subscription_id='<SUBSCRIPTION_ID>', resource_group='<RESOURCE_GROUP>', name='my_workspace', )
SDK v2
from azure.ai.ml import MLClient from azure.ai.ml.entities import Workspace from azure.identity import DefaultAzureCredential # specify the details of your subscription subscription_id = "<SUBSCRIPTION_ID>" resource_group = "<RESOURCE_GROUP>" # get handle on the workspace ws = MLClient( DefaultAzureCredential(), subscription_id='<SUBSCRIPTION_ID>', resource_group_name='<RESOURCE_GROUP>', workspace_name='my_workspace' )
구성 파일을 사용하여 작업 영역에 로드/연결
SDK v1
from azureml.core import Workspace ws = Workspace.from_config() ws.get_details()
SDK v2
from azure.ai.ml import MLClient from azure.ai.ml.entities import Workspace from azure.identity import DefaultAzureCredential ws = MLClient.from_config( DefaultAzureCredential() )
SDK v1 및 SDK v2의 주요 기능 매핑
SDK v1의 기능 | SDK v2의 대략적인 매핑 |
---|---|
SDK v1의 메서드/API(참조 문서 링크 사용) | SDK v2의 메서드/API(참조 문서 링크 사용) |
관련 문서
자세한 내용은 다음을 참조하세요.