首页 > 解决方案 > 使用 Azure CLI 创建 Cosmos DB 容器时出现“找不到资源”错误

问题描述

我正在运行以下命令来为我的 Cosmos DB 创建一个容器,该容器是我从手册中复制并替换为我的帐户值的。

az cosmosdb sql container create -g pluralSight -a pluralsightgreetingbot -d greetingbot -n messages --partition-key-path "/messages"

错误提示“找不到资源”。我仔细检查了我的输入,一切似乎都很好。

在此处输入图像描述

这是作为输出的完整错误:

Command group 'cosmosdb sql' is in preview. It may be changed/removed in a future release.
Deployment failed. Correlation ID: 13db110d-62e6-4a8e-93f9-27c6fbcde5e9. Message: {"code":"NotFound","message":"Message: {\"Errors\":[\"Resource Not Found\"]}\r\nActivityId: b8e95cb7-0f13-11ea-a134-f4f26d19196a, Request URI: /apps/d56d4719-881c-450a-8a93-f55ae16f5b41/services/01ec4f79-1a4b-4571-8706-a9d9e210e4db/partitions/fff88e8a-d1bf-4dc0-812f-cc8c8b985b82/replicas/132188457808536080s, RequestStats: \r\nRequestStartTime: 2019-11-24T23:40:02.0661568Z, RequestEndTime: 2019-11-24T23:40:02.0661568Z,  Number of regions attempted:1\r\nResponseTime: 2019-11-24T23:40:02.0661568Z, StoreResult: StorePhysicalAddress: rntbd://10.0.0.26:11300/apps/d56d4719-881c-450a-8a93-f55ae16f5b41/services/01ec4f79-1a4b-4571-8706-a9d9e210e4db/partitions/fff88e8a-d1bf-4dc0-812f-cc8c8b985b82/replicas/132188457808536080s, LSN: 3, GlobalCommittedLsn: 3, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#3, UsingLocalLSN: False, TransportException: null, ResourceType: Database, OperationType: Read\r\nResponseTime: 2019-11-24T23:40:02.0661568Z, StoreResult: StorePhysicalAddress: rntbd://10.0.0.24:11000/apps/d56d4719-881c-450a-8a93-f55ae16f5b41/services/01ec4f79-1a4b-4571-8706-a9d9e210e4db/partitions/fff88e8a-d1bf-4dc0-812f-cc8c8b985b82/replicas/132189292853257376s, LSN: 3, GlobalCommittedLsn: 3, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#3, UsingLocalLSN: False, TransportException: null, ResourceType: Database, OperationType: Read\r\n, SDK: Microsoft.Azure.Documents.Common/2.7.0"}, Request URI: /dbs/MyDatabase/colls, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0, Microsoft.Azure.Documents.Common/2.7.0

标签: azureazure-cosmosdbazure-cli

解决方案


您需要先单独创建数据库资源。集合创建不会同时创建数据库。很确定“找不到资源”是仍然需要创建的数据库。

这是通过类似的az命令完成的。在您的情况下,类似于:

az cosmosdb sql database create -a pluralsightgreetingbot -g pluralSight -n greetingbot --throughput 400 

推荐阅读