添加新集合时对 Azure Cosmos DB 模拟器的高要求

High demand on Azure Cosmos DB Emulator when adding a new collection

当我尝试向数据库添加新集合时出现此错误:

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

本地模拟器,这个地区需求量大吗?

CosmosDB 模拟器有一些限制,如果您超出这些限制,这是它会抛出的一般消息。

你得到这个的原因是因为你试图在数据库中创建超过 10 个集合,但还有其他原因你也可能会遇到同样的错误。

您可以阅读有关 differences between the Emulator and the service here 的更多信息。

根据 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).

所以基本上,如果您想创建更多分区集合或更多单分区集合,只需在从命令行启动时增加 PartitionCount

CosmosDB.Emulator.exe /PartitionCount=100

我团队中的其他人可以在不需要 CosmosDB.Emulator.exe /PartitionCount=100 的情况下完成这项工作。我们可以看到没有创建容器。

Microsoft 解释了如何解决此问题: https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator#set-partitioncount

  1. 重置数据
  2. 退出 CosmosDb
  3. 转到%LOCALAPPDATA%\CosmosDBEmulator并删除所有内容
  4. 重启你的机器

您现在应该可以重试并且一切正常。