Skip to main content

Nerdio is Microsoft’s 2026 Americas ISV Partner of the Year Get the story

Blog

IT infrastructure automation: how to manage infrastructure as code

Learn how to manage IT infrastructure as code for Windows 365, Intune, and Azure Virtual Desktop with Bicep and Terraform pipelines.

Someone changed a scaling plan in the Azure Portal at 6 PM on Friday. Monday's login storm hits a host pool with half last week's capacity, and with infrastructure as code (IaC) the answer to what changed sits in a commit log.

Generic IaC playbooks assume every resource is disposable. A desktop estate carries state in its session hosts, images, and profiles. The host management model you choose decides which tools work at all, and the work between deployments needs an operator layer alongside the pipeline.

This guide is for platform owners and IT operations managers who run Windows 365, Microsoft Intune, and Azure Virtual Desktop and want desktop infrastructure defined in version-controlled code, with a pipeline between every change and production.

What IT infrastructure automation means for Windows Cloud

For Windows Cloud (the umbrella term for Windows 365 and Azure Virtual Desktop), IT infrastructure automation means defining Windows 365, Intune, and Azure Virtual Desktop in code and changing them only through a pipeline.

IaC manages infrastructure through code, and infrastructure automation is the broader practice that also covers configuration management and workflow orchestration. Microsoft's Well-Architected Framework favors declarative IaC tools that define the desired state of the environment.

Red Hat describes artificial intelligence for IT operations (AIOps) as "an approach to automating IT operations with machine learning and other advanced AI techniques," and IaC can supply the centralized data layer that kind of automation runs on.

Declarative IaC versus imperative scripts

Declarative IaC gives more predictable results on repeat runs than imperative scripts. A Bicep or Terraform file is declarative. It declares the end state, and the engine reconciles toward it.

Azure CLI and PowerShell scripts are imperative, and Microsoft's Cloud Adoption Framework notes imperative scripts depend on the environment's current state.

Why manual procedures and cloud waste make the case for code

Human error and rising cloud waste are both problems a code-defined estate helps you control. Uptime Institute's Annual Outage Analysis 2025, a data center survey, found 85% of human-error incidents stem from staff failing to follow procedures or from flawed procedures. Nearly 40% of organizations in that survey had a major human-error outage in the past three years.

Flexera's 2026 State of the Cloud Report found wasted spend on infrastructure as a service (IaaS) and platform as a service (PaaS) rose to 29%, the first increase in five years.

For a desktop team, those numbers show up as the Friday portal change from the opening and session hosts that keep running after users sign off. Fixing either one starts with knowing which parts of the estate code can manage.

Why a stateful desktop estate breaks the generic IaC playbook

A desktop estate breaks the generic playbook because its session hosts, and the images and profiles behind them, carry live user sessions and state. The tooling to manage them as code is also incomplete.

An Azure Virtual Desktop host pool, application group, workspace, and scaling plan behave like disposable resources. They are Azure Resource Manager (ARM) objects with Bicep references and matching resources in the azurerm Terraform provider. Replace a session host mid-shift and every user signed in to it gets disconnected.

The azurerm provider, at 5.9.0, still has no session host configuration resource because the underlying REST application programming interfaces (APIs) remain in preview. The documented workaround is an azurerm_windows_virtual_machine plus a PowerShell azurerm_virtual_machine_extension. Both Azure Verified Modules for host pools and scaling plans pin azurerm below 5.0.

Check module and provider versions against each other before you design a pipeline. Some management platforms ship their own Terraform providers to cover host lifecycle. The host management model you pick for Azure Virtual Desktop decides which tooling works at all.

Microsoft documents a choice between letting the service manage hosts and managing them yourself:

  • Session host configuration: The Azure Virtual Desktop service owns host creation and updates, and standard tools cannot change hosts outside it.
  • Standard management: You own the lifecycle, and Microsoft lists it as required for automated pipelines and partner tools.

Outside of session hosts, each layer of a Windows Cloud estate has its own configuration path:

  • Windows 365: Microsoft documents Microsoft Graph as the programmatic path for Cloud PCs, with provisioning policies created by a POST to /deviceManagement/virtualEndpoint/provisioningPolicies under the CloudPC.ReadWrite.All permission.
  • Intune: Configuration travels as exported settings catalog JSON or through Microsoft365DSC.
  • Azure Virtual Desktop images: Images live in Azure Compute Gallery and must be replicated to every target region before an ARM or Terraform deployment can reference them.
  • FSLogix: Profile containers are configured through registry and Group Policy settings with no resource properties to declare.

A working practice therefore layers several toolchains in one repository.

Windows 365 operations also require Intune management and an ongoing app lifecycle, with license reclamation as part of routine review. Azure Virtual Desktop is managed through the Azure Portal, PowerShell, and Intune.

How to manage infrastructure as code across Windows 365, Intune, and Azure Virtual Desktop

