Skip to content

CosmosDB

Bases: Spout

__init__(output, state, **kwargs)

Initialize the Cosmos DB class.

Parameters:

Name Type Description Default
output BatchOutput

An instance of the BatchOutput class for saving the data.

required
state State

An instance of the State class for maintaining the state.

required
**kwargs

Additional keyword arguments.

{}

Using geniusrise to invoke via command line

genius CosmosDB rise \
    batch \
        --output_s3_bucket my_bucket \
        --output_s3_folder s3/folder \
    none \
    fetch \
        --args endpoint=https://mycosmosdb.documents.azure.com:443/ my_database my_collection

Using geniusrise to invoke via YAML file

version: "1"
spouts:
    my_cosmosdb_spout:
        name: "CosmosDB"
        method: "fetch"
        args:
            endpoint: "https://mycosmosdb.documents.azure.com:443/"
            database: "my_database"
            collection: "my_collection"
        output:
            type: "batch"
            args:
                bucket: "my_bucket"
                s3_folder: "s3/folder"

fetch(endpoint, database, collection)

📖 Fetch data from a Cosmos DB collection and save it in batch.

Parameters:

Name Type Description Default
endpoint str

The Cosmos DB endpoint URL.

required
database str

The Cosmos DB database name.

required
collection str

The Cosmos DB collection name.

required

Raises:

Type Description
Exception

If unable to connect to the Cosmos DB server or execute the query.