self.setDefaultTemplate = function()

in plugin-azure-server/src/main/resources/buildServerResources/images.vm.js [1107:1285]


  self.setDefaultTemplate = function () {
    if (self.image().disableTemplateModification() !== true) {
      self.image().template('{\n' +
        '  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",\n' +
        '  "contentVersion": "1.0.0.0",\n' +
        '  "parameters": {\n' +
        '    "vmName": {\n' +
        '      "type": "string",\n' +
        '      "metadata": {\n' +
        '        "description": "This is the Virtual Machine name."\n' +
        '      }\n' +
        '    }\n' +
        '  },\n' +
        '  "variables": {\n' +
        '    "location": "[resourceGroup().location]",\n' +
        '    "nicName": "[concat(parameters(\'vmName\'), \'-net\')]",\n' +
        '    "subnetRef": "..."\n' +
        '  },\n' +
        '  "resources": [\n' +
        '    {\n' +
        '      "apiVersion": "2016-09-01",\n' +
        '      "type": "Microsoft.Network/networkInterfaces",\n' +
        '      "name": "[variables(\'nicName\')]",\n' +
        '      "location": "[variables(\'location\')]",\n' +
        '      "properties": {\n' +
        '        "ipConfigurations": [\n' +
        '          {\n' +
        '            "name": "[concat(parameters(\'vmName\'), \'-config\')]",\n' +
        '            "properties": {\n' +
        '              "privateIPAllocationMethod": "Dynamic",\n' +
        '              "subnet": {\n' +
        '                "id": "[variables(\'subnetRef\')]"\n' +
        '              }\n' +
        '            }\n' +
        '          }\n' +
        '        ]\n' +
        '      }\n' +
        '    },\n' +
        '    {\n' +
        '      "apiVersion": "2016-04-30-preview",\n' +
        '      "type": "Microsoft.Compute/virtualMachines",\n' +
        '      "name": "[parameters(\'vmName\')]",\n' +
        '      "location": "[variables(\'location\')]",\n' +
        '      "dependsOn": [\n' +
        '        "[concat(\'Microsoft.Network/networkInterfaces/\', variables(\'nicName\'))]"\n' +
        '      ],\n' +
        '      "properties": {\n' +
        '        "hardwareProfile": {\n' +
        '          "vmSize": "Standard_A2"\n' +
        '        },\n' +
        '        "osProfile": {\n' +
        '          "computerName": "[parameters(\'vmName\')]",\n' +
        '          "adminUsername": "...",\n' +
        '          "adminPassword": "..."\n' +
        '        },\n' +
        '        "storageProfile": {\n' +
        '          "osDisk": {\n' +
        '            "name": "[concat(parameters(\'vmName\'), \'-os\')]",\n' +
        '            "osType": "...",\n' +
        '            "caching": "ReadWrite",\n' +
        '            "createOption": "FromImage"\n' +
        '          },\n' +
        '          "imageReference": {\n' +
        '            "id": "..."\n' +
        '          }\n' +
        '        },\n' +
        '        "networkProfile": {\n' +
        '          "networkInterfaces": [\n' +
        '            {\n' +
        '              "id": "[resourceId(\'Microsoft.Network/networkInterfaces\', variables(\'nicName\'))]"\n' +
        '            }\n' +
        '          ]\n' +
        '        }\n' +
        '      }\n' +
        '    }\n' +
        '  ]\n' +
        '}\n');
    } else {
      self.image().template('{\n' +
        '  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",\n' +
        '  "contentVersion": "1.0.0.0",\n' +
        '  "parameters": {\n' +
        '\t"vmName": {\n' +
        '\t\t"type": "string"\n' +
        '\t},\t\n' +
        '\t"customData" : { \n' +
        '\t\t"type" : "string"\n' +
        '\t},\t\n' +
        '\t"teamcity-profile": {\n' +
        '\t\t"type": "string"\n' +
        '\t},\n' +
        '\t"teamcity-image-hash": {\n' +
        '\t\t"type": "string"\n' +
        '\t},\n' +
        '\t"teamcity-data-hash": {\n' +
        '\t\t"type": "string"\n' +
        '\t},\n' +
        '\t"teamcity-server": {\n' +
        '\t\t"type": "string"\n' +
        '\t},\n' +
        '\t"teamcity-source": {\n' +
        '\t\t"type": "string"\n' +
        '\t}\n' +
        '  },\n' +
        '  "variables": {\n' +
        '    "location": "[resourceGroup().location]",\n' +
        '    "nicName": "[concat(parameters(\'vmName\'), \'-net\')]",\n' +
        '    "subnetRef": "..."\n' +
        '  },\n' +
        '  "resources": [\n' +
        '    {\n' +
        '      "apiVersion": "2016-09-01",\n' +
        '      "type": "Microsoft.Network/networkInterfaces",\n' +
        '      "name": "[variables(\'nicName\')]",\n' +
        '      "location": "[variables(\'location\')]",\n' +
        '      "properties": {\n' +
        '        "ipConfigurations": [\n' +
        '          {\n' +
        '            "name": "[concat(parameters(\'vmName\'), \'-config\')]",\n' +
        '            "properties": {\n' +
        '              "privateIPAllocationMethod": "Dynamic",\n' +
        '              "subnet": {\n' +
        '                "id": "[variables(\'subnetRef\')]"\n' +
        '              }\n' +
        '            }\n' +
        '          }\n' +
        '        ]\n' +
        '      }\n' +
        '    },\n' +
        '    {\n' +
        '      "apiVersion": "2022-03-01",\n' +
        '      "type": "Microsoft.Compute/virtualMachines",\n' +
        '      "name": "[parameters(\'vmName\')]",\n' +
        '      "location": "[variables(\'location\')]",\n' +
        '      "dependsOn": [\n' +
        '        "[concat(\'Microsoft.Network/networkInterfaces/\', variables(\'nicName\'))]"\n' +
        '      ],\n' +
        '\t  "tags": {\n' +
        '        "teamcity-profile": "[parameters(\'teamcity-profile\')]",\n' +
        '        "teamcity-image-hash": "[parameters(\'teamcity-image-hash\')]",\n' +
        '        "teamcity-data-hash": "[parameters(\'teamcity-data-hash\')]",\n' +
        '        "teamcity-server": "[parameters(\'teamcity-server\')]",\n' +
        '        "teamcity-source": "[parameters(\'teamcity-source\')]"\n' +
        '      },\n' +
        '      "properties": {\n' +
        '        "hardwareProfile": {\n' +
        '          "vmSize": "Standard_A2"\n' +
        '        },\n' +
        '        "osProfile": {\n' +
        '          "computerName": "[parameters(\'vmName\')]",\n' +
        '          "adminUsername": "...",\n' +
        '          "adminPassword": "...",\n' +
        '          "customData": "[parameters(\'customData\')]"\n' +
        '        },\n' +
        '        "storageProfile": {\n' +
        '          "osDisk": {\n' +
        '            "name": "[concat(parameters(\'vmName\'), \'-os\')]",\n' +
        '            "osType": "Windows",\n' +
        '            "caching": "ReadWrite",\n' +
        '            "createOption": "FromImage"\n' +
        '          },\n' +
        '          "imageReference": {\n' +
        '            "id": "...",\n' +
        '            "exactVersion": "..."\n' +
        '          }\n' +
        '        },\n' +
        '        "networkProfile": {\n' +
        '          "networkInterfaces": [\n' +
        '            {\n' +
        '              "id": "[resourceId(\'Microsoft.Network/networkInterfaces\', variables(\'nicName\'))]"\n' +
        '            }\n' +
        '          ]\n' +
        '        }\n' +
        '      }\n' +
        '    }\n' +
        '  ]\n' +
        '}');
    }
  };