2017-05-02 41 views
0

我试图在不同的集合之间平衡我的工作负载,每个集合高达10GB,并且我需要知道是否有办法知道使用c#的特定集合中的可用空间是多少,以便自动执行此过程。有没有办法知道使用c#中documentdb集合中的可用空间?

+0

看看[这个答案](http://stackoverflow.com/a/35298151/272109)我张贴了一段时间回来,这也解释了什么是在'返回X-MS-资源使用率'和'x-ms-resource-quota'标头执行请求。这可能会给你一个好主意,如何完成你要找的东西。 –

回答

0

正如David Makogon在他的评论中提到的,我们可以从ResourceResponse获取资源使用信息。请使用DocumentClient.ReadDocumentCollectionAsync方法参考以下示例代码,该方法返回包含许多使用属性的ResourceResponse。

var colls = await client.ReadDocumentCollectionFeedAsync(UriFactory.CreateDatabaseUri("database id")); 

Console.WriteLine("\nReading all DocumentCollection resources for a database"); 

foreach (var coll in colls) 
{ 
    ResourceResponse<DocumentCollection> response = await client.ReadDocumentCollectionAsync(coll.SelfLink); 

    Console.WriteLine(coll.Id + "; " + response.CollectionSizeUsage.ToString()); 

    //or retrieve resource usage from response.ResponseHeaders["x-ms-resource-usage"] 
} 
+0

@Julio,有没有更新?你能够检索使用属性?如果我的回复有帮助,请将其标记为答案,这有助于他人快速找到答案并解决类似问题。 –

相关问题