Gallery › Container Apps › Azure built-in policies
Container App should configure with volume mount
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.1
Enforce the use of volume mounts for Container Apps to ensure availability of persistent storage capacity.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONContainerAppMountStorage_Audit.json · 52 lines
{
"properties": {
"displayName": "Container App should configure with volume mount",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Enforce the use of volume mounts for Container Apps to ensure availability of persistent storage capacity.",
"metadata": {
"version": "1.0.1",
"category": "Container Apps"
},
"version": "1.0.1",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.App/containerApps"
},
{
"count": {
"field": "Microsoft.App/containerApps/template.volumes[*]"
},
"equals": 0
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/7c9f3fbb-739d-4844-8e42-97e3be6450e0",
"name": "7c9f3fbb-739d-4844-8e42-97e3be6450e0"
}Bylaw7c9f3fbb-739d-4844-8e42-97e3be6450e0.bylaw.ps1 · 28 lines
# Converted from ContainerAppMountStorage_Audit.json by ConvertTo-Bylaw.
Policy '7c9f3fbb-739d-4844-8e42-97e3be6450e0' {
Properties @{
DisplayName = 'Container App should configure with volume mount'
Description = 'Enforce the use of volume mounts for Container Apps to ensure availability of persistent storage capacity.'
Version = '1.0.1'
Category = 'Container Apps'
PolicyVersion = '1.0.1'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.App/containerApps' {
Require 'template.volumes is as required' {
Count 'template.volumes[*]' | Must -Not -Be 0
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Container Apps/ContainerAppMountStorage_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw