Reputation: 235
In Azure Logic App, I am creating blob event grid. I am able to get event whenever I have added or deleted a blob from a storage account. In that I am getting the below responses.
In the Subject i am getting response as '/blobServices/default/containers/james/blobs/catputvendor/Capture.PNG'
Now I need to write an expression which gets below result. '/james/catputvendor/Capture.PNG'. Which expression is best.
I got below expression using c# working but in logic app expression, we don't have Remove method. How I need to do in logic app as following:
var subStri1 = str.Remove(str.IndexOf("/blobs"), "/blobs".Length).Substring(str.Remove(str.IndexOf("/blobs"), "/blobs".Length).LastIndexOf("/containers") + "/containers".Length);
Upvotes: 1
Views: 928
Reputation: 14344
The Subject
in the Dynamic content
, it's the absolute path about the blob. So you could use split
expression to get the path you want.
And the expression would be like this:split(triggerBody()?['subject'], '/')?[4]
. My subject path is /blobServices/default/containers/firstcontainer/blobs/test/Snipaste_2018-11-13_10-08-08.png
. So the expression will get the container name firstcontainer
.
So the whole expression will be
@{split(triggerBody()?['subject'], '/')?[4]}/@{split(triggerBody()?['subject'], '/')?[6]}/@{split(triggerBody()?['subject'],'/')?[7]}
.
Here is my flow and the result page.
Hope this could help you, if you still have other questions, please let me know.
Upvotes: 2