使用存储帐户和Office 365连接器部署Logic Apps

问题描述

我正在尝试部署包含Office 365连接器和存储帐户的逻辑应用程序。 在部署之前将存储帐户和office365连接器包含在ARM模板中还是在资源组中创建连接器更好?在这种情况下,我发现Blob操作表示他们找不到该帐户。 如果将所有内容一起部署,则需要手动执行所有操作并在部署到新资源组时重置连接器。我不能指望运营团队能够做到这一点。 最佳做法是什么?

解决方法

对于这个问题,我们可以通过修改arm模板来解决blob问题,但是不能解决arm模板中的o365问题。

要在部署手臂模板后连接到Blob存储,可以参考我的逻辑和手臂模板并编辑手臂模板。我的逻辑应用程序如下所示: enter image description here

我的手臂模板显示如下:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0","parameters": {
    "logicAppName": {
      "type": "string","minLength": 1,"maxLength": 80,"metadata": {
        "description": "Name of the Logic App."
      }
    },"logicAppLocation": {
      "type": "string","defaultValue": "eastasia","allowedValues": [
        "[resourceGroup().location]","eastasia","southeastasia","centralus","eastus","eastus2","westus","northcentralus","southcentralus","northeurope","westeurope","japanwest","japaneast","brazilsouth","australiaeast","australiasoutheast","southindia","centralindia","westindia","canadacentral","canadaeast","uksouth","ukwest","westcentralus","westus2","koreacentral","koreasouth","francecentral","francesouth","uaecentral","southafricanorth","southafricawest"
      ],"metadata": {
        "description": "Location of the Logic App."
      }
    },"azureblob_1_Connection_Name": {
      "type": "string","defaultValue": "azureblob"
    },"azureblob_1_Connection_DisplayName": {
      "type": "string","defaultValue": "blobConnection"
    },"azureblob_1_accountName": {
      "type": "string","metadata": {
        "description": "Name of the storage account the connector should use."
      },"defaultValue": "hurystorage"
    },"azureblob_1_accessKey": {
      "type": "securestring","metadata": {
        "description": "Specify a valid primary/secondary storage account access key."
      }
    },"office365_1_Connection_Name": {
      "type": "string","defaultValue": "office365"
    },"office365_1_Connection_DisplayName": {
      "type": "string","defaultValue": "[email protected]"
    }
  },"variables": {},"resources": [
    {
      "name": "[parameters('logicAppName')]","type": "Microsoft.Logic/workflows","location": "[parameters('logicAppLocation')]","tags": {
        "displayName": "LogicApp"
      },"apiVersion": "2016-06-01","properties": {
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","actions": {
            "Get_blob_content": {
              "type": "ApiConnection","inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                  }
                },"method": "get","path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('JTJmdGVzdGNvbnRhaW5lciUyZmZpbGUxLmNzdg=='))}/content","queries": {
                  "inferContentType": true
                }
              },"runAfter": {},"metadata": {
                "JTJmdGVzdGNvbnRhaW5lciUyZmZpbGUxLmNzdg==": "/testcontainer/file1.csv"
              }
            },"Send_an_email_(V2)": {
              "type": "ApiConnection","inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['office365']['connectionId']"
                  }
                },"method": "post","body": {
                  "To": "[email protected]","Subject": "test","Body": "<p>test</p>"
                },"path": "/v2/Mail"
              },"runAfter": {
                "Get_blob_content": [
                  "Succeeded"
                ]
              }
            }
          },"parameters": {
            "$connections": {
              "defaultValue": {},"type": "Object"
            }
          },"triggers": {
            "Recurrence": {
              "type": "recurrence","recurrence": {
                "frequency": "Month","interval": 1
              }
            }
          },"outputs": {}
        },"parameters": {
          "$connections": {
            "value": {
              "azureblob": {
                "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/',parameters('logicAppLocation'),'/managedApis/','azureblob')]","connectionId": "[resourceId('Microsoft.Web/connections',parameters('azureblob_1_Connection_Name'))]","connectionName": "[parameters('azureblob_1_Connection_Name')]"
              },"office365": {
                "id": "[concat(subscription().id,'office365')]",parameters('office365_1_Connection_Name'))]","connectionName": "[parameters('office365_1_Connection_Name')]"
              }
            }
          }
        }
      },"dependsOn": [
        "[resourceId('Microsoft.Web/connections',"[resourceId('Microsoft.Web/connections',parameters('office365_1_Connection_Name'))]"
      ]
    },{
      "type": "MICROSOFT.WEB/CONNECTIONS","apiVersion": "2018-07-01-preview","name": "[parameters('azureblob_1_Connection_Name')]","properties": {
        "api": {
          "id": "[concat(subscription().id,'azureblob')]"
        },"displayName": "[parameters('azureblob_1_Connection_DisplayName')]","parameterValues": {
          "accountName": "[parameters('azureblob_1_accountName')]","accessKey": "[parameters('azureblob_1_accessKey')]"
        }
      }
    },"name": "[parameters('office365_1_Connection_Name')]",'office365')]"
        },"displayName": "[parameters('office365_1_Connection_DisplayName')]"
      }
    }
  ],"outputs": {}
}

请注意模板中屏幕截图的这一部分。

enter image description here

在我的手臂模板中,我只是将代码从上面的屏幕截图更改为:

"azureblob_1_accessKey": {
  "type": "securestring","metadata": {
    "description": "Specify a valid primary/secondary storage account access key."
  },"defaultValue": "<your storage access key>"
},

然后部署手臂模板,它将连接到您的Blob存储。

对于通过arm模板部署o365连接器的问题,没有很好的解决方案来实现。但是您可以参考此post,它提供了powershell的解决方案来对o365连接器进行身份验证。