{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmAdminUsername": {
"type": "String",
"metadata": {
"description": "User name for the Virtual Machine."
}
},
"vmAdminPassword": {
"type": "SecureString",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"vmName": {
"type": "String",
"metadata": {
"description": "Unique hostname for the Virtual Machine."
}
},
"OSVersion": {
"defaultValue": "2019-Datacenter",
"type": "String",
"metadata": {
"description": "2019-Datacenter"
}
},
"existingVirtualNetworkResourceGroupName": {
"type": "String",
"metadata": {
"description": "VSTS deployment group name."
}
},
"existingSubnetName": {
"type": "String",
"metadata": {
"description": "Name of the existing subnet in the existing VNET you want to use"
}
},
"existingVirtualNetworkName": {
"type": "String",
"metadata": {
"description": "Name of the existing VNET"
}
},
"vmSize": {
"defaultValue": "Standard_D2_v3",
"type": "String",
"metadata": {
"description": "Desired Size of the VM. Any valid option accepted but if you choose premium storage type you must choose a DS class VM size."
}
},
"numberOfVms": {
"defaultValue": "1",
"type": "Int",
"metadata": {
"description": "Give the total number of vm to be deployed."
}
},
"VSTSAccount": {
"type": "String",
"metadata": {
"description": "Specify the name of the VSTSAccount Name"
}
},
"AgentName": {
"type": "String",
"metadata": {
"description": "Specify the name of the Agent"
}
},
"AgentPool": {
"type": "String",
"metadata": {
"description": "Specify the name of the AgentPool which is present"
}
},
"AgentNo": {
"type": "Int",
"metadata": {
"description": "Specify suffix number for Agent name "
}
},
"PATToken": {
"type": "String",
"metadata": {
"description": "Specify the PATToken of organisation or project"
}
},
"resourceTag": {
"type": "Object",
"metadata": {
"description": "Tag of AKS resource."
}
}
},
"variables": {
"imagePublisher": "MicrosoftWindowsServer",
"imageOffer": "WindowsServer",
"copy": [
{
"name": "Agent",
"count": "[parameters('numberOfVms')]",
"input": "[concat(parameters('AgentName'), copyIndex('Agent', 1))]"
}
],
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('existingVirtualNetworkName'))]",
"subnetRef": "[resourceID(parameters('existingVirtualNetworkResourceGroupName'), 'Microsoft.Network/virtualNetWorks/subnets', parameters('existingVirtualNetworkName'), parameters('existingSubnetName'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-06-01",
"name": "[concat(parameters('vmName'),'-nic', copyindex(1))]",
"location": "[resourceGroup().location]",
"dependsOn": [],
"tags": "[parameters('resourceTag')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
},
"copy": {
"name": "nicLoop",
"count": "[parameters('numberOfVms')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2017-03-30",
"name": "[concat(parameters('vmName'),'-vm', copyindex(1))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', concat(parameters('vmName'),'-nic', copyindex(1)))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[concat(parameters('vmName'),'-vm', copyindex(1))]",
"adminUsername": "[parameters('vmAdminUsername')]",
"adminPassword": "[parameters('vmAdminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('OSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(parameters('vmName'),'-nic', copyindex(1)))]"
}
]
}
},
"copy": {
"name": "vmLoop",
"count": "[parameters('numberOfVms')]",
"mode": "serial"
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2018-06-01",
"name": "[concat('virtualMachineName/agt',copyindex(1))]",
"location": "[ResourceGroup().location]",
"dependsOn": [
"[concat(parameters('vmName'),'-vm', copyindex(1))]"
],
"tags": "[parameters('resourceTag')]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"autoUpgradeMinorVersion": true,
"typeHandlerVersion": "1.10",
"settings": {
"fileUris": [
"https://ehpiacarmstorage.blob.core.windows.net/armagentscripts/winserviceagt.ps1"
]
},
"protectedSettings": {
"commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -Command .\\winserviceagt.ps1 -vstsAccount ', parameters('VSTSAccount'), ' -PAT ', parameters('PATToken'), ' -vstsAgent ', variables('Agent'), ' -AgentNo ', parameters('AgentNo'), ' -vmAdminPassword ''', parameters('vmAdminPassword'), ''' -vmAdminUserName ', parameters('vmAdminUsername'), ' -vstsPoolName ', parameters('AgentPool'))]"
}
},
"copy": {
"name": "agtLoop",
"count": "[parameters('numberOfVms')]"
}
}
],
"outputs": {}
}
错误消息
至少有一个资源部署操作失败。有关详细信息,请列出部署操作。有关使用细节,请参见https://aka.ms/DeployOperations。“,”详细信息“:[{”代码“:"InvalidTemplate",”消息“:”无法在'232‘和'9’行处理资源InvalidTemplate的模板语言表达式。“为语言函数“concat”提供的参数无效。所有参数或任何参数都必须是数组。有关使用细节,请参阅https://aka.ms/arm-template-expressions/#concat .
发布于 2021-02-01 12:58:00
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmAdminUsername": {
"type": "String",
"metadata": {
"description": "User name for the Virtual Machine."
}
},
"vmAdminPassword": {
"type": "SecureString",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"vmName": {
"type": "String",
"metadata": {
"description": "Unique hostname for the Virtual Machine."
}
},
"OSVersion": {
"defaultValue": "2019-Datacenter",
"type": "String",
"metadata": {
"description": "2019-Datacenter"
}
},
"indexValue": {
"defaultValue": "1",
"type": "Int",
"metadata": {
"description": "Give the starting deploy vm number for index start."
}
},
"existingVirtualNetworkResourceGroupName": {
"type": "String",
"metadata": {
"description": "VSTS deployment group name."
}
},
"existingSubnetName": {
"type": "String",
"metadata": {
"description": "Name of the existing subnet in the existing VNET you want to use"
}
},
"existingVirtualNetworkName": {
"type": "String",
"metadata": {
"description": "Name of the existing VNET"
}
},
"vmSize": {
"defaultValue": "Standard_D2_v3",
"type": "String",
"metadata": {
"description": "Desired Size of the VM. Any valid option accepted but if you choose premium storage type you must choose a DS class VM size."
}
},
"numberOfVms": {
"defaultValue": "1",
"type": "Int",
"metadata": {
"description": "Give the total number of vm to be deployed."
}
},
"VSTSAccount": {
"type": "String",
"metadata": {
"description": "Specify the name of the VSTSAccount Name"
}
},
"AgentName": {
"type": "String",
"metadata": {
"description": "Specify the name of the Agent"
}
},
"AgentPool": {
"type": "String",
"metadata": {
"description": "Specify the name of the AgentPool which is present"
}
},
"AgentNo": {
"type": "Int",
"metadata": {
"description": "Specify suffix number for Agent name "
}
},
"PATToken": {
"type": "String",
"metadata": {
"description": "Specify the PATToken of organisation or project"
}
},
"resourceTag": {
"type": "Object",
"metadata": {
"description": "Tag of AKS resource."
}
}
},
"variables": {
"imagePublisher": "MicrosoftWindowsServer",
"imageOffer": "WindowsServer",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('existingVirtualNetworkName'))]",
"subnetRef": "[resourceID(parameters('existingVirtualNetworkResourceGroupName'), 'Microsoft.Network/virtualNetWorks/subnets', parameters('existingVirtualNetworkName'), parameters('existingSubnetName'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-06-01",
"name": "[concat(parameters('vmName'),'-nic', copyindex(parameters('indexValue')))]",
"location": "[resourceGroup().location]",
"dependsOn": [],
"tags": "[parameters('resourceTag')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
},
"copy": {
"name": "nicLoop",
"count": "[parameters('numberOfVms')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2017-03-30",
"name": "[concat(parameters('vmName'),'-vm', copyindex(parameters('indexValue')))]",
"location": "[resourceGroup().location]",
"tags": "[parameters('resourceTag')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', concat(parameters('vmName'),'-nic', copyindex(parameters('indexValue'))))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[concat(parameters('vmName'),'-vm', copyindex(parameters('indexValue')))]",
"adminUsername": "[parameters('vmAdminUsername')]",
"adminPassword": "[parameters('vmAdminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('OSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(parameters('vmName'),'-nic', copyindex(parameters('indexValue'))))]"
}
]
}
},
"copy": {
"name": "vmLoop",
"count": "[parameters('numberOfVms')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('vmName'),'-vm', copyindex(parameters('indexValue')),'/agt')]",
"location": "[ResourceGroup().location]",
"dependsOn": [
"[concat(parameters('vmName'),'-vm', copyindex(parameters('indexValue')))]"
],
"tags": "[parameters('resourceTag')]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"autoUpgradeMinorVersion": true,
"typeHandlerVersion": "1.10",
"settings": {
"fileUris": [
"https://ehpiacarmstorage.blob.core.windows.net/armagentscripts/winserviceagt.ps1"
]
},
"protectedSettings": {
"commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -Command .\\winserviceagt.ps1 -vstsAccount ', parameters('VSTSAccount'), ' -PAT ', parameters('PATToken'), ' -vstsAgent ', parameters('AgentName'), ' -AgentNo ', parameters('AgentNo'), ' -vmAdminPassword ''', parameters('vmAdminPassword'), ''' -vmAdminUserName ', parameters('vmAdminUsername'), ' -vstsPoolName ', parameters('AgentPool'))]"
}
},
"copy": {
"name": "agtLoop",
"count": "[parameters('numberOfVms')]"
}
}
],
"outputs": {}
}
https://stackoverflow.com/questions/65971836
复制相似问题