{
  "$schema" : "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion" : "1.0.0.0",
  "parameters" : {
    "vmName" : {
      "type" : "string"
    },
    "sa" : {
      "type" : "string"
    },
    "subnetRef" : {
      "type" : "string"
    },
    "vmSize" : {
      "type" : "string"
    },
    "adminUsername" : {
      "type" : "string"
    },
    "sshKeyData" : {
      "type" : "securestring",
      "metadata" : {
        "description" : "SSH RSA public key file as a string."
      }
    },
    "baseTemplateUrl" : {
      "type" : "string"
    },
    "imageReference" : {
      "type" : "object",
      "metadata" : {
        "description" : "imageReference object that should be used to create the virtual machine"
      }
    },
    "availabilitySet" : {
      "type" : "string"
    }
  },
  "variables" : {
    "apiVersion" : "2015-06-15",
    "sshKeyPath" : "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]"
  },
  "resources" : [
    {
      "apiVersion" : "[variables('apiVersion')]",
      "type" : "Microsoft.Network/networkInterfaces",
      "name" : "[concat(parameters('vmName'), 'nic')]",
      "location" : "[resourceGroup().location]",
      "tags" : {
        "displayName" : "NetworkInterface"
      },
      "properties" : {
        "ipConfigurations" : [
          {
            "name" : "ipconfig1",
            "properties" : {
              "privateIPAllocationMethod" : "Dynamic",
              "subnet" : {
                "id" : "[parameters('subnetRef')]"
              }
            }
          }
        ]
      }
    },
    {
      "apiVersion" : "[variables('apiVersion')]",
      "type" : "Microsoft.Compute/virtualMachines",
      "name" : "[parameters('vmName')]",
      "location" : "[resourceGroup().location]",
      "tags" : {
        "displayName" : "VirtualMachine"
      },
      "dependsOn" : [
        "[concat('Microsoft.Network/networkInterfaces/', concat(parameters('vmName'), 'nic'))]"
      ],
      "properties" : {
        "hardwareProfile" : {
          "vmSize" : "[parameters('vmSize')]"
        },
        "osProfile" : {
          "computerName" : "[parameters('vmName')]",
          "adminUsername" : "[parameters('adminUsername')]",
          "linuxConfiguration" : {
            "disablePasswordAuthentication" : "true",
            "ssh" : {
              "publicKeys" : [
                {
                  "path" : "[variables('sshKeyPath')]",
                  "keyData" : "[parameters('sshKeyData')]"
                }
              ]
            }
          }
        },
        "storageProfile" : {
          "imageReference" : "[parameters('imageReference')]",
          "osDisk" : {
            "name" : "osdisk",
            "vhd" : {
              "uri" : "[concat('http://', parameters('sa'), '.blob.core.windows.net/openshiftvmachines/', parameters('vmName'), '.vhd')]"
            },
            "caching" : "ReadWrite",
            "createOption" : "FromImage"
          },
          "dataDisks" : [
            {
              "caching" : "None",
              "createOption" : "Empty",
              "diskSizeGB" : "128",
              "lun" : 0,
              "name" : "datadisk1",
              "vhd" : {
                "uri" : "[concat('http://', parameters('sa'), '.blob.core.windows.net/openshiftvmachines/', parameters('vmName'), '_datadisk1.vhd')]"
              }
            },
            {
              "caching" : "None",
              "createOption" : "Empty",
              "diskSizeGB" : "128",
              "lun" : 1,
              "name" : "datadisk2",
              "vhd" : {
                "uri" : "[concat('http://', parameters('sa'), '.blob.core.windows.net/openshiftvmachines/', parameters('vmName'), '_datadisk2.vhd')]"
              }
            }
          ]
        },
        "networkProfile" : {
          "networkInterfaces" : [
            {
              "id" : "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), 'nic'))]"
            }
          ]
        },
        "availabilitySet" : {
          "id" : "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySet'))]"
        }
      }
    },
    {
      "type" : "Microsoft.Compute/virtualMachines/extensions",
      "name" : "[concat(parameters('vmName'),'/installcustomscript')]",
      "apiVersion" : "[variables('apiVersion')]",
      "location" : "[resourceGroup().location]",
      "tags" : {
        "displayName" : "VirtualMachineCustomScriptExtension"
      },
      "dependsOn" : [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
      ],
      "properties" : {
        "publisher" : "Microsoft.Azure.Extensions",
        "type" : "CustomScript",
        "typeHandlerVersion" : "2.0",
        "autoUpgradeMinorVersion" : true,
        "settings" : {
          "fileUris" : [
            "[concat(parameters('baseTemplateUrl'), 'node.sh')]"
          ]
        },
        "protectedSettings" : {
          "commandToExecute" : "sh node.sh"
        }
      }
    }
  ],
  "outputs" : {}
}