Show an Azure Policy definition that denies public IPs on NICs.
AdvancedConceptPolicy, Cost, AWS Mapping and Rapid-fire
Answer
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{ "field": "type", "equals": "Microsoft.Network/networkInterfaces" },
{ "count": { "field": "Microsoft.Network/networkInterfaces/ipconfigurations[*]",
"where": { "field": "Microsoft.Network/networkInterfaces/ipconfigurations[*].publicIpAddress.id", "notEquals": "" } },
"greater": 0 }
]
},
"then": { "effect": "deny" }
}
}
az policy definition create -n deny-nic-pip --rules @rule.json --mode All
az policy assignment create -n deny-nic-pip --policy deny-nic-pip \
--scope /providers/Microsoft.Management/managementGroups/corp
A built-in "Network interfaces should not have public IPs" exists; prefer built-ins where they fit.
More on Policy, Cost, AWS Mapping and Rapid-fire
What is Azure Policy and what effects can a policy have?BeginnerAzure Policy vs RBAC: what is the difference?BeginnerHow do remediation tasks and policy exemptions work?AdvancedWhat is Microsoft Defender for Cloud?IntermediateWhat tools does Azure offer for cost management?BeginnerReservations vs Savings Plans vs Spot vs Azure Hybrid Benefit.Intermediate