Introduction
Network security is the set of actions taken to safeguard a computer network and its information from unauthorized access, misuse, changes, or interruptions. It encompasses using different tools, procedures, and rules to guarantee that network resources remain private, unaltered, and accessible when needed. Azure offers a comprehensive suite of network security services to protect your cloud infrastructure and applications. Let's look at a few of them.
Network Security Groups (NSGs)
They serve as fundamental firewall tools within Azure, enabling users to regulate the flow of network traffic to and from Azure resources in a virtual network. NSGs are linkable with subnets, network interfaces, or specific VM instances. Positioned at the network layer (Layer 3) of the OSI model, NSGs empower users to establish regulations that authorize or restrict traffic based on source and destination IP addresses, ports, and protocols.
You can create an NSG and associate it with the subnet containing your VMs. Within the NSG, you define rules to allow or deny specific types of traffic based on criteria such as source and destination IP addresses, ports, and protocols.
Let's look at an example: We create a rule allowing inbound traffic on port 80 (HTTP) to the VM running the web server but deny traffic on other ports to prevent unauthorized access. By configuring NSGs in this way, you can effectively control the flow of traffic to and from your Azure resources, enforcing network security policies and reducing the risk of unauthorized access or malicious activity.
Azure Firewall
It is a completely managed, cloud-based firewall solution delivering centralized, application-aware network security for resources within Azure Virtual Networks. It functions across both the network layer (Layer 3) and the application layer (Layer 7) of the OSI model. Azure Firewall empowers users to establish and implement policies using Fully Qualified Domain Names (FQDN), IP addresses, ports, and protocols, thus providing advanced security features for Azure deployments.
Let's say you have a virtual network (VNet) in Azure hosting multiple resources, including web servers, application servers, and a database server. You want to ensure that only authorized traffic can access these resources and that malicious activity is blocked.
We deploy Azure Firewall within your VNet, configure it, and create a policy allowing inbound traffic on port 80 (HTTP) and 443 (HTTPS) to the web servers, ensuring that users can access the website securely. We configure the firewall to inspect traffic at the application layer (Layer 7) to detect and block suspicious web requests, such as SQL injection attacks or cross-site scripting (XSS) attempts. With these policies in place, Azure Firewall acts as a barrier between your virtual network and the internet, inspecting and filtering traffic to enforce your security policies. It provides centralized, application-aware network security, protecting your Azure resources from unauthorized access, malicious activity, and potential security breaches.
Often there is confusion between the two: NSG and Firewall.
The following provides a quick overview of the key differences between NSGs and Azure Firewall in terms of scope, capabilities, deployment flexibility, and integration with other Azure services.

Join the conversation! Your thoughts help the community grow.