建立資料存放區

適用於:Azure CLI ml 延伸模組 v2 (目前)Python SDK azure-ai-ml v2 (目前)

在本文中,了解如何透過 Azure Machine Learning 資料存放區連線至 Azure 資料儲存體服務。

必要條件

注意

Azure Machine Learning 資料存放區不會建立基礎儲存體帳戶資源。 相反地,他們會連結現有的儲存體帳戶以供 Azure Machine Learning 使用。 這不需要 Azure Machine Learning 資料存放區。 如果您有基礎資料的存取權,您可以直接使用儲存體 URI。

建立 Azure Blob 資料存放區

from azure.ai.ml.entities import AzureBlobDatastore
from azure.ai.ml import MLClient

ml_client = MLClient.from_config()

store = AzureBlobDatastore(
    name="",
    description="",
    account_name="",
    container_name=""
)

ml_client.create_or_update(store)

建立 Azure Data Lake Gen2 資料存放區

from azure.ai.ml.entities import AzureDataLakeGen2Datastore
from azure.ai.ml import MLClient

ml_client = MLClient.from_config()

store = AzureDataLakeGen2Datastore(
    name="",
    description="",
    account_name="",
    filesystem=""
)

ml_client.create_or_update(store)

建立 Azure 檔案儲存體資料存放區

from azure.ai.ml.entities import AzureFileDatastore
from azure.ai.ml.entities import AccountKeyConfiguration
from azure.ai.ml import MLClient

ml_client = MLClient.from_config()

store = AzureFileDatastore(
    name="file_example",
    description="Datastore pointing to an Azure File Share.",
    account_name="mytestfilestore",
    file_share_name="my-share",
    credentials=AccountKeyConfiguration(
        account_key= "XXXxxxXXXxXXXXxxXXXXXxXXXXXxXxxXxXXXxXXXxXXxxxXXxxXXXxXxXXXxxXxxXXXXxxxxxXXxxxxxxXXXxXXX"
    ),
)

ml_client.create_or_update(store)

建立 Azure Data Lake Gen1 資料存放區

from azure.ai.ml.entities import AzureDataLakeGen1Datastore
from azure.ai.ml import MLClient

ml_client = MLClient.from_config()

store = AzureDataLakeGen1Datastore(
    name="",
    store_name="",
    description="",
)

ml_client.create_or_update(store)

建立 OneLake (Microsoft Fabric) 資料存放區 (預覽)

本節說明建立 OneLake 資料存放區的各種選項。 OneLake 資料存放區是 Microsoft Fabric 的一部分。 目前,Azure Machine Learning 支援連線到 Microsoft Fabric Lakehouse 成品,其中包含資料夾/檔案和 Amazon S3 捷徑。 如需 Lakehouse 的詳細資訊,請瀏覽什麼是 Microsoft Fabric 中的 Lakehouse

OneLake 資料存放區建立需要

  • 端點
  • 網狀架構工作區名稱或 GUID
  • 成品名稱或 GUID

來自 Microsoft Fabric 執行個體的資訊。 這三個螢幕擷取畫面說明從 Microsoft Fabric 執行個體擷取這些必要資訊資源:

OneLake 工作區名稱

在 Microsoft Fabric 執行個體中,您可以找到工作區資訊,如此螢幕擷取畫面所示。 您可以使用 GUID 值或「易記名稱」來建立 Azure Machine Learning OneLake 資料存放區。

Screenshot that shows Fabric Workspace details in Microsoft Fabric UI.

OneLake 端點

此螢幕擷取畫面顯示如何在 Microsoft Fabric 執行個體中找到端點資訊:

Screenshot that shows Fabric endpoint details in Microsoft Fabric UI.

OneLake 成品名稱

此螢幕擷取畫面顯示如何在 Microsoft Fabric 執行個體中找到成品資訊。 此螢幕擷取畫面也會顯示如何使用 GUID 值或「易記名稱」來建立 Azure Machine Learning OneLake 資料存放區:

Screenshot showing how to get Fabric LH artifact details in Microsoft Fabric UI.

建立 OneLake 資料存放區

from azure.ai.ml.entities import OneLakeDatastore, OneLakeArtifact
from azure.ai.ml import MLClient

ml_client = MLClient.from_config()

store = OneLakeDatastore(
    name="onelake_example_id",
    description="Datastore pointing to an Microsoft fabric artifact.",
    one_lake_workspace_name="AzureML_Sample_OneLakeWS",
    endpoint="msit-onelake.dfs.fabric.microsoft.com"
    artifact = OneLakeArtifact(
        name="AzML_Sample_LH",
        type="lake_house"
    )
)

ml_client.create_or_update(store)

下一步