本文介绍了获取 ARM 中逻辑应用的回调 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在部署一个 ARM 模板,其中包括:天蓝色函数 + 逻辑应用.

以下

在我的天蓝色应用程序功能中,我需要将此值设置为应用程序设置.

现在,我的 ARM 看起来(越来越少)这样:

{"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0",参数": {//(...)},变量":{//(...)},资源": [{"type": "Microsoft.Storage/storageAccounts",//(...)},{"type": "Microsoft.Web/serverfarms",//(...)},{"apiVersion": "2015-08-01","type": "Microsoft.Web/sites",名称":[变量('functionAppName')]","位置": "[resourceGroup().location]",种类":功能应用程序",依赖于取决于": ["[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",[resourceId('Microsoft.Storage/storageAccounts',变量('storageAccountName'))]"],资源": [{"apiVersion": "2015-08-01",名称":网络",类型":源代码控制",依赖于取决于": [[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"],特性": {"RepoUrl": "[参数('repoURL')]",分支":[变量('分支')]",IsManualIntegration":真}}],特性": {"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",站点配置":{应用程序设置":[{"name": "AzureWebJobsDashboard","value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').键1)]"},//接下来我的应用设置]}}},{名称":[变量('logicAppName')]","type": "Microsoft.Logic/workflows","位置": "[resourceGroup().location]","apiVersion": "2016-06-01",依赖于取决于": ["[resourceId('Microsoft.Web/connections', variables('servicebusConnectionName'))]",[resourceId('Microsoft.Web/sites/sourcecontrols',变量('functionAppName'),'web')]"],标签":{"displayName": "订单创建"},特性": {定义": {"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",行动":{//(...)},参数": {$连接":{默认值": {},类型":对象"}},触发器":{手动的": {类型":请求","种类": "Http",输入":{模式":{}}}},"contentVersion": "1.0.0.0",输出":{}},参数": {$连接":{价值": {服务总线":{"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'servicebus')]","connectionId": "[resourceId('Microsoft.Web/connections', variables('servicebusConnectionName'))]",connectionName":[变量('servicebusConnectionName')]"}}}}}},{"type": "MICROSOFT.WEB/CONNECTIONS","apiVersion": "2016-06-01",名称":[变量('servicebusConnectionName')]","位置": "[resourceGroup().location]",特性": {API":{"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'servicebus')]"},"displayName": "[参数('servicebus_1_Connection_DisplayName')]",参数值":{connectionString":[参数('servicebus_1_connectionString')]"}}}],输出":{}}

我的问题是:

  1. 是否可以在部署期间强制执行逻辑应用callbackUrl"?
  2. 是否可以在部署逻辑应用并在 Azure Functions 中设置应用设置"后获取逻辑应用"回调 URL?
  3. 如果不需要,我是否需要编写一个 powershell 脚本来处理它?
  4. 如何从资源管理器中访问该值?

我在路径中看到accessEndpoint":https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{logicAppName}?api-version=2016-06-01

但是一旦我在我的应用设置中使用了这个值,我就会拒绝访问.

来自逻辑应用站点的回调 URL 看起来很熟悉:https://{server}.logic.azure.com:443/workflows/{workflow}/runs/{someid}/contents/TriggerInputs?api-version=2016-06-01&se=2017-10-30T13%3A34%3A27.3219438Z&sp=%2Fruns%2someid2%2Fcontents%2FTriggerInputs%2Fread&sv=1.0&sig={someid3}

解决方案

既然你问的是如何在 ARM 中做到这一点,这里是假设 LA 有一个名为 ma​​nual 的触发器的解决方案:

listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows', 'logic-app-name', 'manual'), '2016-06-01').value

如果要将逻辑应用和函数应用部署到同一资源组,则可以排除资源组名称.

您可以通过以下方式将回调 URL 添加到您的函数设置中:

{"type": "Microsoft.Web/sites",种类":功能应用程序",名称":[变量('function_app_name')]","apiVersion": "2016-08-01","位置": "[resourceGroup().location]",身份":{类型":系统分配"},特性": {"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('function_hosting_plan_name'))]",站点配置":{永远在线":是的,应用程序设置":[{"name": "Logic_App_Url","值": "[listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows/triggers', 'logic-app-name', 'manual'), '2016-06-01').价值]"}]},资源": [{"apiVersion": "2015-08-01",名称":应用程序设置",类型":配置",依赖于取决于": ["[resourceId('Microsoft.Storage/storageAccounts', variables('storage_account_name'))]",[resourceId('Microsoft.Web/Sites',变量('function_app_name'))]"],特性": {"Logic_App_Url": "[listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows/triggers', 'logic-app-name', 'manual'), '2016-06-01').价值]"}}]}}

I'm deploying an ARM template, which includes:azure functions + logic apps.

Following link i've created a simple flow:one of method from azure functions calls logic app. Let's name the method as "A". The logic app as "B":

A calls B.

The logic app (B) contains "callback URL". Method (A) needs to have a callback url to the logic app (B). I need to set up this variable by "copy" this value:

And in my azure app function I need to set this value as application setting.

Right now, my ARM looks (more and less) like that:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    //(...)
  },
  "variables": {
    //(...)
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      //(...)
    },
    {
      "type": "Microsoft.Web/serverfarms",
      //(...)
    },
    {
      "apiVersion": "2015-08-01",
      "type": "Microsoft.Web/sites",
      "name": "[variables('functionAppName')]",
      "location": "[resourceGroup().location]",
      "kind": "functionapp",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
        "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
      ],
      "resources": [
        {
          "apiVersion": "2015-08-01",
          "name": "web",
          "type": "sourcecontrols",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
          ],
          "properties": {
            "RepoUrl": "[parameters('repoURL')]",
            "branch": "[variables('branch')]",
            "IsManualIntegration": true
          }
        }
      ],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
        "siteConfig": {
          "appSettings": [
            {
              "name": "AzureWebJobsDashboard",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            //next my app settings
          ]
        }
      }
    },
    {
      "name": "[variables('logicAppName')]",
      "type": "Microsoft.Logic/workflows",
      "location": "[resourceGroup().location]",
      "apiVersion": "2016-06-01",
      "dependsOn": [
        "[resourceId('Microsoft.Web/connections', variables('servicebusConnectionName'))]",
        "[resourceId('Microsoft.Web/sites/sourcecontrols', variables('functionAppName'), 'web')]"
      ],
      "tags": {
        "displayName": "order-create"
      },
      "properties": {
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
          "actions": {
            //(...)
          },
          "parameters": {
            "$connections": {
              "defaultValue": {},
              "type": "Object"
            }
          },
          "triggers": {
            "manual": {
              "type": "Request",
              "kind": "Http",
              "inputs": {
                "schema": {}
              }
            }
          },
          "contentVersion": "1.0.0.0",
          "outputs": {}
        },
        "parameters": {
          "$connections": {
            "value": {
              "servicebus": {
                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'servicebus')]",
                "connectionId": "[resourceId('Microsoft.Web/connections', variables('servicebusConnectionName'))]",
                "connectionName": "[variables('servicebusConnectionName')]"
              }
            }
          }
        }
      }
    },
    {
      "type": "MICROSOFT.WEB/CONNECTIONS",
      "apiVersion": "2016-06-01",
      "name": "[variables('servicebusConnectionName')]",
      "location": "[resourceGroup().location]",
      "properties": {
        "api": {
          "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'servicebus')]"
        },
        "displayName": "[parameters('servicebus_1_Connection_DisplayName')]",
        "parameterValues": {
          "connectionString": "[parameters('servicebus_1_connectionString')]"
        }
      }
    }
  ],
  "outputs": {}
}

My questions are:

  1. It's possible to enforce logic app "callbackUrl" during deployment?
  2. It's possible to get the 'logic app' callback URL after deploying the logic app and set the "app settings" in azure functions?
  3. If not - do I need to write a powershell script to work on that?
  4. How can I access this value from resources manager?

I see "accessEndpoint" in path:https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{logicAppName}?api-version=2016-06-01

but once i use this value in my app settings i have access denied.

Callback URL from logic app site looks familiar to:https://{server}.logic.azure.com:443/workflows/{workflow}/runs/{someid}/contents/TriggerInputs?api-version=2016-06-01&se=2017-10-30T13%3A34%3A27.3219438Z&sp=%2Fruns%2someid2%2Fcontents%2FTriggerInputs%2Fread&sv=1.0&sig={someid3}

解决方案

Since you were asking about how to do it in ARM, here is the solution which assumes the LA has a trigger named manual:

listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows', 'logic-app-name', 'manual'), '2016-06-01').value

If you're deploying the logic app and function app to the same resource group you can exclude the resource group name.

Here is how you might add the callback Url to your function settings:

{
  "type": "Microsoft.Web/sites",
  "kind": "functionapp",
  "name": "[variables('function_app_name')]",
  "apiVersion": "2016-08-01",
  "location": "[resourceGroup().location]",
  "identity": { "type": "SystemAssigned" },
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('function_hosting_plan_name'))]",
    "siteConfig":
    {
      "alwaysOn": true,
      "appSettings": [
        {
          "name": "Logic_App_Url",
          "value": "[listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows/triggers', 'logic-app-name', 'manual'), '2016-06-01').value]"
        }
      ]
    },
    "resources": [
      {
        "apiVersion": "2015-08-01",
        "name": "appsettings",
        "type": "config",
        "dependsOn": [
          "[resourceId('Microsoft.Storage/storageAccounts', variables('storage_account_name'))]",
          "[resourceId('Microsoft.Web/Sites', variables('function_app_name'))]"
        ],
        "properties": {
          "Logic_App_Url": "[listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows/triggers', 'logic-app-name', 'manual'), '2016-06-01').value]"
        }
      }
    ]
  }
}

这篇关于获取 ARM 中逻辑应用的回调 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:08