使用连接器更新Azure ARM模板

使用连接器更新Azure ARM模板,azure,azure-active-directory,azure-logic-apps,azure-template,Azure,Azure Active Directory,Azure Logic Apps,Azure Template,我使用ARM模板部署一个逻辑应用程序,它通过office365连接器发送邮件。部署它可以正常工作,但是如果我更新模板并想重新部署它,office365的连接器将断开,我必须再次授权连接。 当我想更新logicapp时,有没有办法避免断开连接器 { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0

我使用ARM模板部署一个逻辑应用程序,它通过office365连接器发送邮件。部署它可以正常工作,但是如果我更新模板并想重新部署它,office365的连接器将断开,我必须再次授权连接。 当我想更新logicapp时,有没有办法避免断开连接器

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "env_suffix": {
            "defaultValue": null,
            "type": "String"
        }
    },
    "variables": {
        "workflow_name": "[concat('GoMail', parameters('env_suffix'))]"
    },
    "resources": [
        {
          "type": "Microsoft.Web/connections",
          "apiVersion": "2016-06-01",
          "location": "[resourceGroup().location]",
          "name": "office365",
          "properties": {
            "api": {
              "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
            },
            "displayName": "office365",
            "parameterValues": {
            }
          }
        },
        {
            "type": "Microsoft.Logic/workflows",
            "name": "[variables('workflow_name')]",
            "apiVersion": "2017-07-01",
            "location": "westeurope",
            "dependsOn": [
                "[resourceId('Microsoft.Web/connections', 'office365')]"
            ],
            "tags": {},
            "scale": null,
            "properties": {
                "state": "Enabled",
                "parameters": {
                    "$connections": {
                        "value": {
                            "office365": {
                                "connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]",
                                "connectionName": "office365",
                                "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/westeurope/managedApis/office365')]"
                            }
                        }
                    }
                },
                "definition": {         
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "actions": {
                        "Condition": {
                            "actions": {},
                            "else": {
                                "actions": {
                                    "Condition_2": {
                                        "actions": {
                                            "Send_an_email_2": {
                                                "inputs": {
                                                    "body": {
                                                        "Body": "@{base64ToString(triggerBody()?['payload'])}",
                                                        "From": "@triggerBody()?['from']",
                                                        "Importance": "Normal",
                                                        "IsHtml": true,
                                                        "Subject": "@triggerBody()?['subject']",
                                                        "To": "mailme@company.com"
                                                    },
                                                    "host": {
                                                        "connection": {
                                                            "name": "@parameters('$connections')['office365']['connectionId']"
                                                        }
                                                    },
                                                    "method": "post",
                                                    "path": "/Mail"
                                                },
                                                "runAfter": {},
                                                "type": "ApiConnection"
                                            }
                                        },
                                        "else": {
                                            "actions": {
                                                "Until": {
                                                    "actions": {
                                                        "Delay": {
                                                            "inputs": {
                                                                "interval": {
                                                                    "count": 10,
                                                                    "unit": "Second"
                                                                }
                                                            },
                                                            "runAfter": {
                                                                "Send_an_email_3": [
                                                                    "Failed"
                                                                ]
                                                            },
                                                            "type": "Wait"
                                                        },
                                                        "Send_an_email_3": {
                                                            "inputs": {
                                                                "body": {
                                                                    "Body": "@{base64ToString(triggerBody()?['payload'])}",
                                                                    "From": "noreply@company.com",
                                                                    "Importance": "Normal",
                                                                    "IsHtml": true,
                                                                    "Subject": "@triggerBody()?['subject']",
                                                                    "To": "@triggerBody()?['email']"
                                                                },
                                                                "host": {
                                                                    "connection": {
                                                                        "name": "@parameters('$connections')['office365']['connectionId']"
                                                                    }
                                                                },
                                                                "method": "post",
                                                                "path": "/Mail"
                                                            },
                                                            "runAfter": {},
                                                            "type": "ApiConnection"
                                                        }
                                                    },
                                                    "expression": "@equals(outputs('Send_an_email_3')['statusCode'], 200)",
                                                    "limit": {
                                                        "count": 5,
                                                        "timeout": "PT5M"
                                                    },
                                                    "runAfter": {},
                                                    "type": "Until"
                                                }
                                            }
                                        },
                                        "expression": "@endswith(triggerBody()?['email'], 'integtest.com')",
                                        "runAfter": {},
                                        "type": "If"
                                    }
                                }
                            },
                            "expression": "@equals(triggerBody()?['email'], 'ping')",
                            "runAfter": {},
                            "type": "If"
                        }
                    },
                    "contentVersion": "1.0.0.0",
                    "outputs": {},
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        }
                    },
                    "triggers": {
                        "manual": {
                            "inputs": {
                                "schema": {
                                    "properties": {
                                        "email": {
                                            "type": "string"
                                        },
                                        "payload": {
                                            "type": "string"
                                        },
                                        "subject": {
                                            "type": "string"
                                        }
                                    },
                                    "type": "object"
                                }
                            },
                            "kind": "Http",
                            "type": "Request"
                        }
                    }
                }
            }
        }
    ]
}

如果通过模板重新部署logic应用程序,则应断开连接。我不认为你可以授权与模板的连接。连接器由azure AD授权,ARM模板仅包括订阅的资源,但不包括azure AD层,azure AD位于订阅之上

微软也回答了类似的问题,你可以看看

决议:

根据观察结果,我与专家进行了讨论,看来连接器目前只能进行windows AD身份验证,因此出现了问题。产品组在待办事项中有此功能更新,并将在未来几天内更新连接器,我们还没有关于此功能的ETA


它说该功能将在未来几天内更新,如果该功能支持powershell,我认为它可能会支持ARM模板,因为这两种方法本质上应该调用相同的rest api。

您可以将office365 api连接模板与logic apps模板分开,您只需部署并授权一次Api连接,在您的逻辑应用程序中,您只需使用授权的Api连接


事实上,这取决于您使用的api连接类别,如果不是需要MFA授权的api连接类型(office365、outlook、keyvault自定义连接器、Dynamics CRM、salesforce),您可以将api连接模板与逻辑应用模板放在一起。

谢谢您的回答。您知道在重新部署logic应用程序时,是否存在只将连接保持在当前状态的问题?是否可能将连接器放在单独的模板中?@user3107823不确定,但目前我们可能无法单独创建连接器。