Gallery › Storage › Azure built-in policies
Configure your Storage account public access to be disallowed
Converted Policy Disabled Modify Mode Indexed Version 1.0.0
Anonymous public read access to containers and blobs in Azure Storage is a convenient way to share data but might present security risks. To prevent data breaches caused by undesired anonymous access, Microsoft recommends preventing public access to a storage account unless your scenario requires it.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONStorageAccountDisablePublicBlobAccess_Modify.json · 79 lines
{
"properties": {
"displayName": "Configure your Storage account public access to be disallowed",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Anonymous public read access to containers and blobs in Azure Storage is a convenient way to share data but might present security risks. To prevent data breaches caused by undesired anonymous access, Microsoft recommends preventing public access to a storage account unless your scenario requires it.",
"metadata": {
"version": "1.0.0",
"category": "Storage"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "The effect determines what happens when the policy rule is evaluated to match"
},
"allowedValues": [
"Modify",
"Disabled"
],
"defaultValue": "Modify"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
{
"anyOf": [
{
"allOf": [
{
"value": "[requestContext().apiVersion]",
"less": "2019-04-01"
},
{
"field": "Microsoft.Storage/storageAccounts/allowBlobPublicAccess",
"exists": "true"
}
]
},
{
"field": "Microsoft.Storage/storageAccounts/allowBlobPublicAccess",
"equals": "true"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"conflictEffect": "audit",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/17d1049b-9a84-46fb-8f53-869881c3d3ab"
],
"operations": [
{
"condition": "[greaterOrEquals(requestContext().apiVersion, '2019-04-01')]",
"operation": "addOrReplace",
"field": "Microsoft.Storage/storageAccounts/allowBlobPublicAccess",
"value": false
}
]
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/13502221-8df0-4414-9937-de9c5c4e396b",
"name": "13502221-8df0-4414-9937-de9c5c4e396b"
}Bylaw13502221-8df0-4414-9937-de9c5c4e396b.bylaw.ps1 · 37 lines
# Converted from StorageAccountDisablePublicBlobAccess_Modify.json by ConvertTo-Bylaw.
Policy '13502221-8df0-4414-9937-de9c5c4e396b' {
Properties @{
DisplayName = 'Configure your Storage account public access to be disallowed'
Description = 'Anonymous public read access to containers and blobs in Azure Storage is a convenient way to share data but might present security risks. To prevent data breaches caused by undesired anonymous access, Microsoft recommends preventing public access to a storage account unless your scenario requires it.'
Version = '1.0.0'
Category = 'Storage'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Modify', 'Disabled')
Default = 'Modify'
DisplayName = 'Effect'
Description = 'The effect determines what happens when the policy rule is evaluated to match'
}
Resource 'Microsoft.Storage/storageAccounts' {
Require 'allowBlobPublicAccess is as required' {
AnyOf {
Arm '[requestContext().apiVersion]' | Must -BeGreaterOrEqual '2019-04-01'
Field allowBlobPublicAccess | Must -Not -Exist
}
}
Require 'allowBlobPublicAccess is not true' {
Field allowBlobPublicAccess | Must -Not -Be 'true' -IfPresent
}
}
Modify -Role 'Storage Account Contributor' -ConflictEffect Audit -Effect (Param Effect) {
Field allowBlobPublicAccess | AddOrReplace $false -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2019-04-01'')]')
}
}Source: built-in-policies/policyDefinitions/Storage/StorageAccountDisablePublicBlobAccess_Modify.json in Azure/azure-policy, under the MIT licence.
Bylaw