使用 Bicep 模板 Azure 为 Blob 存储添加生命周期管理规则
Adding Life Cycle Management Rules for Blob Storage using Bicep Template Azure
我正在构建一个 azure bicep 文件来部署 Azure 资源。
在同一个 bicep 文件中,我正在创建一个存储帐户、几个容器和一些管理策略。在 Microsoft 文档中:
Before you configure a lifecycle management policy, you can choose to enable blob access time tracking. When access time tracking is enabled, a lifecycle management policy can include an action based on the time that the blob was last accessed with reading or write operation.
虽然我在根据文档启用上次访问时间跟踪策略方面遵循文档,并且 运行 同一 bicep 文件中的管理策略,但我仍然 运行此错误:
"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details. Last access time based tracking policy must be enabled before using its specific actions in object lifecycle management policy"
这是我的二头肌文件:
resource storage_account_blob 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'test'
location: 'East US'
sku: {
name: 'Standard_RAGRS'
}
kind: 'StorageV2'
properties: {
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: []
ipRules: []
defaultAction: 'Allow'
}
supportsHttpsTrafficOnly: true
encryption: {
services: {
file: {
keyType: 'Account'
enabled: true
}
blob: {
keyType: 'Account'
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
}
}
resource blobStorageService 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
parent: storage_account_blob
name: 'default'
properties: {
lastAccessTimeTrackingPolicy: {
blobType: [
'string'
]
enable: true
name: 'AccessTimeTracking'
trackingGranularityInDays: 1
}
}
}
resource blobStorage_container_input 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
name: 'input'
properties: {
defaultEncryptionScope: '$account-encryption-key'
denyEncryptionScopeOverride: false
publicAccess: 'None'
}
parent: blobStorageService
}
resource management_policies 'Microsoft.Storage/storageAccounts/managementPolicies@2019-06-01' = {
name: 'default'
properties: {
policy:{
rules: [
{
definition:{
actions:{
baseBlob:{
delete:{
daysAfterLastAccessTimeGreaterThan: 60
}
tierToArchive:{
daysAfterLastAccessTimeGreaterThan: 30
}
tierToCool:{
daysAfterLastAccessTimeGreaterThan:15
}
}
}
filters:{
blobTypes:[
'blockBlob'
]
}
}
enabled: true
name: 'testRules'
type: 'Lifecycle'
}
]
}
}
parent: storage_account_blob
}
在创建生命周期管理策略之前,我是否必须首先使用 blob 服务创建存储帐户?
我不确定,但您是否尝试过在“资源 management_policies”上设置“取决于”并将其指向“资源 blobStorageService”。
我正在构建一个 azure bicep 文件来部署 Azure 资源。
在同一个 bicep 文件中,我正在创建一个存储帐户、几个容器和一些管理策略。在 Microsoft 文档中:
Before you configure a lifecycle management policy, you can choose to enable blob access time tracking. When access time tracking is enabled, a lifecycle management policy can include an action based on the time that the blob was last accessed with reading or write operation.
虽然我在根据文档启用上次访问时间跟踪策略方面遵循文档,并且 运行 同一 bicep 文件中的管理策略,但我仍然 运行此错误:
"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details. Last access time based tracking policy must be enabled before using its specific actions in object lifecycle management policy"
这是我的二头肌文件:
resource storage_account_blob 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'test'
location: 'East US'
sku: {
name: 'Standard_RAGRS'
}
kind: 'StorageV2'
properties: {
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: []
ipRules: []
defaultAction: 'Allow'
}
supportsHttpsTrafficOnly: true
encryption: {
services: {
file: {
keyType: 'Account'
enabled: true
}
blob: {
keyType: 'Account'
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
}
}
resource blobStorageService 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
parent: storage_account_blob
name: 'default'
properties: {
lastAccessTimeTrackingPolicy: {
blobType: [
'string'
]
enable: true
name: 'AccessTimeTracking'
trackingGranularityInDays: 1
}
}
}
resource blobStorage_container_input 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = {
name: 'input'
properties: {
defaultEncryptionScope: '$account-encryption-key'
denyEncryptionScopeOverride: false
publicAccess: 'None'
}
parent: blobStorageService
}
resource management_policies 'Microsoft.Storage/storageAccounts/managementPolicies@2019-06-01' = {
name: 'default'
properties: {
policy:{
rules: [
{
definition:{
actions:{
baseBlob:{
delete:{
daysAfterLastAccessTimeGreaterThan: 60
}
tierToArchive:{
daysAfterLastAccessTimeGreaterThan: 30
}
tierToCool:{
daysAfterLastAccessTimeGreaterThan:15
}
}
}
filters:{
blobTypes:[
'blockBlob'
]
}
}
enabled: true
name: 'testRules'
type: 'Lifecycle'
}
]
}
}
parent: storage_account_blob
}
在创建生命周期管理策略之前,我是否必须首先使用 blob 服务创建存储帐户?
我不确定,但您是否尝试过在“资源 management_policies”上设置“取决于”并将其指向“资源 blobStorageService”。