【问题标题】:Error while fetching page of documents in Azure CosmosDB Portal在 Azure CosmosDB 门户中获取文档页面时出错
【发布时间】:2019-02-28 06:34:21
【问题描述】:

所以我使用 Microsoft 的 Microsoft.Azure.DocumentDB.Core api 从我的 .Net Core 应用程序连接到我的 Cosmos DB。

一切正常,我可以创建、编辑和获取文档,以及创建新的数据库或集合。如果我使用 DocumentDB.Core api 创建数据库或集合,我可以在我的 azure 门户中看到它们。但是,当我创建文档时,我看不到它们。每当我尝试加载我的文档时,我收到此错误的次数等于我拥有的文档数。

Error while fetching page of documents {"code":400,"body":"Command find failed: Unknown server error occurred when processing this request.."}

我知道我有现有的记录,因为如果我保存我在创建时返回的 ID,然后我可以使用 DocumentDB.Core api 查找它。

这是我传递的模型:

public class Api
{
    public Api()
    {
        Client = new ExpandoObject();
    }

    [JsonProperty(PropertyName = "id")]
    public string Id { get; set; }


    public ExpandoObject Client { get; set; }

}

现在,在我切换到 DocumentDB.Core 之前,我使用的是 MongoDB.Driver,这是我的模型:

public class Api
{
    public Api()
    {
        Client = new ExpandoObject();
    }

    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; }


    [BsonElement("client")]
    public ExpandoObject Client { get; set; }

}

使用 MongoDB.Driver 和上述模型,我能够在 azure 门户中看到我的数据。

使用 Microsoft 自己的工具在 Azure CosmosDB 门户中看不到数据是否有原因?我错过了财产吗?我注意到唯一不同的是,使用 MongoDB.Drive,我创建的文档中的 id 是 _id,使用 DocumentDB.Core,我创建的文档中的 id 是 id。我不确定这是否重要,或者如何解决。

【问题讨论】:

    标签: mongodb azure asp.net-core azure-cosmosdb


    【解决方案1】:

    这里有类似的问题,你可以看看:

    Importing Json using DocumentDB Data Migration tool gives "Error while fetching page of documents code: 400" in CosmosDB

    进一步了解,以下可能是错误代码400的原因:-

    -请求正文中的 JSON、SQL 或 JavaScript 无效。

    -此外,当资源的所需属性不存在或未在资源的 POST 或 PUT 正文中设置时,也可以返回 400。

    当 GET 操作的一致性级别被帐户设置的更强一致性覆盖时,也会返回-400。

    当需要 x-ms-documentdb-partitionkey 的请求不包含它时,也会返回 -400。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-03
      • 2022-01-21
      • 2019-07-14
      • 1970-01-01
      相关资源
      最近更新 更多