Gallery › Container Instance › Azure built-in policies
Azure Container Instance container group should deploy into a virtual network
Converted Policy Audit Deny Disabled Mode Indexed Version 2.0.0
Secure communication between your containers with Azure Virtual Networks. When you specify a virtual network, resources within the virtual network can securely and privately communicate with each other.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONVNET_Audit.json · 80 lines
{
"properties": {
"displayName": "Azure Container Instance container group should deploy into a virtual network",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Secure communication between your containers with Azure Virtual Networks. When you specify a virtual network, resources within the virtual network can securely and privately communicate with each other.",
"metadata": {
"version": "2.0.0",
"category": "Container Instance"
},
"version": "2.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled",
"Deny"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ContainerInstance/containerGroups"
},
{
"not": {
"field": "Microsoft.ContainerInstance/containerGroups/ipAddress.type",
"equals": "Private"
}
},
{
"anyOf": [
{
"allOf": [
{
"value": "[requestContext().apiVersion]",
"greater": "2021-03-01"
},
{
"field": "Microsoft.ContainerInstance/containerGroups/subnetIds[*].id",
"exists": false
}
]
},
{
"allOf": [
{
"value": "[requestContext().apiVersion]",
"lessOrEquals": "2021-03-01"
},
{
"field": "Microsoft.ContainerInstance/containerGroups/networkProfile.id",
"exists": false
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/8af8f826-edcb-4178-b35f-851ea6fea615",
"name": "8af8f826-edcb-4178-b35f-851ea6fea615"
}Bylaw8af8f826-edcb-4178-b35f-851ea6fea615.bylaw.ps1 · 44 lines
# Converted from VNET_Audit.json by ConvertTo-Bylaw.
Policy '8af8f826-edcb-4178-b35f-851ea6fea615' {
Properties @{
DisplayName = 'Azure Container Instance container group should deploy into a virtual network'
Description = 'Secure communication between your containers with Azure Virtual Networks. When you specify a virtual network, resources within the virtual network can securely and privately communicate with each other.'
Version = '2.0.0'
Category = 'Container Instance'
PolicyVersion = '2.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled', 'Deny')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.ContainerInstance/containerGroups' {
When {
Field ipAddress.type | Must -Not -Be 'Private'
}
Require 'subnetIds and id are as required' {
AnyOf {
Arm '[requestContext().apiVersion]' | Must -BeLessOrEqual '2021-03-01'
Count 'subnetIds[*]' -Where {
Field id | Must -Exist
} | Must -Not -Be 0
}
}
Require 'networkProfile.id is as required' {
AnyOf {
Arm '[requestContext().apiVersion]' | Must -BeGreaterThan '2021-03-01'
Field networkProfile.id | Must -Exist
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Container Instance/VNET_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw