简体   繁体   English

如何将多个参数传递到 Azure RM 模板自定义脚本扩展

[英]How to pass multiple parameters into an Azure RM Template Custom Script Extension

I am trying to pass multiple parameters to a Custom Script Extension using an ARM template, here is a snippet of the ARM template that currently works without issue:我正在尝试使用 ARM 模板将多个参数传递给自定义脚本扩展,这是 ARM 模板的片段,目前可以正常工作:

{
            "name": "Microsoft.CustomScriptExtension-20210604105657",
            "apiVersion": "2015-01-01",
            "type": "Microsoft.Resources/deployments",
            "properties": {
                "mode": "incremental",
                "templateLink": {
                    "uri": "https://catalogartifact.azureedge.net/publicartifactsmigration/Microsoft.CustomScriptExtension-arm.2.0.56/Artifacts/MainTemplate.json"
                },
                "parameters": {
                    "vmName": {
                        "value": "real-vm-name"
                    },
                    "location": {
                        "value": "uksouth"
                    },
                    "fileUris": {
                        "value": "https://realwebsite/script.ps1"
                    },
                    "arguments": {
                        "value": "[parameters('param1')]"
                    }
                }
            },

But whenever I add another parameter to the arguments section, the template validation fails.但是,每当我向 arguments 部分添加另一个参数时,模板验证都会失败。 This is what I have tried to do:这是我试图做的:

                        "arguments": {
                            "value": "[parameters('param1')], [parameters('param2')]"
                        }

Please can somebody help?请问有人可以帮忙吗?

Can you try to concat or format the parameters depending on what parameters you're using like this:您可以尝试根据您使用的参数来连接或格式化参数,如下所示:

 "value": "[concat(parameters('param1'), parameters('param2'))]"
 "value": "[format(parameters('param1'), parameters('param2'))]"

The Azure doc I referred to:我提到的 Azure 文档:

ARM Deployment Scripts ARM 部署脚本

Concat function for ARM templates Concat function 用于 ARM 模板

Format function for ARM templates ARM 模板的格式 function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM