将Blob生命周期规则添加到ARM模板是通过在ARM模板中定义存储帐户的属性来实现的。具体步骤如下:
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "mystorageaccount",
"location": "chinaeast",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"supportsHttpsTrafficOnly": true,
"allowBlobPublicAccess": false,
"minimumTlsVersion": "TLS1_2",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"blobServices": {
"properties": {
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": true,
"days": 30
},
"containerDeleteRetentionPolicy": {
"enabled": true,
"days": 7
},
"automaticSnapshotPolicyEnabled": false,
"changeFeed": {
"enabled": false
},
"restorePolicy": {
"enabled": false
}
}
}
}
}
deleteRetentionPolicy
和containerDeleteRetentionPolicy
属性用于定义Blob和容器的生命周期规则。deleteRetentionPolicy
定义了Blob的删除保留策略,containerDeleteRetentionPolicy
定义了容器的删除保留策略。可以根据需求修改enabled
和days
的值。总结起来,将Blob生命周期规则添加到ARM模板的步骤包括定义存储帐户资源,并在其中设置deleteRetentionPolicy
和containerDeleteRetentionPolicy
属性来定义Blob和容器的删除保留策略。然后将ARM模板部署到Azure资源管理器中即可生效。
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云