[英]Azure BLOB storage Life Cycle Management - Append Blob vs Block blob
I realize Azure Blob Storage Life Cycle Management supports only Block blobs.我意识到 Azure Blob 存储生命周期管理仅支持块 blob。 It doesn't support Append or Page blobs.
它不支持 Append 或页面 blob。
A solution we are considering is to - do the crude way - of enumerating blobs in each of the containers from a logic app or function app, and deleting based on certain rules similar to Azure's storage Life Cycle Management, say, modified date is n days old.我们正在考虑的一个解决方案是 - 采用粗略的方式 - 从逻辑应用程序或 function 应用程序中枚举每个容器中的 blob,并根据类似于 Azure 存储生命周期管理的某些规则进行删除,例如,修改日期为 n 天老的。
Has anyone run into a similar requirement of cleaning up storage?有没有人遇到过清理存储的类似要求? Could anyone suggest a better way of implementing this?
任何人都可以提出更好的实施方式吗?
Greatly appreciate it.非常感谢。
Thank you Athadu谢谢阿萨杜
The only way I can think of same as you mentioned, create a timer trigger function app or webjob.我能想到的唯一方法与您提到的相同,创建一个计时器触发器 function 应用程序或网络作业。
Here is the sample:这是示例:
Blob storage package: Microsoft.Azure.Storage.Blob, version 11.1.3 Blob 存储 package: Microsoft.Azure.Storage.Blob,版本 11.1.3
The sample code:示例代码:
static void Main(string[] args)
{
var connection_str = "xxxxx";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connection_str);
CloudBlobClient cloudBlobClient=storageAccount.CreateCloudBlobClient();
//list all the containers
var containers = cloudBlobClient.ListContainers();
foreach (var container in containers)
{
Console.WriteLine(container.Name);
//find blobs whose type is CloudAppendBlob
var blobs = container.ListBlobs("", useFlatBlobListing: true).OfType<CloudAppendBlob>();
if (blobs.ToList().Count() <=0) continue;
foreach (var blob in blobs)
{
Console.WriteLine($"blob name is {blob.Name}");
//add your own logic here
//if condition use blob.Properties.LastModified
blob.Delete();
}
}
}
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.