The Simplest Way to Make Azure VMs and Pulumi Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use azure vms and pulumi to build cloud servers with real code. Pulumi reads your code and calls the Azure API to start new virtual machines. This workflow turns manual server clicks into repeatable software runs. Developers write server rules in languages like TypeScript, Python, or Go. The automation tool then builds the network cards, disks, and compute nodes in one step. Every server change goes through code review before it hits the cloud. How azure vms and pulumi handle identity a

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use azure vms and pulumi to build cloud servers with real code. Pulumi reads your code and calls the Azure API to start new virtual machines.

This workflow turns manual server clicks into repeatable software runs. Developers write server rules in languages like TypeScript, Python, or Go. The automation tool then builds the network cards, disks, and compute nodes in one step. Every server change goes through code review before it hits the cloud.

How azure vms and pulumi handle identity and state

Pulumi needs a cloud identity to create or change servers in Azure. Most teams set up an Azure service principal or a managed identity for this job. The tool logs in with that identity and sends requests to the Azure API.

Azure checks the role attached to that identity before it builds any resource. If the role allows server creation, Azure starts the virtual machine and attaches the disk. It also sets up the virtual network and applies your security group rules.

As Azure builds each part, it sends status details back to the automation tool. Pulumi records these server details in a central state file. On the next run, the tool compares your code against this saved state file. It then changes only the servers that differ from your code.

You can also assign a managed identity directly to the new virtual machine. This lets apps on the server talk to other cloud services without saved passwords. Pulumi links this identity to the server during the initial build step.

Common failure modes and how to scope roles

Many teams fail by giving their automation tool one huge admin role. If an attacker steals that key, they can delete every server in the account. Shared service accounts also make it hard to see who ran a bad update.

To fix this, give each project its own service identity with tight rules. Scope the role to a single resource group instead of the whole subscription. Allow the role to manage only virtual machines, disks, and network interfaces.

Azure RBAC + Pulumi Policy as Code: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

SSH keys and admin passwords are another common weak spot in server builds. If you put plain passwords in code, they end up in your state file. Always encrypt secret values in the state file or pull them from a secret store.

Network paths also need strict rules from day one. Do not attach public IP addresses to backend servers out of habit. Place your virtual machines inside private subnets and lock down inbound ports. Use network security groups to block public traffic by default.

Day two server updates and drift checks

Building a virtual machine is only the first part of the job. Once a server runs, engineers often log in to fix bugs or check logs. Manual changes inside the cloud portal cause drift between the live server and your code.

When someone edits a disk size by hand, the next code run might fail. Even worse, the tool might wipe out the manual fix during the next update. Teams should block manual portal edits on any resource group managed by code.

Run regular drift checks in your build pipeline to catch stray changes early. Keep startup scripts small so the server boots fast and stays easy to replace. When you need an OS update, build a fresh server image and swap it in.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

How should Pulumi log in to build Azure servers?

Use federated identity credentials with your build pipeline whenever possible. This method removes long-lived client secrets and uses short-lived tokens for each run.

Where are virtual machine passwords stored during a run?

Pulumi stores inputs in its state file, so mark all passwords as secret outputs. This encrypts the secret values before the tool writes them to your state backend.

What happens when I change a server size in code?

Pulumi sends an update call to the Azure API to resize the virtual machine. Azure will usually reboot the server to apply the new compute size.

The query runs. The emails stay hidden.