DatastoreOperations Class

Represents a client for performing operations on Datastores.

You should not instantiate this class directly. Instead, you should create MLClient and use this client via the property MLClient.datastores

Inheritance
azure.ai.ml._scope_dependent_operations._ScopeDependentOperations
DatastoreOperations

Constructor

DatastoreOperations(operation_scope: OperationScope, operation_config: OperationConfig, serviceclient_2023_04_01_preview: AzureMachineLearningWorkspaces, serviceclient_2024_01_01_preview: AzureMachineLearningWorkspaces, **kwargs: Dict)

Parameters

Name Description
operation_scope
Required
<xref:azure.ai.ml._scope_dependent_operations.OperationScope>

Scope variables for the operations classes of an MLClient object.

operation_config
Required
<xref:azure.ai.ml._scope_dependent_operations.OperationConfig>

Common configuration for operations classes of an MLClient object.

serviceclient_2022_10_01
Required
<xref:<xref:azure.ai.ml._restclient.v2022_10_01._azure_machine_learning_workspaces. AzureMachineLearningWorkspaces>>

Service client to allow end users to operate on Azure Machine Learning Workspace resources.

serviceclient_2023_04_01_preview
Required
serviceclient_2024_01_01_preview
Required

Methods

create_or_update

Attaches the passed in datastore to the workspace or updates the datastore if it already exists.

delete

Deletes a datastore reference with the given name from the workspace. This method does not delete the actual datastore or underlying data in the datastore.

get

Returns information about the datastore referenced by the given name.

get_default

Returns the workspace's default datastore.

list

Lists all datastores and associated information within a workspace.

mount

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Mount a datastore to a local path, so that you can access data inside it under a local path with any tools of your choice.

create_or_update

Attaches the passed in datastore to the workspace or updates the datastore if it already exists.

create_or_update(datastore: Datastore) -> Datastore

Parameters

Name Description
datastore
Required

The configuration of the datastore to attach.

Returns

Type Description

The attached datastore.

Examples

Create datastore example.


   from azure.ai.ml.entities import AzureBlobDatastore

   datastore_example = AzureBlobDatastore(
       name="azure_blob_datastore",
       account_name="sdkvnextclidcdnrc7zb7xyy",  # cspell:disable-line
       container_name="testblob",
   )
   ml_client.datastores.create_or_update(datastore_example)

delete

Deletes a datastore reference with the given name from the workspace. This method does not delete the actual datastore or underlying data in the datastore.

delete(name: str) -> None

Parameters

Name Description
name
Required
str

Name of the datastore

Examples

Delete datastore example.


   ml_client.datastores.delete("azure_blob_datastore")

get

Returns information about the datastore referenced by the given name.

get(name: str, *, include_secrets: bool = False) -> Datastore

Parameters

Name Description
name
Required
str

Datastore name

Keyword-Only Parameters

Name Description
include_secrets

Include datastore secrets in the returned datastore, defaults to False

Returns

Type Description

Datastore with the specified name.

Examples

Get datastore example.


   ml_client.datastores.get("azure_blob_datastore")

get_default

Returns the workspace's default datastore.

get_default(*, include_secrets: bool = False) -> Datastore

Keyword-Only Parameters

Name Description
include_secrets

Include datastore secrets in the returned datastore, defaults to False

Returns

Type Description

The default datastore.

Examples

Get default datastore example.


   ml_client.datastores.get_default()

list

Lists all datastores and associated information within a workspace.

list(*, include_secrets: bool = False) -> Iterable[Datastore]

Keyword-Only Parameters

Name Description
include_secrets

Include datastore secrets in returned datastores, defaults to False

Returns

Type Description

An iterator like instance of Datastore objects

Examples

List datastore example.


   ml_client.datastores.list()

mount

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Mount a datastore to a local path, so that you can access data inside it under a local path with any tools of your choice.

mount(path: str, mount_point: str | None = None, mode: str = 'ro_mount', debug: bool = False, persistent: bool = False, **_kwargs) -> None

Parameters

Name Description
path
Required
str

The data store path to mount, in the form of or azureml://datastores/.

mount_point
Required
str

A local path used as mount point.

mode
Required
str

Mount mode, either ro_mount (read-only) or rw_mount (read-write).

debug
Required

Whether to enable verbose logging.

persistent
Required

Whether to persist the mount after reboot. Applies only when running on Compute Instance, where the 'CI_NAME' environment variable is set."

Returns

Type Description

None