Authoring desired state
Key Principles
Principle
Description
Step-by-Step: From ARM Template to MechCloud
ARM Template (Original)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2025-05-01",
"name": "vnet1",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": ["10.0.0.0/16"]
},
"subnets": [
{
"name": "subnet1",
"properties": {
"addressPrefixes": ["10.0.1.0/24"]
}
}
]
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2025-05-01",
"name": "nsg1",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "allow-ssh",
"properties": {
"priority": 100,
"direction": "Inbound",
"access": "Allow",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "YOUR_IP/32",
"destinationAddressPrefix": "*"
}
}
]
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2025-05-01",
"name": "nic1",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', 'vnet1')]",
"[resourceId('Microsoft.Network/networkSecurityGroups', 'nsg1')]"
],
"properties": {
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', 'nsg1')]"
},
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'vnet1', 'subnet1')]"
},
"privateIPAllocationMethod": "Dynamic"
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2025-04-01",
"name": "vm1",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', 'nic1')]"
],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_B2pts_v2"
},
"osProfile": {
"computerName": "testvm",
"adminUsername": "ubuntu",
"adminPassword": "SecureP@ss2024!"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', 'nic1')]"
}
]
},
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "ubuntu-24_04-lts",
"sku": "server-arm64",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
}
}
}
}
}
]
}MechCloud Desired State (Converted)
Key Simplifications
1. The defaults: Block — Eliminate Repetition
defaults: Block — Eliminate Repetition2. The ref: Syntax — Simple Resource References
ref: Syntax — Simple Resource References3. Nested Resource References — Clean Path Syntax
4. No dependsOn Required
dependsOn RequiredConversion Rules
ARM Template
→
MechCloud
Template Variables
Variable
Description
Reference Syntax Summary
Scenario
ARM Template
MechCloud
Resource Paths
Resource
Path
Referencing Existing Resources
Same Resource Group
Different Resource Group (Same Subscription)
Reference Format Summary
Scenario
Format
Example: VM Using Existing VNet
Next Steps
Last updated