首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >需要从arm模板安装5个vst代理的5vm

需要从arm模板安装5个vst代理的5vm
EN

Stack Overflow用户
提问于 2021-01-30 18:44:59
回答 1查看 58关注 0票数 0
代码语言:javascript
运行
复制
{
    "$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 .

EN

回答 1

Stack Overflow用户

发布于 2021-02-01 12:58:00

代码语言:javascript
运行
复制
{
    "$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": {}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65971836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档