Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
swails and christopheranderson Fix context manager exit method in sample (#159)
* Fix context manager exit method in sample

Assigning `self = None` does nothing -- it rebinds `self` to `None` and then goes out of scope, leaving the reference to the client intact.

* Fix the rest of the examples with respect to cleanup

* This fixes a number of minor issues

* You can simply "raise" when inside an except block to re-raise the
same exception. That way you get the original traceback.
* This fixes Python 3 support by removing stuff allowed in Python 2 but
forbidden in Python 3 (inconsistent indentation and e.message -> e)
* Fixes what would be a NameError
Latest commit e6118a9 May 8, 2019

Microsoft Azure Cosmos Python SDK

Welcome to the repo containing all things Python for the Azure Cosmos DB API which is published with name azure-cosmos. For documentation please see the Microsoft Azure link.


Python 2.7, Python 3.3, Python 3.4, or Python 3.5

If you use Microsoft Visual Studio as IDE (we use 2015), please install the following extension for Python.

Install Cosmos DB emulator Follow instruction at


$ python install


$ pip install azure-cosmos

Running Testing

Clone the repo

git clone
cd azure-cosmos-python

Most of the test files under test sub-folder require you to enter your Azure Cosmos master key and host endpoint:

masterKey = '[YOUR_KEY_HERE]'

To run the tests:

$ python -m unittest discover -s .\test -p "*.py" 

If you use Microsoft Visual Studio, open the project file python.pyproj,
and run all the tests in Test Explorer.

Most of the test cases create containers in your Cosmos account. Containers are billing entities. By running these test cases, you may incur monetary costs on your account.

Documentation generation

Install Sphinx:

$ cd doc
$ sphinx-apidoc -f -e -o api ..\azure\cosmos
$ make.bat html
You can’t perform that action at this time.