azure - 内联对象作为链接模板部署的参数值

标签 azure azure-resource-manager azure-rm-template

我希望能够将内联对象作为参数值传递给链接模板。用例是我有一个部署服务总线(或其他一些资源)的模板和一个部署 Web 应用程序的模板。我想构建一个结合这两个组件的模板。我希望 Web 应用模板有一个名为 userProvidedAppSettings 的对象参数,我可以将其与一些默认值联合,然后将该结果对象分配为 Microsoft.Web/site/config/appsettings 的属性值资源。

目前您似乎无法在参数的内联对象值中使用引用或 listkeys 函数,请参阅下面示例中的 userProvidedAppSettings

这可能吗?我没有使用正确的约定?我在文档中没有看到任何与此相关的内容。

{
    "apiVersion": "[parameters('apiVersion')]",
    "name": "[variables('serviceBusDeploymentName')]",
    "type": "Microsoft.Resources/deployments",
    "properties": {
        "mode": "Incremental",
        "templateLink": {
            "uri": "[parameters('templateOneUri')]",
            "contentVersion": "1.0.0.0"
         },
         "parameters": {
             "environment": { "value": "[parameters('environment')]" },
             "appName": { "value": "[parameters('appName')]" }
          }
     }
},
{
        "apiVersion": "[parameters('apiVersion')]",
        "name": "[variables('applicationDeploymentName')]",
        "type": "Microsoft.Resources/deployments",
        "properties": {
            "mode": "Incremental",
            "templateLink": {
                "uri": "[parameters('templateTwoUri')]",
                "contentVersion": "1.0.0.0"
             },
             "parameters": {
                 "environment": { "value": "[parameters('environment')]" },
                 "appName": { "value": "[parameters('appName')]" },
                 "userProvidedAppSettings" : { "value": { "serviceBusConnectionString": "[reference(variables('serviceBusDeploymentName')).outputs.connectionString.value]" } }
              }
         }
    }

编辑:

澄清一下,这是关于链接模板参数值的行为。我特别想问的是:

"parameters": {
    // Allowed:
    "param1": { "value": "[parameters('environment')]" },
    "param2": { "value": "[reference('otherDeployment').outputs.something.value]" },
    "param3": { "value": { "this": "is allowed",
                           "inline": "is allowed" } },
    // NOT Allowed
    "param4": { "value": { "this": "is NOT allowed".
                           "foo": "[reference('otherDeployment').outputs.something.value]" } }
}

reference 输出允许作为值,内联对象也允许作为值,但内联对象的值包含 reference (或来自 list 的隐式引用)代码 > 函数)是不允许的。我想知道这是否可以通过不同的约定实现,或者是否应该将其添加到所需功能列表中。

最佳答案

对于您的问题,不确定,但您可以尝试一下 links and nested templates 。您可以在主模板中获取链接模板的值。

您可以在链接模板输出中定义变量并在主模板中使用它。有一个简单的例子here 。希望这对您有帮助!

关于azure - 内联对象作为链接模板部署的参数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52726181/

相关文章:

anaconda 上的 Python 找不到 azure.mgmt.datafactory

azure - 是否可以使用 NancyFX 启用 CORS?

azure - 如何与其他 azure 用户共享对 azure 门户中的应用程序见解数据的访问权限

python - 如何修复 'BlobService' 未定义'错误

azure ARM "code": "InUseSubnetCannotBeDeleted" when trying to update vnet

azure - 使用 terraform 和 arm 模板通过工作流程部署逻辑应用程序的最佳方法?

python-2.7 - 根据类型或类别列出 Microsoft Azure 计算中的 VM 大小

python - 分页异步迭代器协议(protocol)不可用(适用于 Python 的 Azure SDK)

azure - ARM 模板部署不会删除旧管道

azure - 模板部署后输出 Azure SQL 数据库连接字符串