Manfred Lange
2 min readApr 8, 2022


Hi Ankit,

I'm not quite sure I fully understand what you are trying to accomplish. Therefore I'll attempt to respond in a more general way. I hope this is still helpful.

In principle it is possible to run up multiple instance of the CosmosDB Emulator container. You just need to make sure they will be at different port numbers. And if two or more are in the same virtual network you'll also need to make sure each has a different IP address from the address range of that virtual network. If you use multiple instances and in particular if you use different IP addresses, you need to make sure you extract the correct SSL certificate and install it in the containers that need access to the respective cosmos db emulator instance.

Having said that, I'd wager that you probably won't need more than one Cosmos DB emulator per virtual network. In essence it's like any other database (server). For testing purposes you could have each test to use a different distinct data set, so different tests don't interfere with each other.

A more expensive (processing time!) approach would be to delete all data at the tear down of each test. However, this is likely to become prohibitive. This kind of test tends to be quite slow.

Yet another technique to consider is this: Use the "Repository Pattern". Then you'd have a set of tests for each repository. All other tests could then mock the repository, run at full speed (no db server round-trip!) and therefore complete faster.

I hope some of this helps with finding a suitable approach forward.