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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use azure bicep and azure vms to build cloud servers from plain text files. Bicep templates define the server size, disk, and network rules before Azure creates the machine. This workflow turns manual portal clicks into repeatable steps. Your team writes one template and deploys identical virtual machines across test and live groups. Every change goes through code review first, which stops drift and human error. How permissions and data flow in azure bicep and azure vms A deployment pi

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 bicep and azure vms to build cloud servers from plain text files. Bicep templates define the server size, disk, and network rules before Azure creates the machine.

This workflow turns manual portal clicks into repeatable steps. Your team writes one template and deploys identical virtual machines across test and live groups. Every change goes through code review first, which stops drift and human error.

How permissions and data flow in azure bicep and azure vms

A deployment pipeline starts when a developer pushes a Bicep file to source control. The build runner logs in to Azure using a workload identity with scoped role assignments. The runner sends the compiled template to the Azure control plane. Azure reads that file and checks if the identity has the right permissions.

Next, the control plane provisions the network card, storage disk, and the virtual machine itself. Bicep does not log in to the guest system directly during this build step. Instead, it passes startup scripts or cloud init files through the Azure control API. The virtual machine boots up, reads those instructions, and sets up its own local apps.

For secrets like admin passwords or SSH keys, Bicep references an Azure key vault. The template passes a pointer to the secret rather than holding raw text in code. The control plane pulls the secret during creation and injects it into the virtual machine. This keeps sensitive keys out of git history and build logs.

Common failure modes and how to scope roles and networks

Many teams make the mistake of giving their deployment runner owner rights on the subscription. A broad token can delete databases or change network rules outside the target group. You should scope the runner role to a single resource group instead. Grant only the exact compute and network permissions needed to create the servers.

Shared admin accounts inside the virtual machines cause another major risk. Teams often bake one static SSH key or password into a Bicep template. When five engineers use that same key, the system logs cannot show who ran a command. Remove static local keys from your templates and require Microsoft Entra ID logins for each user.

Azure RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Public IP addresses in Bicep templates also expose machines to constant port scans. A single template mistake can open management ports to the whole internet. Place every virtual machine inside a private virtual network subnet by default. Block direct public IPs through Azure policy so bad templates fail during the check step.

How to manage day two server updates

Once a virtual machine is running, teams often change settings by hand during an outage. The next time the Bicep pipeline runs, it overwrites those manual fixes and breaks the app. Treat your templates as the only source of truth for disk sizes and network rules.

Keep guest app updates separate from hardware templates. Use Bicep to build the base machine, attach disks, and assign a managed identity. Let the machine pull its own app code after boot using that managed identity. This split keeps deployment times fast and stops hardware updates from breaking running software.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How do we keep admin passwords out of Bicep files?

Store all passwords and SSH keys inside an Azure key vault before you run a build. Mark the input as secure in your Bicep file and link it to that vault.

What happens when we run a Bicep file on an existing VM?

Azure compares the template to the live machine and updates only the changed properties. Some changes, like resizing a disk or changing the OS image, will reboot or rebuild the server.

Should Bicep manage users inside the guest operating system?

No, Bicep should only set up the machine and enable the identity extension. Let your central identity provider manage which human users can log in to the operating system.

The query runs. The emails stay hidden.