How to harden security of Azure Virtual Network

Virtual Networks Are the Foundation of Azure Network Security

Azure Virtual Networks (VNets) provide the network isolation boundary for all Azure resources. A misconfigured VNet — flat network, overly permissive NSGs, missing route tables — allows lateral movement and makes every resource vulnerable. This guide covers how to design and harden your VNet architecture from subnets to DNS.

Threat Landscape and Attack Surface

Hardening Azure Virtual Network requires understanding the threat landscape specific to this service. Azure services are attractive targets because they often store, process, or transmit sensitive data and provide control-plane access to cloud infrastructure. Attackers probe for misconfigured services using automated scanners that continuously sweep Azure IP ranges for exposed endpoints, weak authentication, and default configurations.

The attack surface for Azure Virtual Network includes several dimensions. The network perimeter determines who can reach the service endpoints. The identity and access layer controls what authenticated principals can do. The data plane governs how data is protected at rest and in transit. The management plane controls who can modify the service configuration itself. A comprehensive hardening strategy addresses all four dimensions because a weakness in any single layer can be exploited to bypass the controls in other layers.

Microsoft’s shared responsibility model means that while Azure secures the physical infrastructure, network fabric, and hypervisor, you are responsible for configuring the service securely. Default configurations prioritize ease of setup over security. Every Azure service ships with settings that must be tightened for production use, and this guide walks through the critical configurations that should be changed from their defaults.

The MITRE ATT&CK framework for cloud environments provides a structured taxonomy of attack techniques that adversaries use against Azure services. Common techniques relevant to Azure Virtual Network include initial access through exposed credentials or misconfigured endpoints, lateral movement through overly permissive RBAC assignments, and data exfiltration through unmonitored data plane operations. Each hardening control in this guide maps to one or more of these attack techniques.

Compliance and Regulatory Context

Security hardening is not just a technical exercise. It is a compliance requirement for virtually every regulatory framework that applies to cloud workloads. SOC 2 Type II requires evidence of security controls for cloud services. PCI DSS mandates network segmentation and encryption for payment data. HIPAA requires access controls and audit logging for health information. ISO 27001 demands a systematic approach to information security management. FedRAMP requires specific configurations for government workloads.

Azure Policy and Microsoft Defender for Cloud provide built-in compliance assessments against these frameworks. After applying the hardening configurations in this guide, run a compliance scan to verify your security posture against your applicable regulatory standards. Address any remaining findings to achieve and maintain compliance. Export compliance reports on a scheduled basis to satisfy audit requirements and demonstrate continuous adherence.

The Microsoft cloud security benchmark provides a comprehensive set of security controls mapped to common regulatory frameworks. Use this benchmark as a checklist to verify that your hardening effort covers all required areas. Each control includes Azure-specific implementation guidance and links to the relevant Azure service documentation.

Step 1: Design Subnet Segmentation

# Create VNet with well-planned address space
az network vnet create \
  --name vnet-prod --resource-group rg-network \
  --location eastus --address-prefixes 10.0.0.0/16

# Create purpose-specific subnets
az network vnet subnet create --vnet-name vnet-prod --resource-group rg-network \
  --name snet-web --address-prefixes 10.0.1.0/24

az network vnet subnet create --vnet-name vnet-prod --resource-group rg-network \
  --name snet-api --address-prefixes 10.0.2.0/24

az network vnet subnet create --vnet-name vnet-prod --resource-group rg-network \
  --name snet-data --address-prefixes 10.0.3.0/24

az network vnet subnet create --vnet-name vnet-prod --resource-group rg-network \
  --name snet-pe --address-prefixes 10.0.4.0/24

az network vnet subnet create --vnet-name vnet-prod --resource-group rg-network \
  --name AzureBastionSubnet --address-prefixes 10.0.254.0/24

Separate subnets by function: web tier, API tier, data tier, private endpoints, and management. Each subnet gets its own NSG for micro-segmentation.

Step 2: Apply NSGs to Every Subnet

