Instantly share code, notes, and snippets.

Embed
What would you like to do?
CF to Arm Template
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"VmSize": {
"type": "string",
"defaultValue": "Standard_A1",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3",
"Standard_A4"
]
},
"SSHPublicKey": {
"type": "securestring"
},
"SSHLocation": {
"type": "string",
"minLength": 9,
"maxLength": 18,
"defaultValue": "0.0.0.0/0"
}
},
"variables": {
"VNetPrefix": "10.0.0.0/16",
"VNetSubnet1Name": "Subnet-1",
"VNetSubnet1Prefix": "10.0.0.0/24",
"VMNicVnetID": "[resourceId('Microsoft.Network/virtualNetworks', 'VNet')]",
"VMNicSubnetRef": "[concat(variables('VMNicVnetID'), '/subnets/', variables('VNetSubnet1Name'))]",
"VMNicPIPName": "VMNicPIP",
"ImageReferenceId": "/subscriptions/802df257-6032-4b50-884c-55cb9f074928/resourceGroups/clckwrkhackresources/providers/Microsoft.Compute/images/TestDriveImage10",
"VMNicName": "VMNic",
"VMNicPIPDnsName": "marcuscftoarm",
"AdminUsername": "adminmarcus",
"ComputerName": "azurevm"
},
"resources": [
{
"name": "VNet",
"type": "Microsoft.Network/virtualNetworks",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [],
"tags": {
"displayName": "VNet"
},
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('VNetPrefix')]"
]
},
"subnets": [
{
"name": "[variables('VNetSubnet1Name')]",
"properties": {
"addressPrefix": "[variables('VNetSubnet1Prefix')]"
}
}
]
}
},
{
"name": "[variables('VMNicName')]",
"type": "Microsoft.Network/networkInterfaces",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', 'VNet')]",
"[resourceId('Microsoft.Network/publicIPAddresses', variables('VMNicPIPName'))]"
],
"tags": {
"displayName": "VMNic"
},
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('VMNicSubnetRef')]"
},
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('VMNicPIPName'))]"
}
}
}
]
}
},
{
"name": "[variables('VMNicPIPName')]",
"type": "Microsoft.Network/publicIPAddresses",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [],
"tags": {
"displayName": "VMNicPIP"
},
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[variables('VMNicPIPDnsName')]"
}
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "VMSecurityGroup",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VMSecurityGroup"
},
"properties": {
"securityRules": [
{
"name": "ssh-rule",
"properties": {
"description": "Allow SSH",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "[parameters('SSHLocation')]",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
}
]
}
},
{
"name": "[variables('ComputerName')]",
"type": "Microsoft.Compute/virtualMachines",
"location": "[resourceGroup().location]",
"apiVersion": "2016-04-30-preview",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces','VMNic')]"
],
"tags": {
"displayName": "[variables('ComputerName')]"
},
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('VMSize')]"
},
"osProfile": {
"computerName": "[variables('ComputerName')]",
"adminUsername": "[variables('AdminUsername')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/',variables('AdminUsername'),'/.ssh/authorized_keys')]",
"keyData": "[parameters('SSHPublicKey')]"
}
]
}
}
},
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "16.04.0-LTS",
"version": "latest"
},
"osDisk": {
"name": "myOSDisk",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', 'VMNic')]"
}
]
}
}
}
],
"outputs": {
"PublicDNS ": {
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('VMNicPIPName'))).dnsSettings.fqdn]",
"type": "string"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment