Azure 逻辑应用的字符串连接问题 [英] String concatenation issue with Azure Logic Apps

查看:21
本文介绍了Azure 逻辑应用的字符串连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 ARM 模板,用于部署一个 Web 应用(一个 Mvc Api)和一个逻辑应用.

I'm creating an ARM template that deploys an Web App (an Mvc Api) and a Logic App.

我正在尝试在逻辑应用程序中定义一个 HTTP 操作,以便它使用 splitOn@ 动态连接 Api 的基本 Uri 以及当前项的属性triggerBody().基本 Uri 本身从 ARM 模板中的一组参数连接到一个变量 variables('hockeyAppAPISettings').Uri.

I'm attempting to define an HTTP Action within the Logic App such that it dynamically concatenates the base Uri of the Api as well as a property of the current item using splitOn and @triggerBody(). The base Uri itself is concatenated from a set of parameters in the ARM template into a variable variables('hockeyAppAPISettings').Uri.

这是动作定义的相关片段:

Here's the relevant snipped of the action definition:

"actionName": {
  "conditions": [ ],
  "inputs": {
    "authentication": {
      "audience": "[variables('apiSettings').Authentication.Audience]",
      "clientId": "[variables('apiSettings').Authentication.ClientId]",
      "secret": "[variables('apiSettings').Authentication.Secret]",
      "tenant": "[variables('apiSettings').Authentication.Tenant]",
      "type": "ActiveDirectoryOAuth"
    },
    "method": "patch",
    "uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody()['Id']}/ScanningInProgress')]"
    //"uri": "[concat(variables('apiSettings').Uri, '//@{triggerBody()[/'Id/']}//ScanningInProgress')]"
    //"uri": "[concat(variables('apiSettings').Uri, '//@@{triggerBody()[/'Id/']}//ScanningInProgress')]"
  },
  "type": "Http"
},

"uri" 部分是我正在努力解决的问题.我在整个过程中以不同的模式散布了各种转义字符(\@).

The "uri" section is what i'm struggling with. I've sprinkled various escape characters (\ and @) in differing patterns through out this.

我要么无法通过部署错误使部署成功,例如:

I either can't get the deployment to succeed w/deployment errors like:

无法解析模板语言表达式'concat(variables('apiSettings').Uri,'//@{triggerBody()[/'Id/']}//ScanningInProgress')':预期令牌'RightParenthesis' 和实际的 '标识符'.请参见http://aka.ms/arm-template-expressions 了解使用详情..'.

Unable to parse template language expression 'concat(variables('apiSettings').Uri, '//@{triggerBody()[/'Id/']}//ScanningInProgress')': expected token 'RightParenthesis' and actual 'Identifier'. Please see http://aka.ms/arm-template-expressions for usage details..'.

或者,如果我使部署正常工作,然后在部署后查看门户中的代码,则字符串连接似乎无法正常工作.变量不会转换为其值.

Or if I get the deployment working and then look at the code in the portal after deployment, the string concatenation doesn't seem to work properly. The variable doesn't get converted to its value.

我已经验证,如果我使用以下内容直接(通过门户 HTML 编辑器)编辑 Uri: "uri" : "https://edited.azurewebsites.net/api/Packages/@{triggerBody()['Id']}/ScanningInProgress" 逻辑应用将对来自 HTTP 触发器的每个项目进行补丁调用.

I have validated that if I edit the Uri directly (via the portal HTML editor) using this: "uri" : "https://edited.azurewebsites.net/api/Packages/@{triggerBody()['Id']}/ScanningInProgress" the Logic App will make a patch call for each item that comes from the HTTP trigger.

我做错了什么?

推荐答案

需要转义内部单引号,即try

You need to escape the inner single quotes, i.e. try

"uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody()[''Id'']}/ScanningInProgress')]"

或者,您可以使用点符号来引用属性,即

Alternatively you can use the dot notation to reference the property, i.e.

"uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody().Id}/ScanningInProgress')]"

这篇关于Azure 逻辑应用的字符串连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