Lesson 5 of 5 Defender for Servers and Hybrid Security

Enforcing Configuration with Azure Machine Configuration

This lesson explains how Azure Machine Configuration extends policy into the guest operating system.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain what Machine Configuration adds to Azure Policy.
  • Describe how an assignment works.
  • Choose an assignment mode.
  • Compare related configuration tools.

Policy inside the guest

Azure Policy evaluates Resource Manager properties, so it can tell that a VM exists and which size it is, but it cannot see whether a password policy is set inside Windows. Azure Machine Configuration, formerly Azure Policy guest configuration, fills that gap. It audits or configures operating system and application settings, for Azure VMs and Azure Arc-enabled machines.

Typical uses include checking that a security baseline is applied, that certain software is present, that local administrators are as expected, and that TLS settings are hardened. Defender for Cloud uses this for operating system baseline recommendations in Plan 2.

How it works

Machine configuration uses a package, which contains the settings to check and the compliance rules, built on PowerShell Desired State Configuration technology. A guest assignment links a machine to a package, and an agent on the machine applies it. On Azure VMs this agent runs as an extension, and it needs a system-assigned managed identity to authenticate, which a built-in policy initiative can configure. On Arc-enabled machines, the agent is part of the Connected Machine agent.

A machine can hold up to 50 guest assignments. The agent evaluates periodically and reports the result. Compliance details appear per setting in Azure Policy, which helps an administrator to see which item failed.

True or false

How Machine Configuration works

Exam skills 3.2.9

Check how Azure Machine Configuration works.

Log in to try this activity Interactive activities are free with an account.

Assignment modes

Three modes decide how far machine configuration goes.

ModeBehaviourWhen to use
AuditReports on compliance, and changes nothingAssessing a fleet before enforcement
Apply and MonitorApplies settings once, and reports on driftSetting a baseline, while allowing managed exceptions
Apply and AutocorrectApplies settings, and corrects them if they driftEnforcing settings that must never change

Scenarios that use the phrases must automatically correct or must return to compliance point to Apply and Autocorrect. As with other policies, begin in Audit. An enforced setting can break an application, for example by disabling a protocol that it depends on.

Scenario questions

Choosing an assignment mode

Exam skills 3.2.9

Choose the Machine Configuration assignment mode for each requirement.

Log in to try this activity Interactive activities are free with an account.

Delivering configurations

Built-in policies and initiatives cover common baselines. For a custom requirement, an engineer creates a package, publishes it to a storage location, and creates a policy that deploys the assignment. Assignments can also be created directly on a machine. Azure Policy is the normal route, as it gives compliance reporting and applies to new machines automatically.

Limits matter. On Azure, Arm64 VMs are not supported, and neither are Uniform scale sets, although Flexible scale sets are. Supported systems include Windows Server 2012 to 2025, Windows 10 and 11, and current Linux distributions. From November 2026, machines on older Linux versions must upgrade to use PowerShell-based configurations with new agent versions, and those affected include Ubuntu 16.04 and Red Hat Enterprise Linux 7.x.

Comparing related tools

Several tools configure a server, and a question may test the difference, as the following comparison shows.

Machine Configuration
PurposeAudit and enforce settings
Corrects driftYes, with Autocorrect
StatusCurrent
Custom Script Extension
PurposeRun a script once
Corrects driftNo
StatusCurrent
Azure Automation State Configuration
PurposeLegacy desired state
Corrects driftYes
StatusRetires 30 September 2027

Azure Machine Configuration replaces Azure Automation State Configuration for new work.

Worked example

Enforcing a baseline

A company must ensure that a Windows security setting is present on all Azure VMs and on on-premises servers, and any change must be reversed automatically. New machines must be covered, and compliance must be reported centrally. What should you implement?

Onboard the on-premises servers with Azure Arc. Use Azure Machine Configuration with the Apply and Autocorrect mode, delivered through Azure Policy at a suitable scope, so that new machines are included and the compliance page reports centrally.

Audit mode would report drift without correcting it. A Custom Script Extension would run once. Group Policy could set the value on domain-joined servers, but it would not report centrally in Azure, nor reach machines outside the domain. Azure Automation State Configuration is retiring.

Check yourself

Which mode corrects drift automatically?

Show answer

Apply and Autocorrect. Apply and Monitor reports drift but does not correct it.

Exam Tips

Remember for the exam

  • Machine Configuration extends policy into the guest, on Azure and Arc machines.
  • Apply and Autocorrect corrects drift automatically.
  • A machine can hold up to 50 guest assignments.
  • Azure VMs need a system-assigned managed identity for it.