This repo has a prebuilt development environment making it easy to get started.
Open the repo in a development container using either Visual Studio Code or GitHub Codespaces.
-
Visual Studio Code: Clone this repo to your local machine and open the folder using the Dev containers extension.
-
GitHub Codespaces: Open this repo in the browser with a GitHub codespace.
Configure your Azure Cosmos DB credentials as environment variables.
export COSMOS_ENDPOINT="<cosmos-account-URI>"
export COSMOS_KEY="<cosmos-account-PRIMARY-KEY>"
💡 TIP: If you don't have an Azure Cosmos DB account, create a free account.
Run the quickstart sample app using the azure-cosmos
package from PyPI.
pip install azure-cosmos
python 001-quickstart/app.py
The application should output a single JSON object.
{
"id": "70b63682-b93a-4c77-aad2-65501347265f",
"categoryId": "61dba35b-4f02-45c5-b648-c6badc0cbd79",
"categoryName": "gear-surf-surfboards",
"name": "Yamba Surfboard",
"quantity": 12,
"sale": false,
"_rid": "yzN6AIfJxe0BAAAAAAAAAA==",
"_self": "dbs/yzN6AA==/colls/yzN6AIfJxe0=/docs/yzN6AIfJxe0BAAAAAAAAAA==/",
"_etag": "\"2a00ccd4-0000-0200-0000-63650e420000\"",
"_attachments": "attachments/",
"_ts": 16457527130
}
💡 TIP: The fields assigned by Azure Cosmos DB (ex.
id
) will vary from this sample output.
If you change the code, run the linter and code formatter.
pip install flake8
flake8 --verbose 001-quickstart/app.py
pip install black
black --verbose 001-quickstart/app.py
This project contains multiple samples used in Azure Cosmos DB for NoSQL documentation.