Azure Security Best Practices

Microsoft Azure offers a wide set of security capabilities, and applying them correctly is key to protecting cloud workloads and identities.

Identity with Azure AD

Enforce multi-factor authentication and conditional access policies through Azure Active Directory, and apply role-based access control to limit what each identity can do within a subscription.

Network Security Groups

Use Network Security Groups to control inbound and outbound traffic at the subnet or network interface level, minimizing unnecessary exposure of virtual machines and services.

Data Protection

Enable encryption at rest with Azure Storage Service Encryption and enforce encryption in transit, while using Azure Key Vault to securely manage secrets, keys, and certificates.

Monitoring with Azure Security Center

Microsoft Defender for Cloud continuously assesses resources against security best practices and provides actionable recommendations along with threat detection across the environment.

What Assessors Commonly Find in Azure Tenants

During cloud security reviews and penetration tests, the same weaknesses appear again and again. Knowing them tells you where to start hardening.

  • Administrator accounts without multi-factor authentication, or legacy sign-in protocols that bypass it.
  • The Owner role assigned at subscription level to many people and service principals.
  • Network security group rules that allow RDP (3389) or SSH (22) from any source address.
  • Storage accounts that permit anonymous blob access, sometimes holding backups or exports.
  • Secrets, connection strings and keys stored in code repositories, pipeline variables or app settings in plain text.
  • Diagnostic logging switched off, so nobody can reconstruct what an attacker did.

Note that Azure Active Directory is now called Microsoft Entra ID, so newer documentation and portal pages use that name.

Hardening Commands for Typical Gaps

The Azure CLI lets you fix several of these quickly and repeatably. Replace the placeholder names with your own resources.

# Allow SSH only from one admin IP instead of the whole internet
az network nsg rule create \
  --resource-group rg-prod \
  --nsg-name nsg-web \
  --name Allow-SSH-Admin \
  --priority 100 \
  --direction Inbound \
  --access Allow \
  --protocol Tcp \
  --source-address-prefixes 203.0.113.10/32 \
  --destination-port-ranges 22

# Block anonymous public access to blobs in a storage account
az storage account update \
  --name stappdata01 \
  --resource-group rg-prod \
  --allow-blob-public-access false

# Give a web app its own identity, then read-only access to vault secrets
az webapp identity assign --name shop-api --resource-group rg-prod
az role assignment create \
  --assignee <principal-id-from-previous-command> \
  --role "Key Vault Secrets User" \
  --scope <key-vault-resource-id>

Better still, avoid open management ports entirely by using Azure Bastion or just-in-time VM access, so ports are opened only on request and for a limited time.

Layered Controls Worth Putting in Place

Identity first

  • Use Privileged Identity Management so admin roles are activated only when needed, with approval and an audit trail.
  • Assign roles at the narrowest scope, a resource group or a single resource, rather than the whole subscription.
  • Prefer managed identities over client secrets for applications, so there is no credential to leak or rotate.
  • Keep two emergency "break glass" accounts with strong protection and monitored sign-ins.

Guardrails with Azure Policy

Policies stop insecure resources from being created in the first place, for example denying storage accounts that allow public access or requiring resources to be created only in approved regions. They also report existing resources that break the rules.

Visibility

Send Activity Logs and resource diagnostic logs to a Log Analytics workspace, and use Microsoft Sentinel if you need a SIEM to correlate alerts. Review Defender for Cloud recommendations regularly instead of letting them pile up.

Testing Your Own Configuration Ethically

Only test tenants you own or have written permission to assess, and follow Microsoft's published rules of engagement for penetration testing in the cloud. A useful self-review checklist:

  • List every role assignment with Owner or Contributor and justify each one.
  • Search NSGs for rules with a source of Any or 0.0.0.0/0.
  • Check that MFA or conditional access covers all admins.
  • Confirm Key Vault has soft delete and purge protection enabled.
  • Verify logs are retained long enough to investigate an incident.

Ready to master Cybersecurity?

Join Uncodemy's Cybersecurity Course and learn from industry experts.

Explore Course