【问题标题】:Unable to pass secure values between linked ARM templates无法在链接的 ARM 模板之间传递安全值
【发布时间】:2018-04-16 10:52:13
【问题描述】:

我正在尝试输出在一个链接模板中创建的秘密并将其作为参数引用到另一个模板中。 测试场景:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "templateBaseUrl": {
      "type": "string"
    }
  },
  "variables": {
    "deployment1url": "[concat(parameters('templateBaseUrl'), '/deployment1.json')]",
    "deployment2url": "[concat(parameters('templateBaseUrl'), '/deployment2.json')]"
  },
  "resources": [
    {
      "apiVersion": "2017-08-01",
      "name": "deployment1",
      "dependsOn": [],
      "type": "Microsoft.Resources/deployments",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[variables('deployment1url')]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {}
      }
    },
    {
      "apiVersion": "2017-08-01",
      "name": "deployment2",
      "dependsOn": [],
      "type": "Microsoft.Resources/deployments",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[variables('deployment2url')]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "testInput2": {
            "value": "[reference('deployment1').outputs.testOutput1.value]"
          }
        }
      }
    }
  ],
  "outputs": {}
}

部署1:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    },
    "resources": [],
    "outputs": {
        "testOutput1": {
            "type": "securestring",
            "value": "thisisapassword"
        }
    }
}

部署2:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "testInput2": {
            "type": "securestring"
        }
    },
    "resources": [],
    "outputs": {}
}

运行此场景会引发错误 “无法处理资源的模板语言表达式 '/subscriptions//resourceGroups/testrg1/providers/Microsoft.Resources/deployments/deployment2' 在第 34 行和第 9 列。 '语言表达式属性'value'不存在,可用属性是'type'。'"

如果我将引用参数更改为

,则安全字符串输出上的“.value”不起作用
"testInput2": {
                "value": "[reference('deployment1').outputs.testOutput1]"
              }

错误更改为“部署模板验证失败:'在'5'行和'23'列为模板参数'testInput2'提供的值无效。'。'。”

有没有可能实现我正在做的事情?

提前致谢

【问题讨论】:

    标签: azure azure-resource-manager arm-template azure-template


    【解决方案1】:

    我认为跨部署传递secureStrings 的唯一方法是使用KeyVault 引用。 secureString 输出不是很有用,因为安全字符串在部署级别被 ARM 屏蔽。

    有帮助吗?

    【讨论】:

      猜你喜欢
      • 2016-06-16
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 2012-03-08
      • 1970-01-01
      • 2020-03-13
      • 1970-01-01
      相关资源
      最近更新 更多