Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article
APPLIES TO:
Azure CLI ml extension v2 (current)
Python SDK azure-ai-ml v2 (current)
In this article, you learn how to connect to Azure data storage services with Azure Machine Learning datastores.
Prerequisites
- An Azure subscription. If you don't have an Azure subscription, create a Trial before you begin. Try the trial subscription.
- The Azure Machine Learning SDK for Python.
- A Machine Learning workspace.
Note
Machine Learning datastores do not create the underlying storage account resources. Instead, they link an existing storage account for Machine Learning use. Machine Learning datastores aren't required. If you have access to the underlying data, you can use storage URIs directly.
Create an Azure Blob datastore
- Python SDK: Identity-based access
- Python SDK: Account key
- Python SDK: SAS
- CLI: Identity-based access
- CLI: Account key
- CLI: SAS
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)
Create an Azure Data Lake Storage Gen2 datastore
- Python SDK: Identity-based access
- Python SDK: Service principal
- CLI: Identity-based access
- CLI: Service principal
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)
Create an Azure Files datastore
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)
Create an Azure Data Lake Storage Gen1 datastore
- Python SDK: Identity-based access
- Python SDK: Service principal
- CLI: Identity-based access
- CLI: Service principal
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)