[英]how to set retention period for azure storage tables?
I have a azure table used for metric data collection and I want to set some retention period for eg: if retention period is 7 then table should have last 7 day data in it.我有一个用于指标数据收集的 azure 表,我想设置一些保留期,例如:如果保留期为 7,则表中应包含最近 7 天的数据。
Is there any option available.有没有可用的选项。
I have a azure table used for metric data collection and I want to set some retention period for eg: if retention period is 7 then table should have last 7 day data in it.
我有一个用于指标数据收集的 azure 表,我想设置一些保留期,例如:如果保留期为 7,则表中应包含最近 7 天的数据。
Is there any option available.
有没有可用的选项。
As of today, No such thing is available for Azure Tables (or for Blobs and Files).截至今天,Azure 表(或 Blob 和文件)还没有这样的东西。 You would need to roll something out of your own.
你需要自己推出一些东西。 One possible solution would be to write a background job (either as WebJob or Azure Function) that runs periodically and finds the entities that have been created before "x" days (7 in your example) and delete those entities.
一种可能的解决方案是编写一个后台作业(作为 WebJob 或 Azure 函数),该作业定期运行并查找在“x”天(在您的示例中为 7 天)之前创建的实体并删除这些实体。
There's no way in Azure storage to specify auto-archival. Azure 存储无法指定自动存档。 What I typically do with my storage tables, is create monthly storage tables.
我通常对存储表做的是创建每月存储表。 Data gets inserted according to its timestamp into appropriate "Orders201701" or "Orders201612", etc. tables.
数据根据其时间戳插入到适当的“Orders201701”或“Orders201612”等表中。 Then purge old tables when they contain data that's no longer relevant.
然后在旧表包含不再相关的数据时清除旧表。
You can make your data access layer abstract the consumer away from this complexity by auto-joining results from queries that span multiple months.您可以通过自动连接跨越几个月的查询的结果,让您的数据访问层从这种复杂性中抽象出消费者。
If you're dealing with native Azure diagnostics storage, you're out of luck.如果您正在处理本机 Azure 诊断存储,那么您就不走运了。 However, you can just delete those tables once in a while and Azure will recreate them.
但是,您可以偶尔删除这些表,Azure 会重新创建它们。
Do keep in mind that manually delete data in tables is pretty laborious task - you need to download the Partition Keys/Row Keys first, then execute delete commands in a loop of up to 100 batched rows at the same time.请记住,手动删除表中的数据是一项非常费力的任务 - 您需要先下载分区键/行键,然后在最多 100 个批处理行的循环中同时执行删除命令。 Pretty inefficient.
相当低效。
You can make a new table each week.您可以每周制作一张新桌子。 Your reading layer should abstract away this thing.
你的阅读层应该抽象出这个东西。 And you can delete old tables entirely which is cheaper then fetching keys and deleting insicidual rows
你可以完全删除旧表,这比获取键和删除 insicidual 行更便宜
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.