airflow.providers.microsoft.azure.hooks.fileshare

Module Contents

Classes

AzureFileShareHook

Interacts with Azure FileShare Storage.

class airflow.providers.microsoft.azure.hooks.fileshare.AzureFileShareHook(azure_fileshare_conn_id='azure_fileshare_default')[source]

Bases: airflow.hooks.base.BaseHook

Interacts with Azure FileShare Storage.

Parameters

azure_fileshare_conn_id (str) – Reference to the Azure Container Volume connection id of an Azure account of which container volumes should be used.

conn_name_attr = azure_fileshare_conn_id[source]
default_conn_name = azure_fileshare_default[source]
conn_type = azure_fileshare[source]
hook_name = Azure FileShare[source]
static get_connection_form_widgets()[source]

Returns connection widgets to add to connection form

static get_ui_field_behaviour()[source]

Returns custom field behaviour

get_conn()[source]

Return the FileService object.

check_for_directory(share_name, directory_name, **kwargs)[source]

Check if a directory exists on Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • kwargs – Optional keyword arguments that FileService.exists() takes.

Returns

True if the file exists, False otherwise.

Return type

bool

check_for_file(share_name, directory_name, file_name, **kwargs)[source]

Check if a file exists on Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • kwargs – Optional keyword arguments that FileService.exists() takes.

Returns

True if the file exists, False otherwise.

Return type

bool

list_directories_and_files(share_name, directory_name=None, **kwargs)[source]

Return the list of directories and files stored on a Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • directory_name (str | None) – Name of the directory.

  • kwargs – Optional keyword arguments that FileService.list_directories_and_files() takes.

Returns

A list of files and directories

Return type

list

list_files(share_name, directory_name=None, **kwargs)[source]

Return the list of files stored on a Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • directory_name (str | None) – Name of the directory.

  • kwargs – Optional keyword arguments that FileService.list_directories_and_files() takes.

Returns

A list of files

Return type

list[str]

create_share(share_name, **kwargs)[source]

Create new Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • kwargs – Optional keyword arguments that FileService.create_share() takes.

Returns

True if share is created, False if share already exists.

Return type

bool

delete_share(share_name, **kwargs)[source]

Delete existing Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • kwargs – Optional keyword arguments that FileService.delete_share() takes.

Returns

True if share is deleted, False if share does not exist.

Return type

bool

create_directory(share_name, directory_name, **kwargs)[source]

Create a new directory on a Azure File Share.

Parameters
  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • kwargs – Optional keyword arguments that FileService.create_directory() takes.

Returns

A list of files and directories

Return type

list

get_file(file_path, share_name, directory_name, file_name, **kwargs)[source]

Download a file from Azure File Share.

Parameters
  • file_path (str) – Where to store the file.

  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • kwargs – Optional keyword arguments that FileService.get_file_to_path() takes.

get_file_to_stream(stream, share_name, directory_name, file_name, **kwargs)[source]

Download a file from Azure File Share.

Parameters
  • stream (IO) – A filehandle to store the file to.

  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • kwargs – Optional keyword arguments that FileService.get_file_to_stream() takes.

load_file(file_path, share_name, directory_name, file_name, **kwargs)[source]

Upload a file to Azure File Share.

Parameters
  • file_path (str) – Path to the file to load.

  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • kwargs – Optional keyword arguments that FileService.create_file_from_path() takes.

load_string(string_data, share_name, directory_name, file_name, **kwargs)[source]

Upload a string to Azure File Share.

Parameters
  • string_data (str) – String to load.

  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • kwargs – Optional keyword arguments that FileService.create_file_from_text() takes.

load_stream(stream, share_name, directory_name, file_name, count, **kwargs)[source]

Upload a stream to Azure File Share.

Parameters
  • stream (str) – Opened file/stream to upload as the file content.

  • share_name (str) – Name of the share.

  • directory_name (str) – Name of the directory.

  • file_name (str) – Name of the file.

  • count (str) – Size of the stream in bytes

  • kwargs – Optional keyword arguments that FileService.create_file_from_stream() takes.

test_connection()[source]

Test Azure FileShare connection.

Was this entry helpful?