gpt4 book ai didi

azure - 设置 Azure 中 BLOB 存储的保留期

转载 作者:行者123 更新时间:2023-12-05 06:33:02 26 4
gpt4 key购买 nike

我想手动设置保留期,以便在保留期结束后我可以删除我的存档数据。请向我建议任何可以帮助我的链接或方式。请建议我如何在我的门户中编写代码来设置它。

最佳答案

我已成功配置 lifecycle management policy ,它完全可以使用 ARM 模板完成您想要做的事情。这是最小的工作示例:

 }
"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 }
}
}
}
}
]
}
}
}

在此示例中,我使用 trackingGranularityInDays 字段将搜索设置为每天进行一次,并在 90 天后删除 BLOB。

关于azure - 设置 Azure 中 BLOB 存储的保留期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50952681/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com