nav-arm-templates/buildagent.json

366 строки
15 KiB
JSON
Исходник Обычный вид История

2018-11-24 11:40:51 +03:00
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"defaultValue": "",
"minLength": 3,
"maxLength": 15,
2018-11-24 11:40:51 +03:00
"metadata": {
"Description": "Select the name of the deployment"
}
},
"RemoteDesktopAccess": {
"type": "string",
"defaultValue": "",
"minLength": 1,
"metadata": {
"Description": "Specify * (star) to allow all remote desktop access, specify - (minus) to deny all remote desktop access or provide an address range using CIDR notation, e.g. 10.0.0.0/24; an IP address; or a list of address ranges or IP addresses"
}
},
"OperatingSystem": {
"type": "string",
2018-12-04 09:24:36 +03:00
"defaultValue": "Windows Server 2019 with Containers",
2018-11-24 11:40:51 +03:00
"allowedValues": [
"Windows Server 2016",
2018-12-04 09:24:36 +03:00
"Windows Server 2019",
"Windows Server 2019 with Containers"
],
2018-11-24 11:40:51 +03:00
"metadata": {
"Description": "Select the Operating System of the VM"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_D4_v3",
"allowedValues": [
"Standard_D2_v2",
"Standard_D3_v2",
"Standard_D4_v2",
"Standard_D5_v2",
"Standard_DS2_v2",
"Standard_DS3_v2",
"Standard_DS4_v2",
"Standard_DS5_v2",
"Standard_D2_v3",
"Standard_D4_v3",
"Standard_D8_v3",
"Standard_D16_v3",
"Standard_D2s_v3",
"Standard_D4s_v3",
"Standard_D8s_v3",
"Standard_D16s_v3"
],
"metadata": {
"Description": "Select the VM size of the deployment"
}
},
"vmAdminUsername": {
"type": "string",
"defaultValue": "vmadmin",
"minLength": 1,
"metadata": {
"Description": "Specify administrator user name for connecting to the VM"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"Description": "Specify administrator password for VM, Business Central and SQL (if applicable)"
}
},
"DevOpsOrganization": {
"type": "string",
"minLength": 1,
"metadata": {
"Description": "Specify the URL for your Azure DevOps Organization (ex. https://dev.azure.com/freddykristiansen)"
}
},
"PersonalAccessToken": {
"type": "securestring",
"minLength": 1,
"metadata": {
"Description": "Specify the URL for your Azure DevOps Organization (ex. https://dev.azure.com/freddykristiansen)"
}
},
"Pool": {
"type": "string",
"defaultValue": "default",
"minLength": 1,
"metadata": {
"Description": "Specify the URL for your Azure DevOps Organization (ex. https://dev.azure.com/freddykristiansen)"
}
},
"VstsAgentUrl": {
"type": "string",
"defaultValue": "https://vstsagentpackage.azureedge.net/agent/2.142.1/vsts-agent-win-x64-2.142.1.zip",
"minLength": 1,
"metadata": {
"Description": "Specify the URL for downloading the x64 VSTS Agent for your Azure DevOps Organization (go to https://dev.azure.com/{your_organization}/_admin/_AgentPool and click Download agent and select x64 to get the URL)"
}
},
"FinalSetupScriptUrl": {
"type": "string",
"defaultValue": "",
"metadata": {
"Description": "Optional: Specify a Url to a PowerShell script that should be executed on the VM to do the final setup of the VM."
}
2018-11-24 11:40:51 +03:00
}
},
"variables": {
"vmName": "[trim(parameters('vmName'))]",
"vmSize": "[parameters('vmSize')]",
"RemoteDesktopAccess": "[parameters('RemoteDesktopAccess')]",
"vmAdminUsername": "[trim(parameters('vmAdminUsername'))]",
"adminPassword": "[parameters('adminPassword')]",
"OperatingSystem": "[parameters('OperatingSystem')]",
"imagePublisher": "[if(equals(variables('OperatingSystem'),'Windows 10'),'MicrosoftWindowsDesktop','MicrosoftWindowsServer')]",
"imageOffer": "[if(equals(variables('OperatingSystem'),'Windows 10'),'Windows-10','WindowsServer')]",
2018-11-30 01:37:06 +03:00
"imageSku": "[if(equals(variables('OperatingSystem'),'Windows 10'),'rs5-pro',if(equals(variables('OperatingSystem'),'Windows Server 2016'),'2016-Datacenter',if(equals(variables('OperatingSystem'),'Windows Server 2019'),'2019-Datacenter','2019-Datacenter-with-containers')))]",
2018-11-24 11:40:51 +03:00
"storageAccountType": "Standard_LRS",
"vmStorageAccountContainerName": "vhds",
"publicIPAddressName": "[concat(variables('vmName'), '_pip')]",
"storageAccountName": "[concat('storage', uniqueString(resourceGroup().id))]",
"networkSecurityGroupName": "networksecuritygroup",
"dnsName": "[tolower(variables('vmName'))]",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"virtualNetworkName": "virtualnetwork",
"server1Name": "[tolower(variables('vmName'))]",
"nic1Name": "[concat(variables('vmName'),'_nic')]",
"delimiters": [ ",", ";" ],
"RdpAddresses": "[if(equals(variables('RemoteDesktopAccess'),'-'),'',variables('RemoteDesktopAccess'))]",
"rdpSourceAddressPrefix": "[split(variables('RdpAddresses'),variables('delimiters'))]",
"noOfAddresses": "[length(variables('rdpSourceAddressPrefix'))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"ScriptCommandToExecute": "powershell.exe -executionpolicy unrestricted -file "
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"location": "[resourceGroup().location]",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[variables('dnsName')]"
}
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('networkSecurityGroupName')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
]
}
},
{
"apiVersion": "2015-01-01",
"type": "Microsoft.Resources/deployments",
"name": "rdp-0",
"condition": "[not(equals(variables('RemoteDesktopAccess'),'-'))]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/',variables('networkSecurityGroupName'))]"
],
"properties": {
"mode":"Incremental",
"parameters":{},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [],
"outputs": {}
}
}
},
{
"apiVersion": "2015-01-01",
"type": "Microsoft.Resources/deployments",
"name": "[concat('rdp-', copyIndex(1))]",
"condition": "[not(equals(variables('RemoteDesktopAccess'),'-'))]",
"dependsOn": [
"[concat('rdp-', copyIndex())]"
],
"copy": {
"name": "iterator",
"count": "[variables('noOfAddresses')]"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2016-09-01",
"name": "[concat(variables('networkSecurityGroupName'),'/Rdp',copyIndex())]",
"type": "Microsoft.Network/networkSecurityGroups/securityRules",
"location":"[resourceGroup().location]",
"properties":{
"description": "Remote Desktop Access",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "3389",
"sourceAddressPrefix": "[variables('rdpSourceAddressPrefix')[copyIndex()]]",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": "[add(copyIndex(),100)]",
"direction": "Inbound"
}
}
],
"outputs": {}
}
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/',variables('networkSecurityGroupName'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
}
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nic1Name')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('server1Name')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nic1Name'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[variables('server1Name')]",
"adminUsername": "[variables('vmAdminUsername')]",
"adminPassword": "[variables('adminPassword')]",
"windowsConfiguration": {
"provisionVMAgent": true
}
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('imageSku')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('server1Name'),'.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nic1Name'))]"
}
]
}
},
"resources": [
]
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('server1Name'),'/vmextension1')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "PowerShellScript2"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('server1Name'))]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[uri(deployment().properties.templateLink.uri, 'initbuildagent.ps1')]"
],
2019-12-11 15:06:22 +03:00
"commandToExecute": "[concat(variables('ScriptCommandToExecute'),'initbuildagent.ps1',' -TemplateLink \"',deployment().properties.templateLink.uri,'\" -VMAdminUsername \"',variables('vmAdminUsername'),'\" -AdminPassword \"',replace(variables('adminPassword'),'\"','\\\"'),'\" -DevOpsOrganization \"',parameters('devopsorganization'),'\" -PersonalAccessToken \"',parameters('personalaccesstoken'),'\" -VstsAgentUrl \"',parameters('VstsAgentUrl'),'\" -FinalSetupScriptUrl \"',parameters('FinalSetupScriptUrl'),'\" -Pool \"',parameters('pool'),'\" -vmName \"',variables('vmName'),'\"')]"
2018-11-24 11:40:51 +03:00
},
"protectedSettings": {}
}
}
],
"outputs": {
}
}