Gallery › Storage › Azure Community Policy
Deny - Minimum soft delete retention for Blob services
Converted Policy Audit Deny Disabled Mode All Version 1.0.0-preview
Blob services must have the the minimum specified soft delete retention in days for blobs and containers.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 68 lines
{
"name": "10fef8bf-2c9c-4a62-8848-6e92ac17dedd",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deny - Minimum soft delete retention for Blob services",
"description": "Blob services must have the the minimum specified soft delete retention in days for blobs and containers.",
"metadata": {
"version": "1.0.0-preview",
"category": "Storage"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Deny"
},
"retentionInDays": {
"type": "Integer",
"metadata": {
"displayName": "Retention in Days",
"description": "Minimum soft delete retention in days for blobs and containers."
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts/blobServices"
},
{
"anyOf": [
{
"field": "Microsoft.Storage/storageAccounts/blobServices/containerDeleteRetentionPolicy.enabled",
"equals": false
},
{
"field": "Microsoft.Storage/storageAccounts/blobServices/containerDeleteRetentionPolicy.days",
"less": "[parameters('retentionInDays')]"
},
{
"field": "Microsoft.Storage/storageAccounts/blobServices/deleteRetentionPolicy.enabled",
"equals": false
},
{
"field": "Microsoft.Storage/storageAccounts/blobServices/deleteRetentionPolicy.days",
"less": "[parameters('retentionInDays')]"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw10fef8bf-2c9c-4a62-8848-6e92ac17dedd.bylaw.ps1 · 44 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '10fef8bf-2c9c-4a62-8848-6e92ac17dedd' {
Properties @{
DisplayName = 'Deny - Minimum soft delete retention for Blob services'
Description = 'Blob services must have the the minimum specified soft delete retention in days for blobs and containers.'
Version = '1.0.0-preview'
Category = 'Storage'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter RetentionInDays @{
Type = 'Integer'
DisplayName = 'Retention in Days'
Description = 'Minimum soft delete retention in days for blobs and containers.'
}
Resource 'Microsoft.Storage/storageAccounts/blobServices' {
Require 'containerDeleteRetentionPolicy.enabled is not false' {
Field containerDeleteRetentionPolicy.enabled | Must -Not -Be $false -IfPresent
}
Require 'containerDeleteRetentionPolicy.days is at least the RetentionInDays parameter' {
Field containerDeleteRetentionPolicy.days | Must -BeGreaterOrEqual (Param RetentionInDays) -IfPresent
}
Require 'deleteRetentionPolicy.enabled is not false' {
Field deleteRetentionPolicy.enabled | Must -Not -Be $false -IfPresent
}
Require 'deleteRetentionPolicy.days is at least the RetentionInDays parameter' {
Field deleteRetentionPolicy.days | Must -BeGreaterOrEqual (Param RetentionInDays) -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Storage/deny-blob-softdelete-retention/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw