{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageAccountName": { "type": "string" }, "dnsNameForPublicIP": { "type": "string" }, "adminUserName": { "type": "string" }, "adminPassword": { "type": "securestring" }, "azureAdTenantId": { "type": "string" }, "azureAdAppId": { "type": "string" }, "azureAdAppSecret": { "type": "securestring" }, "imagePublisher": { "type": "string", "defaultValue": "Canonical", "metadata": { "description": "Image Publisher" } }, "imageOffer": { "type": "string", "defaultValue": "UbuntuServer", "metadata": { "description": "Image Offer" } }, "imageSKU": { "type": "string", "defaultValue": "14.04.2-LTS", "metadata": { "description": "Image SKU" } }, "location": { "type": "string", "defaultValue": "West US", "allowedValues": [ "East US", "West US", "West Europe", "North Europe", "East Asia", "South East Asia" ], "metadata": { "description": "Deployment location" } }, "vmSize": { "type": "string", "defaultValue": "Standard_A0" }, "publicIPAddressName": { "type": "string", "defaultValue": "myPublicIP" }, "vmName": { "type": "string", "defaultValue": "myLinuxVM" }, "virtualNetworkName": { "type": "string", "defaultValue": "myVNET" }, "nicName": { "type": "string", "defaultValue": "myNIC" } }, "variables": { "addressPrefix": "10.0.0.0/16", "subnet1Name": "Subnet-1", "subnet2Name": "Subnet-2", "subnet1Prefix": "10.0.0.0/24", "subnet2Prefix": "10.0.1.0/24", "vmStorageAccountContainerName": "vhds", "publicIPAddressType": "Dynamic", "storageAccountType": "Standard_LRS", "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]", "subnet1Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "name": "[parameters('storageAccountName')]", "apiVersion": "2015-06-15", "location": "[parameters('location')]", "properties": { "accountType": "[variables('storageAccountType')]" } }, { "apiVersion": "2015-06-15", "type": "Microsoft.Network/publicIPAddresses", "name": "[parameters('publicIPAddressName')]", "location": "[parameters('location')]", "properties": { "publicIPAllocationMethod": "[variables('publicIPAddressType')]", "dnsSettings": { "domainNameLabel": "[parameters('dnsNameForPublicIP')]" } } }, { "apiVersion": "2015-06-15", "type": "Microsoft.Network/virtualNetworks", "name": "[parameters('virtualNetworkName')]", "location": "[parameters('location')]", "properties": { "addressSpace": { "addressPrefixes": [ "[variables('addressPrefix')]" ] }, "subnets": [ { "name": "[variables('subnet1Name')]", "properties": { "addressPrefix": "[variables('subnet1Prefix')]" } }, { "name": "[variables('subnet2Name')]", "properties": { "addressPrefix": "[variables('subnet2Prefix')]" } } ] } }, { "apiVersion": "2015-06-15", "type": "Microsoft.Network/networkInterfaces", "name": "[parameters('nicName')]", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]", "[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]" ], "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]" }, "subnet": { "id": "[variables('subnet1Ref')]" } } } ] } }, { "apiVersion": "2015-06-15", "type": "Microsoft.Compute/virtualMachines", "name": "[parameters('vmName')]", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", "[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]" ], "properties": { "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "osProfile": { "computerName": "[parameters('vmName')]", "adminUsername": "[parameters('adminUserName')]", "adminPassword": "[parameters('adminPassword')]" }, "storageProfile": { "imageReference": { "publisher": "[parameters('imagePublisher')]", "offer": "[parameters('imageOffer')]", "sku": "[parameters('imageSKU')]", "version": "latest" }, "osDisk": { "name": "osdisk1", "vhd": { "uri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/','osdisk1spec.vhd')]" }, "caching": "ReadWrite", "createOption": "FromImage" } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',parameters('nicName'))]" } ] } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(parameters('vmName'),'/writemetadatajson')]", "apiVersion": "2015-06-15", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]" ], "properties": { "publisher": "Microsoft.OSTCExtensions", "type": "CustomScriptForLinux", "typeHandlerVersion": "1.5", "settings": { "fileUris": [ "[concat('https://', parameters('storageAccountName'), '.blob.core.windows.net/customscript/readmeta.sh')]" ] }, "protectedSettings": { "commandToExecute": "[concat('bash readmeta.sh ', parameters('azureAdTenantId'), ' ', parameters('azureAdAppId'), ' ', parameters('azureAdAppSecret'))]" } } } ] }