# Azure

MechCloud's Stateless Infrastructure as Code (IaC) for Azure enables you to declaratively manage your Azure resources without relying on state files, eliminating common issues like state drift. By defining your desired infrastructure in YAML and comparing it directly against your live Azure environment, you can provision, update, and delete resources with confidence. This feature supports a wide range of Azure resources (e.g., Virtual Networks, Subnets, Network Security Groups, Virtual Machines) and integrates real-time pricing to provide proactive cost insights during planning.

For details on resource contexts (equivalent to Kubernetes namespaces for scoping resources), see the Resource Contexts documentation.

### Key Concepts

#### Desired State

The desired state is your YAML blueprint describing the infrastructure you want. It's hierarchical, using nesting to define parent-child relationships (e.g., a subnet inside a virtual network).

**Requirements**:

* Each resource must have a **unique relative path** based on its hierarchy (e.g., vnet1/subnet1/vm1), similar to a Linux file path. This is your responsibility to ensure uniqueness and prevent conflicts.
* Use `snake_case` for all properties (e.g., address\_prefix instead of addressPrefix).
* No explicit parent references (e.g., no virtual\_network\_id for a subnet—MechCloud infers from hierarchy).
* References:
  * **Sibling references** (same parent): ref:\<name> (e.g., ref:nsg1).
  * **Non-sibling references** (cross-hierarchy): ref:\<full\_path> (e.g., ref:vnet1/nsg1).

#### Actual State

The actual state is a real-time snapshot of your Azure resources in the selected context, formatted to match the desired state structure (hierarchical, snake\_case properties). It includes resource types, names, identifiers, and properties.

#### Plan

The plan compares desired and actual states, proposing actions:

* **Create**: New resources.
* **Update**: In-place changes.
* **Recreate**: When at least one immutable property differs (requires delete + create).
* **Delete**: Remove extra resources.
* **None**: No changes needed.

Plans show hierarchy with indentation (-- for children) and include real-time pricing for compute/storage resources (hourly/monthly costs, % change).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mechcloud.io/cloud-computing/stateless-iac/azure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
