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

zengzsys  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(103)

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

{
      "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:\a\1\s\UAT\Playbook\get_geo_from_ip\azuredeploy.json的部署。该文件包含未选择用于部署的内容的资源。如果要部署此文件,请将内容类型添加到连接。
有人可能会认为嵌套模板是根本原因,但这并不是因为我将其部署为独立组件。
如果你需要更多的信息,只是让知道。我真的很高兴得到你的帮助。

von4xj4u

von4xj4u1#

确保自定义连接的内容类型存在于主模板的部署范围或模板参数中,以解决问题。
要修复此警告,请参阅Logic应用程序的ARM模板的此连接资源定义,并确保包含自定义连接器的template.json格式正确。

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

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

字符串

  • 在嵌套模板中,传入content-type参数,如下所示:-*
{
  "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'

相关问题