# Azure Tasks


This module contains a collection of tasks for interacting with Azure resources.

# BlobStorageDownload

class

prefect.tasks.azure.blobstorage.BlobStorageDownload

(azure_credentials_secret="AZ_CONNECTION_STRING", container=None, **kwargs)[source]

Task for downloading data from an Blob Storage container and returning it as a string. Note that all initialization arguments can optionally be provided or overwritten at runtime.

Args:

  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be an Azure connection string
  • container (str, optional): the name of the Azure Blob Storage to download from
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.azure.blobstorage.BlobStorageDownload.run

(blob_name, azure_credentials_secret="AZ_CONNECTION_STRING", container=None)[source]

Task run method.

Args:

  • blob_name (str): the name of the blob within this container to retrieve
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be an Azure connection string
  • container (str, optional): the name of the Blob Storage container to download from
Returns:
  • str: the contents of this blob_name / container, as a string



# BlobStorageUpload

class

prefect.tasks.azure.blobstorage.BlobStorageUpload

(azure_credentials_secret="AZ_CONNECTION_STRING", container=None, **kwargs)[source]

Task for uploading string data (e.g., a JSON string) to an Azure Blob Storage container. Note that all initialization arguments can optionally be provided or overwritten at runtime.

Args:

  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be an Azure connection string
  • container (str, optional): the name of the Azure Blob Storage to upload to
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.azure.blobstorage.BlobStorageUpload.run

(data, blob_name=None, azure_credentials_secret="AZ_CONNECTION_STRING", container=None)[source]

Task run method.

Args:

  • data (str): the data payload to upload
  • blob_name (str, optional): the name to upload the data under; if not provided, a random uuid will be created
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be an Azure connection string
  • container (str, optional): the name of the Blob Storage container to upload to
Returns:
  • str: the name of the blob the data payload was uploaded to



# CosmosDBCreateItem

class

prefect.tasks.azure.cosmosdb.CosmosDBCreateItem

(url=None, database_or_container_link=None, item=None, azure_credentials_secret="AZ_CREDENTIALS", options=None, **kwargs)[source]

Task for creating an item in a Azure Cosmos database. Note that all initialization arguments can optionally be provided or overwritten at runtime.

Args:

  • url (str, optional): The url to the database.
  • database_or_container_link (str, optional): link to the database or container.
  • item (dict, optional): the item to create
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.CreateItem method.
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.azure.cosmosdb.CosmosDBCreateItem.run

(url=None, database_or_container_link=None, item=None, azure_credentials_secret="AZ_CREDENTIALS", options=None)[source]

Task run method.

Args:

  • url (str, optional): The url to the database.
  • database_or_container_link (str, optional): link to the database or container.
  • item (dict, optional): the item to create
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.CreateItem method.
Returns:
  • (dict): the created item.



# CosmosDBReadItems

class

prefect.tasks.azure.cosmosdb.CosmosDBReadItems

(url=None, document_or_container_link=None, azure_credentials_secret="AZ_CREDENTIALS", options=None, **kwargs)[source]

Task for reading items from a Azure Cosmos database. Note that all initialization arguments can optionally be provided or overwritten at runtime.

Args:

  • url (str, optional): The url to the database.
  • document_or_container_link (str, optional): link to a document or container. If a document link is provided, the document in question is returned, otherwise all docuements are returned.
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.ReadItem or ReadItems method.
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.azure.cosmosdb.CosmosDBReadItems.run

(url=None, document_or_container_link=None, azure_credentials_secret="AZ_CREDENTIALS", options=None)[source]

Task run method.

Args:

  • url (str, optional): The url to the database.
  • document_or_container_link (str, optional): link to a document or container. If a document link is provided, the document in question is returned, otherwise all docuements are returned.
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.ReadItem or ReadItems method.
Returns:
  • (dict or list)): a single document or all documents.



# CosmosDBQueryItems

class

prefect.tasks.azure.cosmosdb.CosmosDBQueryItems

(url=None, database_or_container_link=None, query=None, azure_credentials_secret="AZ_CREDENTIALS", options=None, partition_key=None, **kwargs)[source]

Task for creating an item in a Azure Cosmos database. Note that all initialization arguments can optionally be provided or overwritten at runtime.

Args:

  • url (str, optional): The url to the database.
  • database_or_container_link (str, optional): link to the database or container.
  • query (dict, optional): the query to run
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.QueryItems method.
  • partition_key (str, None): Partition key for the query.
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.azure.cosmosdb.CosmosDBQueryItems.run

(url=None, database_or_container_link=None, query=None, azure_credentials_secret="AZ_CREDENTIALS", options=None, partition_key=None)[source]

Task run method.

Args:

  • url (str, optional): The url to the database.
  • database_or_container_link (str, optional): link to the database or container.
  • query (dict, optional): the query to run
  • azure_credentials_secret (str, optional): the name of the Prefect Secret that stores your Azure credentials; this Secret must be JSON string with the key AZ_COSMOS_AUTH. The value should be dictionary containing masterKey or resourceTokens, where the masterKey value is the default authorization key to use to create the client, and resourceTokens value is the alternative authorization key.
  • options (dict, optional): options to be passed to the azure.cosmos.cosmos_client.CosmosClient.QueryItems method.
  • partition_key (str, None): Partition key for the query.
Returns:
  • (list): a list containing the query results, one item per row.



This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC