azure - 如何在Azure蓝图中正确使用 `outputs`?

标签 azure azure-cloud-services

我对蓝图输出的工作原理以及如何正确地将值从一个工件导入到另一个工件存在误解。

让我描述一下我从工件中获取变量的尝试:

我在资源组内创建了两个工件:

enter image description here

我尝试使用以下语法将 vnet_name、vnet_addresses 等变量从 VNET 工件传输到 SUBNET_AKS 工件:

互联网络:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
........
  "outputs": {
    "vnet_name_output": {
      "type": "string",
      "value": "[variables('vnet_name')]"
    },
    "vnet_ip_range_output": {
      "type": "string",
      "value": "[parameters('vnet_ip_range')]"
    },
    "vnet_path_output": {
      "type": "string",
      "value": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnet_name'))]"
    }
  }
}

下一步是将输出变量添加到 SUBNET_AKS 工件:

 "resources": [
    {
      "apiVersion": "2018-04-01",
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "name": "[concat(artifacts('VNET').outputs.vnet_name_output, '/', concat(parameters('deployment_prefix'),'-aks-subnet'))]",

但出现以下错误:

Deployment template validation failed: 'The template resource '[concat(artifacts('VNET').outputs.vnet_name_output, '/', concat(parameters('deployment_prefix'),'-aks-subnet'))]' at line '27' and column '9' is not valid: The template function 'artifacts' is not valid. Please see https://aka.ms/arm-template-expressions for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.

如何了解输出参数应如何在 Azure 蓝图定义中正常工作?

最佳答案

Azure Blueprint 只是一个编排层,负责工件的排序和部署。 ARM 模板是 three valid types 之一-policyAssignment 和roleAssignment 是另外两个。

这意味着您有两个"template"工件:VNET 和 SUBNET_AKS。每个模板都应被视为参与者/黑匣子,这意味着您只能使用 ARM 模板可用的函数。如果您需要蓝图中的参数,则必须将其作为参数传入。

这就是您收到特定语法错误的原因。 artifacts() function is only available to Blueprints

相反,您需要更新 ARM 模板,以便它指定命名输出值。在 Azure 蓝图中,您可以引用先前工件的输出作为后续蓝图工件的输入参数。

希望these code snippets and docs可以为您指明正确的方向。

关于azure - 如何在Azure蓝图中正确使用 `outputs`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59029918/

相关文章:

c# - Azure 文档数据库更新文档

azure - 为 Web/辅助角色配置内部负载均衡器

Azure 云辅助角色没有获得足够的 CPU 使用率

azure - Az Powershell 命令不适用于 "Cloud service (classic)"

c# - 无法从 Azure 应用程序配置服务读取设置

Azure 防火墙 : Most common Azure Firewall Policy Rule Collection Rules

azure - 在Azure databricks中,将pyspark数据帧写入eventhub花费的时间太长,因为数据帧中有300万条记录

azure - 无法使用 Azure CLI 清除 Azure CDN 端点

Azure 使用成本 - 困惑

azure - 没有 Web 角色的云服务