Deny inbound NSG Rule creation via Azure Policy
In this blog article, we will cover how to deny the creation of inbound Network Security Group Rules if the inbound NSG Rule contains Internet, Any, or 0.0.0.0/0 as source and the destination port contains 22, 3389 or *".
Note: If users have the required permissions, they can create exemption for their resources. Which make this policy ineffective for that resource.
Custom Policy Definition creation
You can follow the steps below to create a custom policy:
1) From the Azure portal, access Azure policy, then definitions blade.
2) Create a new policy definition.
3) Add the definition location (which subscription will be hosting this policy), Name, and description.
4) Set the category to use existing and select Networking (as below):
5) Then add the below policy definition into the rule field:
Note: you can add more default ports for which this policy will be evaluated. These are the default port used in this policy.
"*",
"22",
"3389",
6) Then save the policy.
Policy Assignment
Now you can assign this policy as per your requirements.
1) From Azure policies page, and access definitions blade -> select the created custom policy, and click assign policy (you can assign on the Subscription level or a specific resource group depending on your business requirements).
2) To update the port list at time of policy assignment. Go to Parameters tab, then uncheck the box "Only show parameters that need input or review" and select of the three dots next to the "blocked ports" box.
3) It will open the editor; update the ports you want to include in this policy and click save.
4) Click Next, and Next, update the "Non-compliance message" as per your requirement.
5) Click review + create and review the output. Once verified create the policy assignment.
Policy assignment usually takes around 5-15 minutes to take effect.
To update the list of ports after the policy assignment. Edit the policy assignment, go to the parameters tab and edit the ports.
Disclaimer
Please note that products and options presented in this article are subject to change. This article reflects custom policy for Azure Network Security Rules in September 2024.
If users have the required permissions, they can create exemption for their resources. Which make this policy ineffective for that resource.
References
Tutorial: Create a custom policy definition - Azure Policy | Microsoft Learn
Programmatically create policies - Azure Policy | Microsoft Learn
Published on:
Learn moreRelated posts
Enable IP restriction for a public facing App service
In this blog article, we will cover how to control the app service deployment to support only public facing app service with IP restriction en...
Selecting the Optimal Container for Azure AI: Docker, ACI, or AKS?
Deploying Azure AI services in containers like Docker, Azure Container Instances (ACI), or Azure Kubernetes Service (...
Mt Diablo - Disaggregated Power Fueling the Next Wave of AI Platforms
Authors: Jason Adrian – General Manager, Azure Platform Architecture Laurentiu Olariu – Power Architect, Azure Platform Architecture Banha Sok...
Securing Hardware and Firmware Supply Chains
In the modern cloud data center, ensuring the authenticity, integrity, and security of hardware and firmware is paramount. Firmware is the low...
Liquid Cooling in Air Cooled Data Centers on Microsoft Azure
With the advent of artificial intelligence and machine learning (AI/ML), hyperscale datacenters are increasingly accommodating AI accelerators...
Azure Extended Zones: Optimizing Performance, Compliance, and Accessibility
Azure Extended Zones are designed to bring the power of Azure closer to end users in specific metropolitan areas or jurisdictions, cate...
Inside Maia 100: Revolutionizing AI Workloads with Microsoft's Custom AI Accelerator
Authored by: Sherry Xu, Partner Lead SoC Architect, Azure Maia Chandru Ramakrishnan, Partner Software Engineering Manager As the advanc...
Accelerate Cloud Potential for Your SAP Workloads on Azure with these Learning Paths
Accelerate Cloud Potential for Your SAP Workloads on Azure with these Learning Paths In today's rapidly evolving digital landsc...
Azure Role Assignments Audit Report
Overview: Azure Administrators often come across challenges while tracking multiple Azure role assignments and removals. At present Azur...
Leveraging Azure Copilot for Azure Kubernetes Services (AKS)
Azure Copilot is a powerful AI-driven tool that helps manage and optimize your Azure resources, including Azure Kubernetes Services (AKS). By ...