【问题标题】:How to pass multiple parameters into an Azure RM Template Custom Script Extension如何将多个参数传递到 Azure RM 模板自定义脚本扩展
【发布时间】:2021-08-24 14:34:58
【问题描述】:

我正在尝试使用 ARM 模板将多个参数传递给自定义脚本扩展,这里是 ARM 模板的 sn-p,目前可以正常工作:

{
            "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')]"
                    }
                }
            },

但是每当我向参数部分添加另一个参数时,模板验证都会失败。这是我试图做的:

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

有人可以帮忙吗?

【问题讨论】:

  • 你能提供失败时的实际错误吗?

标签: json azure powershell azure-resource-manager


【解决方案1】:

您能否尝试根据您使用的参数来连接或格式化参数,如下所示:

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

我提到的 Azure 文档:

ARM Deployment Scripts

Concat function for ARM templates

Format function for ARM templates

【讨论】:

  • 谢谢Ked,这正是我需要的。 Concat 运行良好,再次感谢您!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-10
  • 2021-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-09
相关资源
最近更新 更多