# Create NSG for web tier
az network nsg create --name nsg-web --resource-group rg-network

az network nsg rule create --nsg-name nsg-web --resource-group rg-network \
  --name AllowHTTPS --priority 100 --direction Inbound \
  --source-address-prefixes 10.0.254.0/24 --destination-port-ranges 443 \
  --protocol Tcp --access Allow

az network nsg rule create --nsg-name nsg-web --resource-group rg-network \
  --name DenyAllInbound --priority 4096 --direction Inbound \
  --source-address-prefixes '*' --destination-port-ranges '*' \
  --protocol '*' --access Deny

az network vnet subnet update --vnet-name vnet-prod --resource-group rg-network \
  --name snet-web --network-security-group nsg-web

# Create NSG for data tier (allow only API tier)
az network nsg create --name nsg-data --resource-group rg-network

az network nsg rule create --nsg-name nsg-data --resource-group rg-network \
  --name AllowFromAPI --priority 100 --direction Inbound \
  --source-address-prefixes 10.0.2.0/24 --destination-port-ranges 1433 \
  --protocol Tcp --access Allow

az network nsg rule create --nsg-name nsg-data --resource-group rg-network \
  --name DenyAllInbound --priority 4096 --direction Inbound \
  --source-address-prefixes '*' --destination-port-ranges '*' \
  --protocol '*' --access Deny

az network vnet subnet update --vnet-name vnet-prod --resource-group rg-network \
  --name snet-data --network-security-group nsg-data

Step 3: Enable NSG Flow Logs

# Enable flow logs for traffic analysis
az network watcher flow-log create \
  --name flow-log-web --resource-group rg-network \
  --nsg nsg-web --storage-account stflowlogs \
  --workspace law-prod-id --enabled true \
  --traffic-analytics true --interval 10

Step 4: Configure Route Tables

# Create route table to force traffic through firewall
az network route-table create \
  --name rt-web --resource-group rg-network --disable-bgp-route-propagation true

az network route-table route create \
  --route-table-name rt-web --resource-group rg-network \
  --name to-internet --address-prefix 0.0.0.0/0 \
  --next-hop-type VirtualAppliance --next-hop-ip-address 10.0.0.4

az network vnet subnet update --vnet-name vnet-prod --resource-group rg-network \
  --name snet-web --route-table rt-web

Step 5: Enable DDoS Protection

# Create DDoS protection plan
az network ddos-protection create --name ddos-plan --resource-group rg-network

# Associate with VNet
az network vnet update --name vnet-prod --resource-group rg-network \
  --ddos-protection-plan ddos-plan --ddos-protection true

Identity and Access Management Deep Dive

Identity is the primary security perimeter in cloud environments. For Azure Virtual Network, implement a robust identity and access management strategy that follows the principle of least privilege.

Managed Identities: Use system-assigned or user-assigned managed identities for service-to-service authentication. Managed identities eliminate the need for stored credentials (connection strings, API keys, or service principal secrets) that can be leaked, stolen, or forgotten in configuration files. Azure automatically rotates the underlying certificates, removing the operational burden of credential rotation.

Custom RBAC Roles: When built-in roles grant more permissions than required, create custom roles that include only the specific actions needed. For example, if a monitoring service only needs to read metrics and logs from Azure Virtual Network, create a custom role with only the Microsoft.Insights/metrics/read and Microsoft.Insights/logs/read actions rather than assigning the broader Reader or Contributor roles.

Conditional Access: For human administrators accessing Azure Virtual Network through the portal or CLI, enforce Conditional Access policies that require multi-factor authentication, compliant devices, and approved locations. Set session lifetime limits so that administrative sessions expire after a reasonable period, forcing re-authentication.

Just-In-Time Access: Use Azure AD Privileged Identity Management (PIM) to provide time-limited, approval-required elevation for administrative actions. Instead of permanently assigning Contributor or Owner roles, require administrators to activate their role assignment for a specific duration with a business justification. This reduces the window of exposure if an administrator’s account is compromised.

