Как развернуть приложение Logi c с o365 Connector в шаблоне ARM - PullRequest
1 голос
/ 16 марта 2020

Я пытаюсь развернуть шаблон ARM с приложением logi c и (без аутентификации) подключением o365. Это мой шаблон:

{
  "$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": "<p>@{triggerBody()?['message']}</p>",
                    "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": {

  }
}

При выполнении, т.е. при запуске az deployment group create --resource-group my-rgroup --template-file .\arm-template.json

Рабочий процесс и соединение API созданы. В представлении Logi c кода приложения (левая панель) свойства приложения и соединения logi c выглядят отлично: enter image description here

Однако при открытии дизайнер шаг, использующий соединение, выдает ошибку «Соединитель не найден»: enter image description here

И когда я нажимаю «просмотреть код» (в конструкторе вид) раздел параметров выглядит следующим образом:

    "parameters": {
        "$connections": {
            "value": {
                "DCA9B054-C46B-4419-B0E9-FC142A864810": {
                    "connectionId": "",
                    "connectionName": "",
                    "id": ""
                }
            }
        }
    }

Я использовал следующие ресурсы для создания шаблона руки:

Решение

Проблема заключалась в неправильном синтаксисе внутри логики c приложение Ниже приводится рабочее решение. Я также удалил раздел parameterValues ​​соединения o365. Таким образом, шаблон руки может быть развернут повторно и аутентифицировать соединение один раз с учетной записью пользователя.

{
  "$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": "<p>hello world</p>",
                    "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": {

  }
}

1 Ответ

1 голос
/ 17 марта 2020

В вашем действии "Send_an_email_ (V2)" есть дополнительный inputs.

"Send_an_email_(V2)": {
  "type": "ApiConnection",
  "inputs": {
    "inputs": {
      "host": {
        "connection": {
          "name": "@parameters('$connections')['office365']['connectionId']"
        }
      },
      "body": {
        "Body": "<p>@{triggerBody()?['message']}</p>",
        "Subject": "@triggerBody()?['subject']",
        "To": "@triggerBody()?['to']"
      },
      "method": "post",
      "path": "/v2/Mail"
    }
  }
}

Вам нужно удалить один inputs из кода выше.

"Send_an_email_(V2)": {
  "type": "ApiConnection",
  "inputs": {
      "host": {
        "connection": {
          "name": "@parameters('$connections')['office365']['connectionId']"
        }
      },
      "body": {
        "Body": "<p>@{triggerBody()?['message']}</p>",
        "Subject": "@triggerBody()?['subject']",
        "To": "@triggerBody()?['to']"
      },
      "method": "post",
      "path": "/v2/Mail"
  }
}

После развертывания мы можем получить ожидаемый результат. enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...