Azure逻辑应用从正文提取第二行。

huangapple go评论42阅读模式
英文:

Azure logic app extract 2nd line from body

问题

我需要从消息正文中提取一个包含重要服务名称的消息正文,该服务名称是纯文本。我需要将整行提取到一个新字段中。在Azure逻辑应用中如何实现这一点。

示例数据

%%%
DB-Service-Name
Line1
Line2

我只需要在一个新字段中提取消息正文的第二行,名称为Service-Name。

英文:

I have a body message body which contains an important service name in the body of the message which is plain text. I need to extract that whole line into a new field. how can this be achieved in Azure logic app.

Sample data

%%%
DB-Service-Name
Line1
Line2

I only need to extract the 2nd line from the message body in a new field Service-Name

答案1

得分: 1

你需要使用分割操作,如@skin所提到的。我已经从我的一侧重现了问题,以下是我遵循的步骤:

  • 创建逻辑应用如下所示,并分配
%%%
DB-Service-Name
Line1
Line2

它在一个初始化变量中。

Azure逻辑应用从正文提取第二行。

  • 接下来,采用另一个初始化变量,如下所示,根据换行符拆分行,表达式为
    split(variables('Service'),'\n')

    注意:确保你在代码视图中添加这个表达式,因为逻辑应用默认附加'\'。

Azure逻辑应用从正文提取第二行。

接下来,采用另一个初始化变量如下所示,以获取第二个值,表达式为,
split(variables('Service-Name'),',')[1]

Azure逻辑应用从正文提取第二行。

逻辑应用成功运行如下所示。
Azure逻辑应用从正文提取第二行。
最终初始化变量的输出。
Azure逻辑应用从正文提取第二行。

英文:

you need to use split action as mentioned by @ skin. I have reproduced issue from my side and below are steps I followed,

  • Created logic app as shown below and assigned
%%%
DB-Service-Name
Line1
Line2

it in a initialize variable.

Azure逻辑应用从正文提取第二行。

  • Next taken another initialize variable as shown below to split lines based on new line and the expression is
    split(variables('Service'),'\n')

    Note: Make sure you add this expression in code view as logic app by default append '\'.

Azure逻辑应用从正文提取第二行。

Next taken another initialize variable as shown below to get second value and the expression is,
split(variables('Service-Name'),',')[1]

Azure逻辑应用从正文提取第二行。

logic app ran successfully as shown below.
Azure逻辑应用从正文提取第二行。
Output of final initialize variable.
Azure逻辑应用从正文提取第二行。

huangapple
  • 本文由 发表于 2023年3月3日 17:53:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75625543.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定