Service Principal Hygiene: If managed identities cannot be used (for example, for external services or CI/CD pipelines), use certificate-based authentication for service principals rather than client secrets. Certificates are harder to accidentally expose than text secrets, and Azure Key Vault can automate their rotation. Set short expiration periods for any client secrets and monitor for secrets that are approaching expiration.

Step 6: Implement Hub-Spoke Topology

# Create hub VNet
az network vnet create --name vnet-hub --resource-group rg-network \
  --address-prefixes 10.0.0.0/16

# Create spoke VNet
az network vnet create --name vnet-spoke1 --resource-group rg-workload \
  --address-prefixes 10.1.0.0/16

# Peer hub to spoke
az network vnet peering create \
  --name hub-to-spoke1 --resource-group rg-network \
  --vnet-name vnet-hub --remote-vnet vnet-spoke1 \
  --allow-forwarded-traffic true --allow-gateway-transit true

az network vnet peering create \
  --name spoke1-to-hub --resource-group rg-workload \
  --vnet-name vnet-spoke1 --remote-vnet vnet-hub \
  --allow-forwarded-traffic true --use-remote-gateways true

Step 7: Configure DNS Security

# Create Private DNS Resolver in hub
az dns-resolver create --name dnspr-hub --resource-group rg-network \
  --location eastus --id "/subscriptions/{sub}/resourceGroups/rg-network/providers/Microsoft.Network/virtualNetworks/vnet-hub"

# Configure VNet to use custom DNS (Azure Firewall as DNS proxy)
az network vnet update --name vnet-prod --resource-group rg-network \
  --dns-servers 10.0.0.4

Step 8: Restrict VNet Peering

