Script that creates a user for your cosmosdb container.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.rst
create_db_and_creds.py
requirements.txt

README.rst

Create CosmosDB Database and Corresponding User

Script creates a database in CosmosDB container and a corresponding user. As output, it prints a temporary token for the user.

Notice: cosmosdb does not support users as you would expect in a database. You have to use your service keys (az cosmosdb get-keys --resource-group RESOURCE_GROUP --name COSMOSDB_CONTAINER) or temporary user/token. The temporary user/token will not work if you want to use the mongodb client.

# az cosmosdb show --resource-group RESOURCE_GROUP --name COSMOSDB_NAME --query 'documentEndpoint' -o tsv
export COSMOSDB_ENDPOINT=
# az cosmosdb list-keys --resource-group RESOURCE_GROUP --name COSMOSDB_NAME --query 'primaryMasterKey' -o tsv
export COSMOSDB_MASTERKEY=
export USER_NAME=
export DB_NAME=

python create_db_and_creds.py

If you want to automatize CosmosDB, the best source are the tests for CosmosDB python client. You will find the links below.

Reference