Azure / Enterprise-Scale

The Azure Landing Zones (Enterprise-Scale) architecture provides prescriptive guidance coupled with Azure best practices, and it follows design principles across the critical design areas for organizations to define their Azure architecture
https://aka.ms/alz
MIT License
1.69k stars 964 forks source link

Bug Report: Issue in using policy Deny-MgmtPorts-From-Internet policy #1549

Closed jain-ranjith closed 8 months ago

jain-ranjith commented 8 months ago

Community Note

Description

{
  "field": "Microsoft.Network/networkSecurityGroups/securityRules/destinationPortRange",
  "in": "[[parameters('ports')]"
 },

This is resulting in error The inner exception 'Evaluation result of language expression '[[parameters('ports')]' is type 'String', expected type is 'Array'.'. at policy creation.

jtracey93 commented 8 months ago

Hey @jain-ranjith, thanks for the issue.

How did you deploy this policy? As if you copied it from this repo and didn't use one of our implementation options (portal, bicep or terraform modules) you will have some extra escaping characters present that you dont need.

If you just want the definition, use the "copy definition" button via AzAdvertizer here for this policy and it will remove the escaping characters https://www.azadvertizer.net/azpolicyadvertizer/Deny-MgmtPorts-From-Internet.html

details on the escaping is here: https://github.com/Azure/Enterprise-Scale/wiki/ALZ-Contribution-Guide#escaping-policy-functions

jain-ranjith commented 8 months ago

Hi @jtracey93 , Thanks for the explanation.
I tried to "copy" the definition and used it Terraform. My bad that I did not read the instructions. I will close the issue :)