# Use Azure Policy to control peering
# Deny peering to VNets outside approved subscriptions
az policy definition create \
  --name restrict-peering \
  --display-name "Restrict VNet peering" \
  --mode All \
  --rules '{
    "if": {
      "allOf": [
        {"field": "type", "equals": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings"},
        {"not": {"field": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings/remoteVirtualNetwork.id", "contains": "/subscriptions/approved-sub-id/"}}
      ]
    },
    "then": {"effect": "deny"}
  }'

Security Monitoring and Threat Detection

Hardening configurations are only effective if you can detect when they are bypassed, misconfigured, or degraded. Implement comprehensive security monitoring for Azure Virtual Network that covers authentication events, authorization decisions, configuration changes, and data access patterns.

Enable Microsoft Defender for Cloud and activate the relevant protection plan for this service type. Defender provides threat detection powered by Microsoft’s global threat intelligence, behavioral analytics that identify suspicious patterns, and just-in-time alerts when potential security incidents are detected. Review and triage Defender alerts daily, and integrate them into your security incident response workflow.

Configure Microsoft Sentinel to ingest logs from Azure Virtual Network and apply analytics rules that detect attack indicators. Common detection scenarios include brute force authentication attempts, access from unusual geographic locations, privilege escalation through role assignment changes, and data exfiltration through unusual data transfer patterns. Create custom analytics rules for scenarios specific to your environment, such as access outside of maintenance windows or modifications by unauthorized automation accounts.

Implement Azure Policy assignments that continuously monitor your resources for configuration drift from your hardened baseline. Use the audit effect to detect non-compliant resources and the deny effect to prevent the creation of resources that do not meet your security standards. Review policy compliance reports weekly and remediate any drift immediately, as configuration changes that weaken security controls may indicate either accidental misconfiguration or deliberate tampering.

Conduct tabletop exercises that simulate security incidents involving Azure Virtual Network. Walk through scenarios such as compromised credentials, data breach notification, ransomware attack, and insider threat. These exercises test your team’s ability to detect, contain, and recover from security incidents using the hardening controls and monitoring capabilities you have implemented. Document lessons learned and improve your security controls based on the gaps identified during the exercise.

Step 9: Implement Service Endpoints vs Private Endpoints

Feature Service Endpoint Private Endpoint
IP Address Public IP (optimized route) Private IP in VNet
DNS Public DNS Private DNS zone
On-premises access Not available Via VPN/ExpressRoute
Data exfiltration Risk (can access any instance) Locked to specific resource
Cost Free Per-hour charge

Prefer private endpoints for data services. Service endpoints are acceptable for low-risk services where cost is a concern.

Step 10: Monitor Network Health

# Enable Network Watcher
az network watcher configure --resource-group rg-network \
  --locations eastus --enabled true

# Create connection monitor
az network watcher connection-monitor create \
  --name monitor-web-to-db --resource-group rg-network \
  --location eastus \
  --test-group-name web-db-test \
  --endpoint-source-type AzureVM --endpoint-source-resource-id vm-web-id \
  --endpoint-dest-type ExternalAddress --endpoint-dest-address sql-prod.database.windows.net \
  --test-config-name tcp-1433 --protocol Tcp --tcp-port 1433

Defense in Depth Strategy

No single security control is sufficient. Apply a defense-in-depth strategy that layers multiple controls so that the failure of any single layer does not expose the service to attack. For Azure Virtual Network, this means combining network isolation, identity verification, encryption, monitoring, and incident response capabilities.

At the network layer, restrict access to only the networks that legitimately need to reach the service. Use Private Endpoints to eliminate public internet exposure entirely. Where public access is required, use IP allowlists, service tags, and Web Application Firewall (WAF) rules to limit the attack surface. Configure network security groups (NSGs) with deny-by-default rules and explicit allow rules only for required traffic flows.

At the identity layer, enforce least-privilege access using Azure RBAC with custom roles when built-in roles are too broad. Use Managed Identities for service-to-service authentication to eliminate stored credentials. Enable Conditional Access policies to require multi-factor authentication and compliant devices for administrative access.

At the data layer, enable encryption at rest using customer-managed keys (CMK) in Azure Key Vault when the default Microsoft-managed keys do not meet your compliance requirements. Enforce TLS 1.2 or higher for data in transit. Enable purge protection on any service that supports soft delete to prevent malicious or accidental data destruction.

At the monitoring layer, enable diagnostic logging and route logs to a centralized Log Analytics workspace. Configure Microsoft Sentinel analytics rules to detect suspicious access patterns, privilege escalation attempts, and data exfiltration indicators. Set up automated response playbooks that can isolate compromised resources without human intervention during off-hours.

Continuous Security Assessment

Security hardening is not a one-time activity. Azure services evolve continuously, introducing new features, deprecating old configurations, and changing default behaviors. Schedule quarterly security reviews to reassess your hardening posture against the latest Microsoft security baselines.

Use Microsoft Defender for Cloud’s Secure Score as a quantitative measure of your security posture. Track your score over time and investigate any score decreases, which may indicate configuration drift or new recommendations from updated security baselines. Set a target Secure Score and hold teams accountable for maintaining it.

Subscribe to Azure update announcements and security advisories to stay informed about changes that affect your security controls. When Microsoft introduces a new security feature or changes a default behavior, assess the impact on your environment and update your hardening configuration accordingly. Automate this assessment where possible using Azure Policy to continuously evaluate your resources against your security standards.

Conduct periodic penetration testing against your Azure environment. Azure’s penetration testing rules of engagement allow testing without prior notification to Microsoft for most services. Engage a qualified security testing firm to assess your Azure Virtual Network deployment using the same techniques that real attackers would employ. The findings from these tests often reveal gaps that automated compliance scans miss.

Hardening Checklist

  1. Purpose-specific subnet segmentation
  2. NSGs on every subnet with explicit deny rules
  3. NSG flow logs with traffic analytics
  4. Route tables forcing traffic through firewall
  5. DDoS Protection Standard enabled
  6. Hub-spoke topology for network isolation
  7. DNS security with Private DNS Resolver
  8. VNet peering restricted via Azure Policy
  9. Private endpoints for data services
  10. Network Watcher and connection monitoring

For more details, refer to the official documentation: What is Azure Virtual Network?.

Leave a Reply