使用连接器更新Azure ARM模板

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

我使用ARM模板部署一个通过office365连接器发送邮件的Logic App。它可以很好地部署它,但如果我更新模板并想要重新部署它,连接到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": "[email protected]"
                                                    },
                                                    "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": "[email protected]",
                                                                    "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"
                        }
                    }
                }
            }
        }
    ]
}
azure azure-active-directory azure-logic-apps azure-template
2个回答
1
投票

如果您通过模板重新部署逻辑应用程序,则应断开连接。我不认为你可以与模板一起授权连接。连接器由azure AD授权,ARM模板仅包含订阅的资源,但不包括azure AD层,azure广告高于订阅。

Here是微软回答的类似问题,你可以看看。

解析度:

根据观察结果,我与专家进行了讨论,似乎连接器目前只能进行Windows AD身份验证,因此也就是问题。产品组在待办事项中更新了此功能,并且将在未来几天内更新连接器,我们尚未对此进行ETA更新。

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


1
投票

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

实际上,它取决于您使用的api连接的类别,如果不是需要MFA授权的api连接(office365,outlook,keyvalut自定义连接器,动态CRM,salesforce),您可以将Api连接模板与您的逻辑应用模板。

© www.soinside.com 2019 - 2024. All rights reserved.