获得的BLOB数在Azure存储容器 [英] Getting blob count in an Azure Storage container

查看:169
本文介绍了获得的BLOB数在Azure存储容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最有效的方式得到的斑点在Azure存储容器?

数计数

现在我想不出比低于code以外的任何方式:

  CloudBlobContainer容器= GetContainer(myContainer中);
变种数= container.ListBlobs()计数()。


解决方案

该API不包含容器计数方法或属性,因此,你需要做这样的事情,你有什么公布。然而,你需要处理NextMarker如果超过5,000个项目退回(或者指定最大#返回,并在列表超过数)。然后你要让基于NextMarker用户互动,增加呼叫并添加计数。

编辑:每smarx:该SDK应该照顾NextMarker的为您服务。你需要处理NextMarker如果你在API层面的工作,呼吁列表斑点通过REST。

另外,如果你控制BLOB插入/缺失(通过WCF服务,例如),您可以使用BLOB容器的元数据区存储您每次插入计算或删除缓存容器计数。你只需要处理并发写入到容器中。

What is the most efficient way to get the count on the number of blobs in an Azure Storage container?

Right now I can't think of any way other than the code below:

CloudBlobContainer container = GetContainer("mycontainer");
var count = container.ListBlobs().Count();

解决方案

The API doesn't contain a container count method or property, so you'd need to do something like what you posted. However, you'll need to deal with NextMarker if you exceed 5,000 items returned (or if you specify max # to return and the list exceeds that number). Then you'll make add'l calls based on NextMarker and add the counts.

EDIT: Per smarx: the SDK should take care of NextMarker for you. You'll need to deal with NextMarker if you're working at the API level, calling List Blobs through REST.

Alternatively, if you're controlling the blob insertions/deletions (through a wcf service, for example), you can use the blob container's metadata area to store a cached container count that you compute with each insert or delete. You'll just need to deal with write concurrency to the container.

这篇关于获得的BLOB数在Azure存储容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