title: How to deploy Logic App with o365 Connector within ARM template
body: <p>Im trying to deploy an ARM template with a logic app and an (unauthenticated) o365 connection. This is my template: </p>
  
  <pre><code>{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "location": {
        "type": "string",
        "defaultValue": "[resourceGroup().location]",
        "metadata": {
          "description": "Location for all resources."
        }
      }
    },
    "variables": {
      "LogicAppName": "MyLogicApp"
    },
    "resources": [
      {
        "type": "Microsoft.Logic/workflows",
        "apiVersion": "2017-07-01",
        "name": "[variables('LogicAppName')]",
        "location": "[parameters('location')]",
        "identity": {
          "type": "SystemAssigned"
        },
        "properties": {
          "state": "Enabled",
          "definition": {
            "parameters": {
              "$connections": {
                "defaultValue": {
                },
                "type": "Object"
              }
            },
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "contentVersion": "1.0.0.0",
            "triggers": {
              "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                  "schema": {
                    "properties": {
                    },
                    "type": "object"
                  }
                }
              }
            },
            "actions": {
              "Send_an_email_(V2)": {
                "type": "ApiConnection",
                "inputs": {
                  "inputs": {
                    "host": {
                      "connection": {
                        "name": "@parameters('$connections')['office365']['connectionId']"
                      }
                    },
                    "body": {
                      "Body": "&lt;p&gt;@{triggerBody()?['message']}&lt;/p&gt;",
                      "Subject": "@triggerBody()?['subject']",
                      "To": "@triggerBody()?['to']"
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                  }
                }
              }
  
            },
            "outputs": {
            }
          },
          "parameters": {
            "$connections": {
              "value": {
                "office365": {
                  "connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]",
                  "connectionName": "office365",
                  "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
                }
              }
            }
          }
        },
        "dependsOn": [
          "[resourceId('Microsoft.Web/connections', 'office365')]"
        ]
      },
      {
        "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": {
          }
        }
      }
    ],
    "outputs": {
  
    }
  }
  </code></pre>
  
  <p>When executing i.e. running <code>az deployment group create --resource-group my-rgroup --template-file .\arm-template.json</code></p>
  
  <p>The workflow and api connection are created. In the <strong>Logic app code view</strong> (left panel) the logic app and connection properties look fine:
  <a href="https://i.stack.imgur.com/PAeyM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PAeyM.png" alt="enter image description here"></a></p>
  
  <p>However when I open the <strong>designer</strong> the step using the connection gives me an "Connector not found" error:
  <a href="https://i.stack.imgur.com/u8vIW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u8vIW.png" alt="enter image description here"></a></p>
  
  <p>And when I click "view code" (in the designer view) the parameters section looks like this:</p>
  
  <pre><code>    "parameters": {
          "$connections": {
              "value": {
                  "DCA9B054-C46B-4419-B0E9-FC142A864810": {
                      "connectionId": "",
                      "connectionName": "",
                      "id": ""
                  }
              }
          }
      }
  </code></pre>
  
  <p>I used following resources to build the arm template:</p>
  
  <ul>
  <li><p><a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/6a17c729-ea15-4309-bd34-aa07d0a818bc/arm-template-for-0365-connector-with-username-and-password?forum=azurelogicapps" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/6a17c729-ea15-4309-bd34-aa07d0a818bc/arm-template-for-0365-connector-with-username-and-password?forum=azurelogicapps</a></p></li>
  <li><p><a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/6a17c729-ea15-4309-bd34-aa07d0a818bc/arm-template-for-0365-connector-with-username-and-password?forum=azurelogicapps" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/6a17c729-ea15-4309-bd34-aa07d0a818bc/arm-template-for-0365-connector-with-username-and-password?forum=azurelogicapps</a></p></li>
  </ul>
  
  <h1>Solution</h1>
  
  <p>The problem was a wrong syntax inside the logic app. Following is a working solution. I also removed the parameterValues section of the o365 connection. In this way the arm template can be deployed repeatedly and authenticate the connection once with a user account.</p>
  
  <pre><code>{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "location": {
        "type": "string",
        "defaultValue": "[resourceGroup().location]",
        "metadata": {
          "description": "Location for all resources."
        }
      }
    },
    "variables": {
      "LogicAppName": "MyLogicApp"
    },
    "resources": [
      {
        "type": "Microsoft.Logic/workflows",
        "apiVersion": "2017-07-01",
        "name": "[variables('LogicAppName')]",
        "location": "[parameters('location')]",
        "identity": {
          "type": "SystemAssigned"
        },
        "properties": {
          "state": "Enabled",
          "definition": {
            "parameters": {
              "$connections": {
                "defaultValue": {
                },
                "type": "Object"
              }
            },
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "contentVersion": "1.1.0.0",
            "triggers": {
              "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                  "schema": {
                    "properties": {
                    },
                    "type": "object"
                  }
                }
              }
            },
            "actions": {
              "Send_an_email_(V2)": {
                "type": "ApiConnection",
                  "inputs": {
                    "host": {
                      "connection": {
                        "name": "@parameters('$connections')['office365']['connectionId']"
                      }
                    },
                    "body": {
                      "Body": "&lt;p&gt;hello world&lt;/p&gt;",
                      "Subject": "test",
                      "To": "example@email.com"
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                  }
              }
  
            },
            "outputs": {
            }
          },
          "parameters": {
            "$connections": {
              "value": {
                "office365": {
                  "connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]",
                  "connectionName": "office365",
                  "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
                }
              }
            }
          }
        },
        "dependsOn": [
          "[resourceId('Microsoft.Web/connections', 'office365')]"
        ]
      },
      {
        "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"
        }
      }
    ],
    "outputs": {
  
    }
  }
  </code></pre>