Azure ARM。嵌套部署无法部署内容

问题描述 投票:0回答:1

自从我尝试为 Azure 逻辑应用实现和部署 IaC 模板以来,已经有几个月了。 我尝试部署的剧本基于自定义连接器,我想使用嵌套部署将其与剧本本身一起部署。

{
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2021-04-01",
      "name": "custom_connector_template_link",
      "dependsOn": [],
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "relativePath": "custom_connector/template.json"
        }
      }
    }

这段简短的代码应该可以完成工作,但不幸的是它没有。事实上,当通过 Azure DevOps 开始部署时,它显示以下内容:

[警告] 跳过 D:\s\UAT\Playbook\get_geo_from_ip zuredeploy.json 的部署。该文件包含未选择部署的内容的资源。如果您希望部署此文件,请在连接中添加内容类型。

有人可能认为嵌套模板是根本原因,但这并不是因为我将其部署为独立组件。

如果您需要更多信息,请告知。 我将非常高兴收到您的帮助。

azure azure-resource-manager
1个回答
0
投票

确保自定义连接的内容类型存在于主模板的部署范围或模板参数中,以解决问题。

为了修复此警告,请参阅逻辑应用程序的ARM 模板的连接资源定义,并确保包含自定义连接器的 template.json 格式正确。

在主部署文件中,azdeploy.json 添加自定义连接器的参数,如下所示:-

"parameters": {
  "customConnectorContentType": {
    "type": "string",
    "defaultValue": "application/vnd.microsoft.appconnect.connectordefinition+json",
    "metadata": {
      "description": "Content type for the custom connector."
    }
  }
}

在嵌套模板中,传递内容类型参数,如下所示:-

{
  "type": "Microsoft.Resources/deployments",
  "apiVersion": "2021-04-01",
  "name": "custom_connector_template_link",
  "dependsOn": [],
  "properties": {
    "mode": "Incremental",
    "templateLink": {
      "relativePath": "custom_connector/template.json"
    },
    "parameters": {
      "contentVersion": {
        "value": "[parameters('customConnectorContentType')]"
      }
    }
  }
}

您可以尝试的另一个示例如下:-

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Logic App to create."
            }
        },
        "customConnectorTemplateUrl": {
            "type": "string",
            "metadata": {
                "description": "The URL of the ARM template for the custom connector."
            }
        }
    },
    "variables": {
        "customConnectorDeploymentName": "[concat('customConnectorDeployment-', uniqueString(resourceGroup().id))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "triggers": {
                        "Recurrence": {
                            "type": "Recurrence",
                            "recurrence": {
                                "frequency": "Hour",
                                "interval": 1
                            }
                        }
                    },
                    "actions": {
                        "CustomConnectorDeployment": {
                            "type": "Microsoft.Resources/deployments",
                            "apiVersion": "2021-04-01",
                            "name": "[variables('customConnectorDeploymentName')]",
                            "properties": {
                                "mode": "Incremental",
                                "templateLink": {
                                    "uri": "[parameters('customConnectorTemplateUrl')]"
                                }
                            }
                        }
                    },
                    "outputs": {}
                },
                "parameters": {}
            }
        }
    ]
}

我的Azure yaml管道脚本:-

steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'ARM Template deployment: Resource Group scope'
  inputs:
    azureResourceManagerConnection: 'SID subscription(xxxx4xxxe97cb2a7)'
    subscriptionId: 'xxxxxdxxxe2b6e97cb2a7'
    resourceGroupName: siliconrg32
    location: 'Australia East'
    csmFile: '$(System.DefaultWorkingDirectory)/_azurelogicapps/azdeploy.json'
© www.soinside.com 2019 - 2024. All rights reserved.