airflow.providers.microsoft.azure.hooks.wasb
¶
This module contains integration with Azure Blob Storage.
It communicate via the Window Azure Storage Blob protocol. Make sure that a Airflow connection of type wasb exists. Authorization can be done by supplying a login (=Storage account name) and password (=KEY), or login and SAS token in the extra field (see connection wasb_default for an example).
Module Contents¶
-
class
airflow.providers.microsoft.azure.hooks.wasb.
WasbHook
(wasb_conn_id: str = default_conn_name)[source]¶ Bases:
airflow.hooks.base.BaseHook
Interacts with Azure Blob Storage through the
wasb://
protocol.These parameters have to be passed in Airflow Data Base: account_name and account_key.
Additional options passed in the 'extra' field of the connection will be passed to the BlockBlockService() constructor. For example, authenticate using a SAS token by adding {"sas_token": "YOUR_TOKEN"}.
- Parameters
wasb_conn_id (str) -- Reference to the wasb connection.
-
check_for_blob
(self, container_name, blob_name, **kwargs)[source]¶ Check if a blob exists on Azure Blob Storage.
-
check_for_prefix
(self, container_name: str, prefix: str, **kwargs)[source]¶ Check if a prefix exists on Azure Blob storage.
-
get_blobs_list
(self, container_name: str, prefix: str, **kwargs)[source]¶ Return a list of blobs from path defined in prefix param
- Parameters
- Returns
List of blobs.
- Return type
list(azure.storage.common.models.ListGenerator)
-
load_file
(self, file_path: str, container_name: str, blob_name: str, **kwargs)[source]¶ Upload a file to Azure Blob Storage.
-
load_string
(self, string_data: str, container_name: str, blob_name: str, **kwargs)[source]¶ Upload a string to Azure Blob Storage.
-
get_file
(self, file_path: str, container_name: str, blob_name: str, **kwargs)[source]¶ Download a file from Azure Blob Storage.
-
read_file
(self, container_name: str, blob_name: str, **kwargs)[source]¶ Read a file from Azure Blob Storage and return as a string.
-
delete_file
(self, container_name: str, blob_name: str, is_prefix: bool = False, ignore_if_missing: bool = False, **kwargs)[source]¶ Delete a file from Azure Blob Storage.
- Parameters
container_name (str) -- Name of the container.
blob_name (str) -- Name of the blob.
is_prefix (bool) -- If blob_name is a prefix, delete all matching files
ignore_if_missing (bool) -- if True, then return success even if the blob does not exist.
kwargs (object) -- Optional keyword arguments that BlockBlobService.create_blob_from_path() takes.