AzureFileDatastore class

Definition

Represents a datastore that saves connection information to Azure File storage.

You should not work with this class directly. To create a datastore of this type, use the register_azure_file_share(workspace, datastore_name, file_share_name, account_name, sas_token=None, account_key=None, protocol=None, endpoint=None, overwrite=False, create_if_not_exists=False, skip_validation=False) method of Datastore.

Note: When using a datastore to access data, you must have permission to access that data, which depends on the credentials registered with the datastore.

AzureFileDatastore(workspace, name, container_name, account_name, sas_token=None, account_key=None, protocol=None, endpoint=None, request_session=None)
Inheritance

Parameters

workspace
Workspace

The workspace this datastore belongs to.

name
str

The name of the datastore. It can only contain alphanumeric characters or - or _.

container_name
str

The file share name

account_name
str

The storage account name

sas_token
str, optional

The SAS token for accessing this container. The default is None.

account_key
str, optional

The storage account key. The default is None.

protocol
str, optional

The protocol to use to connect to the storage account. If None, defaults to https.

endpoint
str, optional

The endpoint of the blob container. If None, defaults to core.windows.net.

request_session
requests.Session, optional

The session object to use for http requests. The default is None.

Methods

download(target_path, prefix=None, overwrite=False, show_progress=True)

Download the data from the file share to the local file system.

upload(src_dir, target_path=None, overwrite=False, show_progress=True)

Upload the data from the local file system to the file share this datastore points to.

upload_files(files, relative_root=None, target_path=None, overwrite=False, show_progress=True)

Upload the data from the local file system to the file share this datastore points to.

download(target_path, prefix=None, overwrite=False, show_progress=True)

Download the data from the file share to the local file system.

download(target_path, prefix=None, overwrite=False, show_progress=True)

Parameters

target_path
str

The local directory to download the file to.

prefix
str, optional

The path to the folder in the file share to download. If set to None, Azure Machine Learning will download everything in the file share.

default value: None
overwrite
bool, optional

Indicates whether to overwrite existing file.

default value: False
show_progress
bool, optional

Indicates whether to show the progress of download in the console.

default value: True

Returns

The number of files successfully downloaded.

Return type

int

upload(src_dir, target_path=None, overwrite=False, show_progress=True)

Upload the data from the local file system to the file share this datastore points to.

upload(src_dir, target_path=None, overwrite=False, show_progress=True)

Parameters

src_dir
str

The local directory to upload.

target_path
str

The location in file share to upload to. If Non,e then upload to root.

default value: None
overwrite
bool, optional

Indicates whether to overwrite existing files.

default value: False
show_progress
bool, optional

Indicates whether to show the progress of upload in the console.

default value: True

Returns

The DataReference instance for the target path uploaded.

Return type

upload_files(files, relative_root=None, target_path=None, overwrite=False, show_progress=True)

Upload the data from the local file system to the file share this datastore points to.

upload_files(files, relative_root=None, target_path=None, overwrite=False, show_progress=True)

Parameters

files
list[str]

A list of absolute path to files to upload.

relative_root
str, optional

The base path used to determine the path of the files in the file share. For example, if you upload /path/to/file.txt, and you define base path to be /path, when file.txt is uploaded to the file share, it will have the path of /to/file.txt. If target_path is also specified, then it will be used as the prefix for the derived path from above. The base path must be a common path of all of the files, otherwise an exception will be thrown. The default is None, which will find the common path.

default value: None
target_path
str, optional

The location in the file share to upload the data to. The default is None, the root.

default value: None
overwrite
bool, optional

Indicates whether to overwrite existing files.

default value: False
show_progress
bool, optional

Indicates whether to show the progress of upload in the console.

default value: True

Returns

The DataReference instance for the target path uploaded.

Return type