简体   繁体   English

在 Azure 中的 BLOB 存储中设置保留期

[英]Set Retention Period in BLOB Storage in Azure

I want to SET RETENTION Period manually so that I can delete my archived data once retention period is over.我想手动设置保留期,以便在保留期结束后删除我的存档数据。 Please suggest me any link or way which could help me.请向我建议任何可以帮助我的链接或方式。 Please suggest how I will be able to code in my portal to set it.请建议我将如何在我的门户中编码来设置它。

Note the approach I mention is not the direct approach of setting the retention duration per blob but a higher level policy which can affect the whole storage account or specific containers or specific blobs which match some filtration criteria.请注意,我提到的方法不是设置每个 blob 的保留持续时间的直接方法,而是更高级别的策略,它可以影响整个存储帐户或特定容器或匹配某些过滤条件的特定 blob。 As of March 2021, I haven't yet found a way to set the retention period oa per blob basis via the Azure API.截至 2021 年 3 月,我还没有找到通过 Azure API 设置每个 blob 保留期 oa 的方法。

Link to Lifecycle Management for Azure Blobs for Azure Storage V2 链接到 Azure Blob for Azure Storage V2 的生命周期管理

I have successfully configured a lifecycle management policy , which does exactly what you want to do, with ARM templates.我已经使用 ARM 模板成功配置了一个生命周期管理策略,它完全符合您的要求。 Here's the minimal working example:这是最小的工作示例:

 }
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2021-04-01",
  "name": "[variables('storageAccountName']",
  "location": "[resourceGroup().location]",
  "sku": {
    "name": "Standard_LRS",
    "tier": "Standard"
  },
  "kind": "StorageV2",
  "properties": {
    "minimumTlsVersion": "TLS1_2"
  }
},
{
  "type": "Microsoft.Storage/storageAccounts/blobServices",
  "apiVersion": "2021-02-01",
  "name": "[concat(variables('storageAccountName'), '/', 'default')]",
  "dependsOn": ["[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"],
  "properties": {
    "lastAccessTimeTrackingPolicy": {
      "blobType": [ "string" ],
      "enable": true,
      "name": "AccessTimeTracking",
      "trackingGranularityInDays": 1
    }
  }
},
{
  "type": "Microsoft.Storage/storageAccounts/managementPolicies",
  "apiVersion": "2021-02-01",
  "name": "[concat(variables('storageAccountName'), '/', 'default')]",
  "dependsOn": ["[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"],
  "properties": {
    "policy": {
      "rules": [
        {
          "name": "expirationRule",
          "enabled": true,
          "type": "Lifecycle",
          "definition": {
            "filters": {
              "blobTypes": [ "blockBlob" ]
            },
            "actions": {
              "baseBlob": {
                "delete": { "daysAfterModificationGreaterThan": 90 }
              }
            }
          }
        }
      ]
    }
  }
}

In this example, I have setup the search to happen once a day with the trackingGranularityInDays field, and the BLOBs to be deleted after 90 days.在此示例中,我使用trackingGranularityInDays字段将搜索设置为每天发生一次,并在 90 天后删除 BLOB。

You can create using Azure Automation account.您可以使用 Azure 自动化帐户创建。

You can try the following PowerShell script to remove Old Azure Storage Blobs.您可以尝试使用以下 PowerShell 脚本来删除旧的 Azure 存储 Blob。 The below script works for the Classic Storage accounts, you can modify the script for the ARM Storage account.以下脚本适用于经典存储帐户,您可以修改 ARM 存储帐户的脚本。

https://www.wikitechy.com/tutorials/azure/delete-blobs-in-blob-storage-older-than-a-number-of-days https://www.wikitechy.com/tutorials/azure/delete-blobs-in-blob-storage-older-than-a-number-of-days

https://gist.github.com/philskents/4e61ebe418a7861ed294044814d193d7#file-remove-oldazurestorageblob-ps1 https://gist.github.com/philskents/4e61ebe418a7861ed294044814d193d7#file-remove-oldazurestorageblob-ps1

https://strangeadventures.in/deletingoldfilesfromazureblobstorage/ https://strangeadventures.in/deletingoldfilesfromazureblobstorage/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM