想要创建一个Azure Logic App表达式

时间:2019-02-27 20:35:42

标签: azure azure-logic-apps

在Azure Logic应用中,我正在创建Blob事件网格。每当我从存储帐户中添加或删除Blob时,我都可以获取事件。因此,我得到以下回应。

enter image description here

在主题中,我得到的响应为'/ blobServices / default / containers / james / blobs / catputvendor / Capture.PNG'

现在,我需要编写一个低于结果的表达式。 '/ james / catputvendor / Capture.PNG'。 哪种表达最好。

我在使用c#的情况下获得了以下表达式,但在逻辑应用程序表达式中,我们没有Remove方法。我需要在逻辑应用程序中执行以下操作:

var subStri1 = str.Remove(str.IndexOf("/blobs"), "/blobs".Length).Substring(str.Remove(str.IndexOf("/blobs"), "/blobs".Length).LastIndexOf("/containers") + "/containers".Length);

1 个答案:

答案 0 :(得分:2)

Subject中的Dynamic content,它是有关Blob的绝对路径。因此,您可以使用split表达式来获取所需的路径。

表达式将是这样的:split(triggerBody()?['subject'], '/')?[4]。我的主题路径是/blobServices/default/containers/firstcontainer/blobs/test/Snipaste_2018-11-13_10-08-08.png。因此,表达式将获得容器名称firstcontainer

因此整个表达式将是 @{split(triggerBody()?['subject'], '/')?[4]}/@{split(triggerBody()?['subject'], '/')?[6]}/@{split(triggerBody()?['subject'],'/')?[7]}

这是我的流程和结果页面。

enter image description here enter image description here

希望这对您有帮助,如果您还有其他问题,请告诉我。