379 строки
16 KiB
JSON
379 строки
16 KiB
JSON
{
|
|
"$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,
|
|
"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",
|
|
"defaultValue": "Windows Server 2019 with Containers",
|
|
"allowedValues": [
|
|
"Windows Server 2016",
|
|
"Windows Server 2019",
|
|
"Windows Server 2019 with Containers"
|
|
],
|
|
"metadata": {
|
|
"Description": "Select the Operating System of the VM"
|
|
}
|
|
},
|
|
"vmSize": {
|
|
"type": "string",
|
|
"defaultValue": "Standard_D4s_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"
|
|
}
|
|
},
|
|
"StorageAccountType": {
|
|
"type": "string",
|
|
"defaultValue": "Premium_LRS",
|
|
"allowedValues": [
|
|
"Standard_LRS",
|
|
"Premium_LRS"
|
|
],
|
|
"metadata": {
|
|
"Description": "Select the preferred storage account type. Standard_LRS is HDD, Premium_LRS is SSD."
|
|
}
|
|
},
|
|
"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.170.1/vsts-agent-win-x64-2.170.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": "additional-installforbuildagent.ps1",
|
|
"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."
|
|
}
|
|
}
|
|
},
|
|
"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')]",
|
|
"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')))]",
|
|
"storageAccountType": "[parameters('StorageAccountType')]",
|
|
"OSDiskName": "[concat(variables('vmName'),'_osdisk')]",
|
|
"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": "2018-10-01",
|
|
"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": {
|
|
"createOption": "FromImage",
|
|
"osType": "Windows",
|
|
"name": "[variables('OSDiskName')]",
|
|
"caching": "ReadWrite",
|
|
"managedDisk": {
|
|
"storageAccountType": "[variables('storageAccountType')]"
|
|
},
|
|
"diskSizeGB": 128
|
|
}
|
|
},
|
|
"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')]"
|
|
],
|
|
"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'),'\"')]"
|
|
},
|
|
"protectedSettings": {}
|
|
}
|
|
}
|
|
],
|
|
"outputs": {
|
|
}
|
|
}
|