Define each layer in a declarative tool, keep every definition in source control, and let a gated pipeline make every change.

  1. Pick a declarative tool per layer: Microsoft recommends Bicep over ARM JSON templates for Azure-native resources and points to Terraform for multicloud or hybrid estates. Automate the deployment of the Azure Virtual Desktop control plane from the Azure/avdaccelerator repository, whose baseline deploys the host pool, scaling plan, and session hosts along with supporting storage and Key Vault. Keep Cloud PC provisioning policies and Intune settings as JSON in the same repository.
  2. Put every definition under source control with branch protection: In Microsoft's Azure Architecture Center guidance, the infrastructure definition is the source of truth, and approved manual changes are reconciled back through it. DevOps Research and Assessment (DORA) recommends trunk-based development, and GitHub branch protection can require reviews and status checks before a merge.
  3. Deploy only through pipelines, and preview before apply: Run bicep lint main.bicep and a what-if or Terraform plan on every pull request. The Bicep linter fails the pipeline on errors, and what-if previews changes without touching resources. Use a read identity for previews and a write identity for applies, and gate production behind an approval.
  4. Keep secrets in Key Vault: Pass secure values into Bicep with getSecret, which works only on Key Vault resources and only for @secure() parameters. Never emit secrets as Bicep outputs, because outputs land in deployment history.
  5. Manage state remotely: Terraform state belongs in an azurerm backend on Azure Blob Storage, which locks the blob before every state-writing operation. Pass credentials as environment variables, since -backend-config values show up in plan files. Bicep needs no separate state file because its what-if reads live state.
  6. Replace hosts from versioned images: Azure Image Builder, wrapped by Azure Virtual Desktop custom image templates, distributes versioned images to Azure Compute Gallery. Microsoft's image-based servicing for pooled multi-session hosts publishes a validated gallery version, then deploys new hosts and drains the old ones. In-place operating system (OS) upgrades are not supported on pooled multi-session hosts. Microsoft requires virtual machines (VMs) in a host pool to share type, size, and resource group, and FSLogix profile storage to sit in the hosts' region. Keep those aligned as you roll image versions.
  7. Detect drift, then deny it: Azure deployment stacks manage resources as one unit and can apply deny settings such as DenyDelete. These settings cover control-plane operations only. Azure Policy machine configuration in ApplyAndAutoCorrect mode corrects in-guest drift at the next evaluation. Microsoft Entra Tenant Governance captures configuration as code across 200+ resource types including Intune and scans for drift every six hours. Azure Blueprints stops accepting new assignments on October 31, 2026, and Microsoft names deployment stacks and template specs as the replacements.

That pipeline handles change. Runtime operations build on Microsoft's native services within their documented limits.

Where an operator layer adds to native Microsoft automation

An operator layer adds to native Microsoft automation in scaling, host patching, and Intune app delivery. Nerdio Manager for Enterprise is one such layer, with CPU and RAM scaling triggers, image updates, and Intune policy recovery.

Autoscale

Native autoscale runs on schedules and a capacity threshold, and Microsoft's autoscale documentation describes no CPU or memory triggers. In Microsoft's documented example, two hosts at 20 sessions each give a capacity of 40, and with a 75% threshold the 31st session turns on a third host.

Hosts under maintenance need the scaling plan's exclusion tag (Microsoft's example is excludeFromScaling), because pooled multi-session autoscale overwrites drain mode.

Patching and app delivery

Microsoft's update methodology guidance recommends session host update for Windows multi-session hosts and marks Azure Update Manager as unsupported there. Session host update replaces VMs in batches, and manual files and registry keys on the old VMs are lost. Microsoft also states you can't use it when you manage hosts with your own tools, which is the model a pipeline requires.

Native Intune application delivery can take up to 3 hours because Intune does not poll continuously, and Intune has no native backup and restore for deleted policies. For these workflows, Nerdio Manager extends and enhances Intune with application delivery and policy backup and restore.

Blast radius

Automation that reaches every host can break every host. Google Cloud's June 12, 2025 incident was triggered by a policy change containing blank fields that replicated globally within seconds and had no feature-flag protection. Some customers' monitoring ran on Google Cloud and failed with it.

For desktops, the equivalent is a canary host pool with health gates before each expansion, plus monitoring that lives outside the pipeline being changed.

Where Nerdio Manager fits in an infrastructure-as-code practice

Nerdio Manager fits as a runtime operator for scaling and app delivery, working alongside the pipeline that owns every change. It deploys from Microsoft Marketplace into your Azure subscription, and Microsoft infrastructure remains in place.

  • The Nerdio Terraform provider (Public Preview) manages host pools and session hosts as code and extends Terraform coverage to host lifecycle.
  • The REST API, which you turn on under System > Settings > Integrations, lets IT service management (ITSM) tools such as ServiceNow call console actions.

Carvana's Cloud Support Team Lead Brandon Holliday said, "When we saw Nerdio, I recognized immediately that they had put real thought into usability."

In a benchmark white paper from Dr. Benny Tritsch, a custom image update took 5:09 and 146 clicks natively versus 0:37 and 13 clicks in Nerdio Manager. That's 88% less time and 91% fewer clicks, which means fewer manual steps where a configuration error can slip in. Nerdio's Unified Application Management delivers apps to Cloud PCs in about 30 seconds.

Patented auto-scaling adds CPU and RAM triggers to session counts and can save enterprise customers on Azure compute. TechTarget's Enterprise Strategy Group found up to a 55% reduction in Azure Virtual Desktop costs with Nerdio Manager compared to running Azure Virtual Desktop alone in its economic validation report.

For a total-cost comparison, account for compute and Microsoft OS/access licensing alongside the third-party management layer. Your pipeline keeps ownership of every change, and the operator handles the scaling, patching, and app delivery that happen between commits.

What this means for your first automation sprint

Start with one non-production host pool and put it, along with its image build, behind a gated pipeline.

  1. Deploy a non-production host pool from the accelerator through the pipeline, with what-if and an approval gate.
  2. Put the image build on the same pipeline.
  3. Turn on deployment stack deny settings to block the Friday-evening portal change before Monday's login storm.
  4. Run host lifecycle under standard management, through Nerdio Manager or your scripts, and keep Cloud PC provisioning policies as Graph-exported JSON beside the Bicep.

Get a demo to see how Nerdio Manager works across your Windows 365 and Azure Virtual Desktop environment, or try it free in your Azure tenant.

Frequently asked questions about IT infrastructure automation

Ready to get started?