HeadlinesBriefing favicon HeadlinesBriefing.com

Azure Machine Configuration for Linux VMs

DEV Community •
×

Azure Machine Configuration now supports Linux VMs using PowerShell DSC, but with a unique twist. Unlike Windows, Linux systems lack native PowerShell, so the AzurePolicyForLinux extension installs it silently for policy use only. Managing Linux servers requires compatible DSC resources, with the NxTools module being the recommended choice. It provides POSIX wrappers for essential tasks like managing files, users, groups, packages, and services, enabling true infrastructure-as-code for Linux environments.

Configuring a Linux VM involves creating a DSC configuration that imports NxTools. For instance, you can define resources to ensure a specific user exists, add them to a group, and use an nxScript block to create files. This script block requires returning a custom Reason object, which Azure displays in the portal if the VM becomes noncompliant. This approach allows granular control over Linux server states directly from Azure.

A critical detail is that compiling these configurations requires a Linux environment with PowerShell installed; Windows or macOS machines will throw errors. To streamline this, administrators can use CI/CD pipelines or GitHub Actions for packaging. The process involves installing the necessary modules, compiling the configuration to a MOF file, and using the GuestConfiguration package cmdlet. Once packaged, the configuration is ready for deployment to target Linux VMs via Azure Machine Configuration.