Configure secure access to virtual networks
Filter traffic with network security groups and application security groups, connect securely with Azure Bastion, and reach PaaS services privately with service and private endpoints.
- 20 min
- 5 concepts
- Try it yourself
- 5-question check
Learn
Once VNets are built, you need to control what can reach what. Network security groups filter traffic, Azure Bastion removes the need for public IPs on VMs, and endpoints keep traffic to services like Storage off the public internet.
Expect questions where you work out whether a packet is allowed by reading NSG rules in priority order.
- 1
Create and configure network security groups (NSGs) and application security groups
An NSG is a list of inbound and outbound rules, each with a priority (100 to 4096, lower runs first), source, destination, port, protocol and allow or deny. Processing stops at the first match. Associate an NSG with a subnet, a NIC, or both.
Every NSG has default rules at 65000 and above: allow traffic within the VNet, allow the Azure load balancer, and deny everything else inbound. Application security groups (ASGs) let you group VMs by role, such as web or db, and use those names in rules instead of IP addresses.
Remember: Lowest priority number wins, and the first match stops processing.
- 2
Evaluate effective security rules in NSGs
When NSGs are on both the subnet and the NIC, inbound traffic must be allowed by the subnet NSG and then the NIC NSG. Outbound goes NIC first, then subnet. A deny at either one blocks the traffic.
Use Effective security rules on a NIC, or Network Watcher's IP flow verify, to see the combined result.
Remember: Both NSGs must allow it. Either one can block it.
- 3
Implement Azure Bastion
Azure Bastion gives RDP and SSH to VMs from the browser or a native client over TLS, so the VMs don't need public IPs. It's deployed into a subnet called exactly
AzureBastionSubnet, at least /26.SKUs are Developer, Basic, Standard and Premium. Standard adds native client support, host scaling and IP-based connections; Premium adds session recording and private-only deployment.
Remember: The subnet must be called AzureBastionSubnet.
- 4
Configure service endpoints for Azure platform as a service (PaaS)
A service endpoint extends the VNet's identity to an Azure service such as Storage or SQL Database over the Azure backbone. You then add a virtual network rule on the service to allow only that subnet.
The service keeps its public endpoint and public IP; traffic just comes from the subnet's private address. Service endpoint policies can limit which storage accounts the subnet can reach.
Remember: Service endpoint: the service is still public, but only your subnet is allowed in.
- 5
Configure private endpoints for Azure PaaS
A private endpoint is a network interface with a private IP from your subnet that connects to one specific resource, such as one storage account, through Azure Private Link. You can then turn off public access completely.
Clients need to resolve the service's name to the private IP, which is done with a private DNS zone such as
privatelink.blob.core.windows.net. Private endpoints also work from peered VNets and on-premises.Remember: Private endpoint: the resource gets a private IP in your VNet.
Service endpoint or private endpoint?
- Enabled on a subnet
- Service keeps its public IP
- Allow the subnet with a VNet rule
- Doesn't extend to on-premises
- No extra cost
- A NIC with a private IP
- Connects to one specific resource
- Public access can be disabled
- Works from peered VNets and on-premises
- Needs private DNS; charged per hour and data
Try it
Send a packet to the VM and watch the NSG rules evaluate in priority order.
This interactive part needs JavaScript.
In the portal
- Inbound rulesAzure portal: Network security groups > your NSG > Settings > Inbound security rules
- Effective rules for a NICAzure portal: Network interfaces > your NIC > Help > Effective security rules
- Deploy BastionAzure portal: Virtual networks > your VNet > Settings > Bastion
- Create a private endpointAzure portal: Storage accounts > your account > Security + networking > Networking > Private endpoint connections
Key terms
Click a card to see the definition.
Check your understanding
5 questions. Score 80% or more and these skills are marked as confident in your AZ-104 study plan.
Rule 100 allows TCP 443 and rule 200 denies all. What happens to HTTPS traffic?
Lower numbers run first and processing stops at the first match.
The subnet NSG allows RDP but the NIC NSG denies it. Can you RDP to the VM?
Inbound traffic must be allowed by both NSGs.
What must the Azure Bastion subnet be called?
Bastion requires that exact name, at least /26.
A storage account must be reachable from on-premises over ExpressRoute with public access disabled. What do you use?
Private endpoints give a private IP reachable from connected networks; service endpoints don't extend on-premises.
Which lets you write a rule like 'allow web servers to reach db servers on 1433' without IP addresses?
ASGs group VMs by role for use in NSG rules.
Sources
- Microsoft Learn: Network security groups
- Microsoft Learn: How network security groups filter traffic
- Microsoft Learn: Application security groups
- Microsoft Learn: What is Azure Bastion?
- Microsoft Learn: Virtual network service endpoints
- Microsoft Learn: What is a private endpoint?
Facts in this lesson are from Microsoft Learn. This site isn't affiliated with Microsoft.