19

When I'm trying to add a new collection to database I'm getting this error :

Failed to create collection 'Products'.

Error:
Sorry, we are currently experiencing high demand in this region, and cannot 
fulfill your request at this time. We work continuously to bring more and 
more capacity online, and encourage you to try again. Please do not hesitate 
to email docdbswat@microsoft.com at any time or for any reason.
ActivityId: bad1a40a-0000-0000-0000-000000000000, 
Microsoft.Azure.Documents.Common/1.22.0.0

It's a local emulator, what kind of high demmand in this region ?

Nicu Besliu
  • 453
  • 5
  • 17
  • 1
    This is [documented behavior](https://learn.microsoft.com/en-us/azure/cosmos-db/local-emulator), if you exceed the maximum number of partitions configured for the emulator. – David Makogon Jul 31 '18 at 13:53

3 Answers3

17

According to the official documentation.

By default, you can create up to 25 single partition collections, or 1 partitioned collection using the Azure Cosmos DB Emulator. By modifying the PartitionCount value, you can create up to 250 single partition collections or 10 partitioned collections, or any combination of the two that does not exceed 250 single partitions (where one partitioned collection = 25 single partition collection).

So basically, if you want to create more partitioned collections or more single-partition collections, just increase the PartitionCount when starting from the command-line:

CosmosDB.Emulator.exe /PartitionCount=100
Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47
  • Didn't work for me. Why is the limitation there ? Isn't this supposed to work on a developer machine ... which we already have lots of collections to test and drop in a lots of projects – Jalal El-Shaer Oct 03 '18 at 10:43
  • Actually, it did work after cleanup and re-installation. I tried 250, but the computer became slow and takes time to boot the emulator. So I went back to the default. – Jalal El-Shaer Oct 03 '18 at 13:16
  • 2
    It will consume more environment resources, because it needs to allocate more space and resources for those partitions, that's why the default is not 250. – Matias Quaranta Oct 03 '18 at 13:19
  • 1
    I can't understand why it should allocate space and resources ahead of time. I thought it was just a "limitation" number. Anyway, I believe Microsoft should reconsider this – Jalal El-Shaer Oct 05 '18 at 11:51
  • 1
    How does one change this setting when running the emulator in Docker? – Shawn de Wet Jun 16 '21 at 05:39
  • @ShawndeWet did you find out? – sharpc Jul 18 '23 at 09:57
  • @sharpc nothing. I never did figure this out. – Shawn de Wet Jul 19 '23 at 04:07
  • @ShawndeWet you can use an env var (AZURE_COSMOS_EMULATOR_PARTITION_COUNT) and set it to an higher amount. The higher, the slower the container will start. – sharpc Jul 19 '23 at 10:19
5

Someone else on my team could get this working without the need for CosmosDB.Emulator.exe /PartitionCount=100. We could see that the containers where not being created.

Microsoft explains how to resolve this issue: https://learn.microsoft.com/en-us/azure/cosmos-db/local-emulator#set-partitioncount

enter image description here

enter image description here

  1. Reset Data
  2. Exit CosmosDb
  3. Go to %LOCALAPPDATA%\CosmosDBEmulator and delete all content
  4. Restart your machine for good measure

You should now be able to retry and all should work.

Sigex
  • 2,834
  • 2
  • 24
  • 25
3

The CosmosDB emulator has some limitations and this is the generic message that it will throw if you exceed those limitations.

The reason you got that is because you tried to make more than 10 collections in a database, but there are other reasons you might get the same error as well.

You can read more about the differences between the Emulator and the service here.

Nick Chapsas
  • 6,872
  • 1
  • 20
  • 29