Azure Logic Apps的字符串串联问题 [英] String concatenation issue with Azure Logic Apps

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

问题描述

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

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

我正在尝试在Logic App中定义HTTP动作,以便它使用splitOn@triggerBody()动态连接Api的基本Uri以及当前项目的属性.基本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')':预期令牌 正确的括号"和实际的标识符".请参阅 http://aka.ms/arm-template-expressions 有关用法的详细信息./p>

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",Logic App将对来自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.

我在做什么错了?

推荐答案

您需要对内部单引号进行转义,即尝试

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 Logic Apps的字符串串联问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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