簡體   English   中英

使用 Azure Android ZF20E3C5DAZ60C0893F53Z 在 azure Cosmos-db 中創建文檔失敗

[英]Failed to Create document in to azure Cosmos-db using Azure Android SDK

我正在使用 azure android SDK 將新記錄添加到集合項中。 我們的 cosmos-DB 沒有分區鍵。 所以我作為 null 傳遞給它。

它會給我以下錯誤

x-ms-partitionkey header 中提供的分區鍵的組件少於集合中定義的組件

誰能幫我擺脫困境?

您需要使用 @PartitionKey 注釋將您正在使用的屬性標記為分區鍵,例如:

@PartitionKey
    var testKey = ""

在 C# 中,我們使用 Undefined.Value 一切都會好起來的。

client.DeleteDocumentAsync(
          UriFactory.CreateDocumentUri(DbName, CollectionName, id), 
          new RequestOptions() { PartitionKey = new PartitionKey(Undefined.Value) });

azure android SDK 所需的分區鍵,它不接受 Z37A6259CC0C1DAE299A786648 或空。 此外,如果您有一堆記錄要存儲在 cosmos DB 中,那么您必須使用分區鍵,否則您將來可能會遇到分區鍵限制達到的問題。 Azure 為邏輯分區提供最大 10 GB 的空間。

我已經使用用戶明智的分區創建了一個新集合並傳遞了分區鍵值,例如。 我的 object 中的patitionKey=/.UserID 這對我有用。 還管理分區鍵限制問題。

所以最好提前使用分區鍵,以免以后出現問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM