gpt4 book ai didi

azure - 如何将 Blob 生命周期规则添加到 ARM 模板

转载 作者:行者123 更新时间:2023-12-03 16:02:22 24 4
gpt4 key购买 nike

我已经根据现有资源组创建了 ARM 模板,

最近,我在帐户存储中向 Blob 存储添加了新配置,我需要管理其生命周期,幸运的是,可以通过添加规则在 Azure 门户上使用该配置:

enter image description here

或者添加以下 json 代码:

{
"rules": [
{
"name": "ruleFoo",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ],
"prefixMatch": [ "container1/foo" ]
},
"actions": {
"baseBlob": {
"tierToCool": { "daysAfterModificationGreaterThan": 30 },
"tierToArchive": { "daysAfterModificationGreaterThan": 90 },
"delete": { "daysAfterModificationGreaterThan": 2555 }
},
"snapshot": {
"delete": { "daysAfterCreationGreaterThan": 90 }
}
}
}
}
]
}

但我不清楚的是我的 blob 服务部分的哪一部分

{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "[variables('storageAccount_version')]",
"name": "[concat(variables('storageAccount_name'), '/default')]",
"tags": {
"displayName": "Storage Account - Blob Service"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount_name'))]"
],
"properties": {
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": false
}
}
},

如果有任何帮助,我将不胜感激!谢谢!

最佳答案

以下模板创建存储帐户及其 Blob 生命周期。

关键是使用存储帐户名称前缀命名生命周期资源并添加dependentOn 部分。

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "ajstoragetest444"
}
},
"resources": [
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"location": "westeurope",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
}
},
{
"name": "[concat(parameters('storageAccountName'), '/default')]",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"apiVersion": "2019-06-01",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
],
"properties": {
"policy": {
"rules": [
{
"name": "ruleFoo",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"container1/foo"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 2555
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 90
}
}
}
}
}
]
}
}
}
]
}

关于azure - 如何将 Blob 生命周期规则添加到 ARM 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61872368/

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