cloud-blender
Version:
A high level library for cloud compute operations
179 lines (178 loc) • 5.72 kB
JavaScript
module.exports = function () {
var armCreateLinuxVmTemplate = {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"userImagestorageAccountName": {
"type": "string",
"defaultValue": "group69720",
"metadata": {
"description": "This is the name of the Image storage account"
}
},
"storageAccountName": {
"type": "string",
"defaultValue": "storageaccounthpe",
"metadata": {
"description": "This is the name of the the VM storage account"
}
},
"osImageVhdUri": {
"type": "string",
"defaultValue": "https://group69720.blob.core.windows.net/system/Microsoft.Compute/Images/images/image1461230168730-osDisk.d3dd6f94-ef37-47e7-982f-222f77419eb5.vhd",
"metadata": {
"description": "Uri of the your user image"
}
},
"vnetName": {
"type": "string",
"defaultValue": "VNet1",
"metadata": {
"description": "This is the name of the existing Vnet"
}
},
"vnetResourceGroup": {
"type": "string",
"metadata": {
"description": "Name of the existing VNET resource group"
},
"defaultValue": "preptest2-rg"
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS2",
"metadata": {
"description": "This is the size of your VM"
}
},
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
"subnet1Name": {
"type": "string",
"metadata": {
"description": "Name of the subnet"
},
"defaultValue": "Subnet1"
},
"customData": {
"type": "string",
"metadata": {
"description": "custom data"
}
},
"keyData": {
"type": "string",
"metadata": {
"description": "Key data"
}
}
},
"variables": {
"vnetID": "[resourceId(parameters('vnetResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('vnetName'))]",
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/',parameters('subnet1Name'))]",
"osDiskVhdName": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/vhds/',parameters('vmName'),'.vhd')]",
"osImageName": "[concat(parameters('vmname'),'-os.vhd')]",
"adminUserName": "ubuntu",
"publicIPName": "[concat(parameters('vmname'),'-PIP')]",
"nicName": "[concat(parameters('vmname'),'-NIC')]"
},
"resources": [
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[parameters('vmName')]"
},
"location": "[resourceGroup().location]"
}
},
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/',variables('publicIPName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPName'))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[resourceGroup().location]",
"tags": "",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[variables('adminUsername')]",
"customData": "[parameters('customData')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/home/ubuntu/.ssh/authorized_keys",
"keyData": "[parameters('keyData')]"
}
]
}
}
},
"storageProfile": {
"osDisk": {
"name": "[variables('osImageName')]",
"osType": "Linux",
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "[parameters('osImageVhdUri')]"
},
"vhd": {
"uri": "[variables('osDiskVhdName')]"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
}
]
}
}
}
],
"outputs": {}
};
return armCreateLinuxVmTemplate;
};