airflow.providers.microsoft.azure.hooks.cosmos
¶
This module contains integration with Azure CosmosDB.
AzureCosmosDBHook communicates via the Azure Cosmos library. Make sure that a Airflow connection of type azure_cosmos exists. Authorization can be done by supplying a login (=Endpoint uri), password (=secret key) and extra fields database_name and collection_name to specify the default database and collection to use (see connection azure_cosmos_default for an example).
Module Contents¶
-
class
airflow.providers.microsoft.azure.hooks.cosmos.
AzureCosmosDBHook
(azure_cosmos_conn_id: str = default_conn_name)[source]¶ Bases:
airflow.hooks.base.BaseHook
Interacts with Azure CosmosDB.
login should be the endpoint uri, password should be the master key optionally, you can use the following extras to default these values {"database_name": "<DATABASE_NAME>", "collection_name": "COLLECTION_NAME"}.
- Parameters
azure_cosmos_conn_id (str) -- Reference to the Azure CosmosDB connection.
-
does_collection_exist
(self, collection_name: str, database_name: str)[source]¶ Checks if a collection exists in CosmosDB.
-
create_collection
(self, collection_name: str, database_name: Optional[str] = None)[source]¶ Creates a new collection in the CosmosDB database.
-
delete_collection
(self, collection_name: str, database_name: Optional[str] = None)[source]¶ Deletes an existing collection in the CosmosDB database.
-
upsert_document
(self, document, database_name=None, collection_name=None, document_id=None)[source]¶ Inserts a new document (or updates an existing one) into an existing collection in the CosmosDB database.
-
insert_documents
(self, documents, database_name: Optional[str] = None, collection_name: Optional[str] = None)[source]¶ Insert a list of new documents into an existing collection in the CosmosDB database.
-
delete_document
(self, document_id: str, database_name: Optional[str] = None, collection_name: Optional[str] = None)[source]¶ Delete an existing document out of a collection in the CosmosDB database.
-
airflow.providers.microsoft.azure.hooks.cosmos.
get_database_link
(database_id: str) → str[source]¶ -
Get Azure CosmosDB database link