Join our Newsletter — 33% off our NHI Course
Home› Guides› Azure Virtual Machines Security Guide: Encryption, Trusted Launch,…
Guide Cloud Security

Azure Virtual Machines Security Guide: Encryption, Trusted Launch, JIT and Extension Control

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 15 November 2026 17 min read
On this page

An Azure virtual machine can be fully patched and still be taken over by anyone who holds a control-plane role that lets them push an extension or a Run Command into it. Securing Azure VMs means working on two planes at once: the Azure Resource Manager plane, where roles decide who can change disks, extensions and network rules, and the guest operating system, where local accounts, agents and patches live. This guide covers the VM-specific controls: disk encryption options and the move away from Azure Disk Encryption, Trusted Launch, just-in-time (JIT) management port access, the extension and Run Command attack path, serial console, patching with Azure Update Manager, and logging. It is written for Azure platform engineers, cloud security architects and server owners. For brokered RDP and SSH without public IPs, see the Azure Bastion guide; for machines outside Azure managed through Azure Arc, see the Azure Arc Security Guide.

This is an independent guide from NHI Mgmt Group, based on Microsoft's public documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft's current documentation.

Key takeaways

  • Virtual Machine Contributor is a code execution role. Microsoft describes it as able to "install and run software" and reset the root password through VM extensions; its Microsoft.Compute/virtualMachines/* action covers executing scripts on VMs. Treat it as equivalent to local administrator on every VM in scope.
  • Plan the Azure Disk Encryption migration now. Microsoft has scheduled Azure Disk Encryption (ADE) for retirement on 15 September 2028, after which ADE-encrypted disks fail to unlock on reboot. Encryption at host is the documented replacement for new VMs.
  • Keep Trusted Launch on and finish the set. Secure Boot, vTPM and the Guest Attestation extension together give boot integrity monitoring and the Defender for Cloud attestation failure alert. Trusted Launch is the default for new Generation 2 VMs created in the portal, CLI and PowerShell.
  • Close management ports by default. JIT VM access (Defender for Servers Plan 2) keeps deny rules on ports such as 22 and 3389 and opens them only for an approved source IP and time window; Azure Bastion removes the need for public IPs altogether.
  • Logs from inside the VM need an agent. Activity Log records control-plane operations, but guest OS events need the Azure Monitor agent and a data collection rule. Alert on extension writes and Run Command operations as privileged actions.

The two planes of an Azure VM

Many VM compromises start not with a guest exploit but with an identity that already holds rights on the resource, such as a pipeline service principal with Contributor on a subscription. Separate the two planes in your design and your access reviews.

PlaneWhat controls itMain risksPrimary controls
Azure control plane (ARM)Azure RBAC role assignments, Azure Policy, resource locksExtension or Run Command execution, disk snapshot and export, NSG changes, password reset through the VMAccess extensionLeast-privilege roles, Privileged Identity Management, policy deny effects, Activity Log alerts
Guest OS (data plane)Local accounts, Microsoft Entra ID login roles, SSH keys, OS firewallBrute force on exposed RDP or SSH, stale local admin passwords, unpatched servicesJIT or Bastion, Entra ID login, disabling local accounts where possible, patching, EDR
Platform and bootTrusted Launch, encryption settings, VM size and imageBootkits and unsigned drivers, unencrypted temp disks and cachesSecure Boot, vTPM, Guest Attestation, encryption at host, Azure Compute Gallery images

Microsoft's own security baseline for VMs recommends Microsoft Entra ID as the default authentication method for data plane access, says local accounts should be disabled wherever possible, and recommends managed identities over service principals for workloads running on the VM. Managed identity tokens are fetched from the Instance Metadata Service inside the VM, so anyone with code execution on the VM can use that identity: see the Azure Managed Identities Security Guide for scoping those roles.

Roles and the extension attack path

VM extensions are small applications the Azure platform installs and runs inside the VM after deployment, managed entirely from the control plane: Microsoft notes you do not need to connect to the VM to install or remove one. The Azure VM Agent that runs them needs to run as Local System on Windows, and the action form of Run Command executes as the system account on Windows or root on Linux. Anyone who can write an extension or invoke Run Command can therefore run code with full privileges on the guest, without a network path to it and without guest credentials. MITRE ATT&CK tracks this behaviour as T1651 Cloud Administration Command.

Built-in roleWhat Microsoft documentsEffective guest impactRecommended handling
Owner, ContributorFull management of resources in scopeCode execution on every VM in scope through extensions and Run CommandEligible only through PIM; never standing for automation at subscription scope
Virtual Machine ContributorCreate and manage VMs, manage disks, install and run software, reset the root password and manage local users through VM extensions; no login data actionsCode execution as SYSTEM or root, local credential resetTreat as privileged; scope to a resource group per workload; eligible through PIM
Virtual Machine Administrator LoginView VMs in the portal and log in as administratorInteractive admin sign-in with Entra IDEligible only; pair with Conditional Access
Virtual Machine User LoginView VMs in the portal and log in as a regular userInteractive non-admin sign-in with Entra IDDefault for operators who need to sign in
Virtual Machine Data Access Administrator (preview)Add or remove assignments of the two login roles, with an ABAC conditionDelegated control over who can sign inUse to delegate login management without granting Owner or User Access Administrator
Data Operator for Managed DisksUpload, read or export data of managed disks not attached to running VMs, and snapshots, via SAS URIs and Entra IDOffline copy of disk contentsAssign narrowly; monitor disk export and SAS generation

Control which extensions can run: the built-in Azure Policy "Only approved VM extensions should be installed" (category Compute) takes a list of approved extensions and supports Audit, Deny and Disabled effects, with Audit as the default.

Keep secrets out of extension settings: Microsoft documents a protectedSettings block that encrypts data and decrypts it only inside the target VM, while values under settings, including a Custom Script Extension commandToExecute, are not encrypted and are readable by anyone who can read the resource. Better still, have the script fetch secrets from Key Vault with the VM's managed identity; see the Azure Key Vault Security Guide.

Know the two Run Command types: action Run Command is a POST action for one-off tasks with a 90 minute limit and runs as the system account or root; managed Run Command is an ARM resource type, supports sequencing and recurring execution, and runs as a user you specify, with up to 25 per VM. Include managed Run Command resources in configuration reviews.

Disk encryption: choosing an option

Azure managed disks are always encrypted at rest by server-side encryption (SSE) with platform-managed keys. The choices are whether to cover temp disks, caches and data in flight, and who holds the key.

OptionCoversKey controlWhen to choose it
Server-side encryption (SSE)OS and data disks at rest on storage clusters; not temp disks or cachesPlatform-managed keys, or customer-managed keys through a disk encryption set (DES)Always on; add a DES with customer-managed keys where regulation requires key control
Encryption at hostExtends SSE to temp disks and disk caches at rest and encrypts data flows to storagePlatform-managed or customer-managed via DES (temp disk with platform-managed keys only)Default choice for new VMs; documented replacement for ADE; no guest CPU cost
Confidential disk encryptionOS disk, with keys bound to the VM's TPM and released through attested code; temp disk by opt-inCustomer-managed via DES, Key Vault Premium or Managed HSMConfidential workloads on confidential VM sizes where the host operator must be excluded
Azure Disk Encryption (ADE)OS and data disks inside the guest with BitLocker or DM-CryptKey Vault, optional key encryption keyExisting estates only; migrate before the retirement date

ADE retirement: Microsoft states that ADE is scheduled for retirement on 15 September 2028. Workloads keep running on that date, but encrypted disks fail to unlock after a reboot, and Microsoft says all ADE-enabled VMs, including backups, must move to encryption at host before then. Inventory ADE-enabled VMs now and include restore points: a backup restored after the date inherits the problem. See the Azure Backup and Recovery Services Vault Security Guide for vault-side protections.

Decision guidance: most organisations need SSE plus encryption at host with platform-managed keys. Add customer-managed keys only when a regulator, contract or internal policy requires key ownership, because it brings key rotation, availability and revocation duties: losing access to the Key Vault key makes the disks unusable.

Trusted Launch and boot integrity

Trusted Launch protects Generation 2 VMs against bootkits, rootkits and kernel-level malware (ATT&CK T1542.003 Bootkit). Microsoft documents four layers that can be enabled independently: Secure Boot (only signed boot loaders, kernels and drivers run), a vTPM 2.0 that measures the boot chain, boot integrity monitoring through remote attestation, and virtualisation-based security for HVCI and Credential Guard on Windows.

  • Defaults: Trusted Launch is the default for new Generation 2 VMs and scale sets created in the portal, CLI and PowerShell. ARM, Bicep and Terraform deployments need the TrustedLaunchByDefaultPreview feature registered, or set securityProfile.securityType to TrustedLaunch with secureBootEnabled and vTpmEnabled set to true explicitly. Set it explicitly in templates so the outcome does not depend on feature registration.
  • Existing VMs: Microsoft documents that Generation 1 VMs can be upgraded to Generation 2 with Trusted Launch, and existing Generation 2 VMs and scale sets can have it enabled after creation. Test on a clone first.
  • Sizes and images: some families, including A, Dv2, Dv3 and most M-series sizes, do not support Generation 2; Managed Image is replaced by Azure Compute Gallery for Trusted Launch. On Linux, GRID GPU drivers need Secure Boot disabled, so isolate those VMs and document the exception.
  • Complete the attestation chain: Defender for Cloud raises low-severity recommendations to enable Secure Boot, enable vTPM and install the Guest Attestation extension. With all three in place it assesses attestation health and raises a medium-severity VM attestation failure alert when the boot log deviates from a trusted baseline, plus a low-severity alert when an untrusted Linux kernel module is blocked.

Management access: JIT, Bastion and serial console

Exposed RDP (T1021.001) and SSH (T1021.004) remain the most common way into cloud VMs from the internet. Pick one controlled path per environment and remove the rest.

ApproachHow it worksFitsWatch for
Azure BastionManaged broker in the virtual network; no public IP on the VMProduction and any VM without a business need for public exposureWho holds the Reader roles and shareable links; covered in the Bastion guide
JIT VM accessDefender for Cloud keeps deny rules in the NSG and Azure Firewall (Rules Classic) and opens the port for an approved source IP and timeVMs that must keep a public IP or a firewall path; break-glass accessDefault source is Any when enabled from the VM blade; restrict it to known ranges
Serial consoleText console through the portal over TLS 1.2 or laterRecovery when networking or boot failsEnabled by default for subscriptions; needs Virtual Machine Contributor or higher; commands and output land in boot diagnostics logs

JIT details: JIT is part of Defender for Servers Plan 2. When enabled from the VM configuration page, the defaults are port 3389 for Windows and 22 for Linux, a 3 hour maximum request window and allowed source IPs of Any; Defender for Cloud also recommends 5985 and 5986 for WinRM. Requesting access needs Microsoft.Security/locations/jitNetworkAccessPolicies/initiate/action plus read actions, while editing the policy needs jitNetworkAccessPolicies/write and Microsoft.Compute/virtualMachines/write, so separate requesters from policy editors. JIT does not cover VMs behind an Azure Firewall managed by Firewall Manager policies.

Serial console: commands and output, including any secrets typed, are written to boot diagnostics logs, so disable it at subscription level where it is not needed and restrict read access to boot diagnostics storage where it stays on.

Patching, images and endpoint protection

  • Azure Update Manager: assesses and installs updates for Windows and Linux on Azure VMs and Arc-connected machines, with periodic assessment every 24 hours, customer-defined maintenance windows, dynamic scoping and hotpatching for critical updates without a restart on supported images. Turn on periodic assessment by Azure Policy so every new VM reports compliance from day one.
  • Automatic guest patching: applies Critical and Security updates automatically; Microsoft's baseline notes it is not enabled by default. Use it for stateless or scale-set tiers, and scheduled maintenance windows for stateful servers.
  • Golden images: build hardened images in Azure Compute Gallery and rebuild on a schedule.
  • EDR and anti-malware: Defender for Servers integrates with Microsoft Defender for Endpoint for EDR; Microsoft Defender Antivirus is installed by default on Windows Server 2016 and later. Defender for Servers is not enabled by default, so assign it by policy at management group scope.
  • Vendor updates: apply Microsoft security updates for the VM Agent and extensions promptly; Microsoft notes you cannot opt out of extension hotfix updates that carry security fixes, and recommends keeping autoUpgradeMinorVersion enabled.

Implementation roadmap

  1. Inventory (week 1): list VMs with public IPs, VMs with Secure Boot or vTPM off, ADE-enabled VMs and their backups, deployed extensions and managed Run Commands, and every principal holding Owner, Contributor or Virtual Machine Contributor over VM scopes.
  2. Reduce standing privilege (weeks 2 to 4): move human Contributor and Virtual Machine Contributor assignments to PIM eligibility; scope pipeline identities to the resource groups they deploy; give operators Virtual Machine User Login instead of management roles. See the Privileged Identity Management (PIM) Guide.
  3. Audit-mode policies (weeks 2 to 6): assign "Only approved VM extensions should be installed" in Audit, plus policies for periodic update assessment and Defender for Servers, and review compliance before changing effects. The Azure Policy and Management Groups Guide covers assignment scope and exemptions.
  4. Close management ports (weeks 4 to 8): deploy Bastion in hub networks, enable JIT for VMs that keep a public path, restrict JIT source ranges, and disable serial console where not needed.
  5. Encryption and boot (weeks 6 to 16): enable encryption at host on new builds through templates; pilot ADE-to-encryption-at-host migration on a non-production ring with a tested restore; enable Trusted Launch and Guest Attestation on supported VMs.
  6. Enforce (after a clean audit period): switch the extension policy to Deny at management group scope, keep a documented exemption process, and set Trusted Launch explicitly in every template.
  7. Rollback: every Deny assignment has a named owner who can flip it back to Audit; every disk migration keeps a verified backup until the VM has rebooted cleanly on the new configuration.

Small and large estates: a team with a few dozen VMs can enforce most of this in one subscription in a quarter, with Bastion replacing JIT entirely. Large estates should drive it from management group policy and run the ADE migration as a tracked programme; see the Azure Landing Zones Security Guide.

Logging, detection and metrics

SignalSourceWhy it matters
Extension write or delete on a VMActivity Log (Microsoft.Compute/virtualMachines/extensions/write)Code execution path into the guest; unexpected publishers or Custom Script Extension use outside pipelines
Run Command invocationActivity Log (Microsoft.Compute/virtualMachines/runCommand/action) and managed Run Command resource changesDirect SYSTEM or root execution by a control-plane identity
Disk export, SAS generation or snapshot creationActivity Log on disks and snapshotsOffline copy of data that bypasses guest controls
JIT request and NSG rule changesActivity Log, JIT Activity Log view (exportable to CSV)Who opened which port, from where, for how long
VM attestation failure, untrusted kernel moduleDefender for Cloud alertsBoot chain tampering or unexpected drivers
Guest sign-ins, process and service creationAzure Monitor agent with a data collection rule, Defender for EndpointActivity after access, which control-plane logs do not show

Alert on the first three rows when the caller is not a known deployment identity. The Azure Monitor, Activity Log and Diagnostic Settings Guide covers export and retention.

Metrics that show progress:

  • Percentage of VMs with no public IP on management ports, or covered by JIT.
  • Percentage of supported VMs with Secure Boot, vTPM and Guest Attestation all enabled.
  • Count of ADE-enabled VMs and restore points remaining, trending to zero before September 2028.
  • Number of standing (non-PIM) assignments of Owner, Contributor or Virtual Machine Contributor over VM scopes.
  • Extension and Run Command operations by non-pipeline identities per month, each with a ticket reference.

Common failure patterns

  • Treating Virtual Machine Contributor as low risk: the role is handed to helpdesk or monitoring teams because it "cannot log in", yet it can run scripts as SYSTEM and reset local passwords through extensions.
  • Secrets in plain extension settings: passwords placed in settings.commandToExecute rather than protectedSettings, readable by any principal with read access to the VM resource and visible in deployment history.
  • JIT with source Any: JIT enabled from the VM blade with default allowed source IPs, which opens the port to the internet for three hours on each request.
  • Half-finished Trusted Launch: Secure Boot and vTPM on but no Guest Attestation extension, so boot integrity monitoring and attestation alerts never fire.
  • ADE migration that forgets backups: live VMs moved to encryption at host while old restore points remain ADE-encrypted and fail to unlock after the retirement date.

Framework mapping

Control areaNIST SP 800-53 Rev 5NIST CSF 2.0ISO/IEC 27001:2022 Annex AMITRE ATT&CK
Control-plane least privilege, extension and Run Command governanceAC-6, CM-7PR.AA-05A.8.2 Privileged access rightsT1651, T1078.004
Disk encryption and key managementSC-28PR.DS-01A.8.24 Use of cryptography
Trusted Launch and boot integritySI-7PR.PS-01A.8.9 Configuration managementT1542.003
Management port access (JIT, Bastion)AC-17PR.AA-05A.8.20 Networks securityT1021.001, T1021.004
Patching and imagesSI-2, SA-22PR.PS-02A.8.8 Management of technical vulnerabilities
Logging and detectionAU-12DE.CM-09A.8.15 Logging, A.8.16 Monitoring activitiesT1552.005

CIS Controls v8.1 safeguards that apply directly include 3.11 (encrypt sensitive data at rest), 4.1 (secure configuration process), 5.4 (restrict administrator privileges to dedicated accounts), 7.3 (automated operating system patch management) and 8.2 (collect audit logs).

Practitioner checklist

  • Every Owner, Contributor and Virtual Machine Contributor assignment over VM scopes is PIM-eligible or a scoped workload identity, and reviewed quarterly.
  • "Only approved VM extensions should be installed" is assigned, moving from Audit to Deny after review.
  • No secrets in extension settings; scripts read secrets from Key Vault with a managed identity.
  • New VMs use encryption at host through templates; ADE-enabled VMs and restore points have a migration date before 15 September 2028.
  • Templates set securityType to TrustedLaunch with Secure Boot and vTPM enabled, and Guest Attestation is installed.
  • No management ports open to the internet: Bastion or JIT with restricted source ranges only.
  • Serial console disabled where not needed; boot diagnostics storage access restricted.
  • Periodic update assessment and Defender for Servers assigned by policy at management group scope.
  • Alerts exist for extension writes, Run Command, disk export and JIT requests by unexpected identities.
  • Azure Monitor agent and a data collection rule collect guest security events.

Standards and references

Related NHI Mgmt Group resources: Azure Bastion, Azure Arc Security Guide, Azure Managed Identities Security Guide, Azure RBAC and Service Principals Guide, Azure Security Checklist.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 15 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.