データストアの作成

適用対象:Azure CLI ml extension 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 Files データストアを作成する

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 では、フォルダーとファイルおよび Amazon S3 ショートカットを含む Microsoft Fabric レイクハウスの成果物への接続がサポートされています。 レイクハウスについて詳しくは、「Microsoft Fabric のレイクハウスとは?」をご覧ください。

OneLake データストアを作成するには、次のものが必要です

  • エンドポイント
  • ファブリック ワークスペース名または GUID
  • 成果物名または GUID

Microsoft Fabric インスタンスからの情報。 これら 3 つのスクリーンショットは、Microsoft Fabric インスタンスから必要な 3 つの情報リソースを取得する様子を示しています。

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)

次のステップ