hi welcome in another episode of cloud in five minutes today I want to show you
how to use Azure functions from a logic app aussi si vous préféré j'ai une version
en francais de ce vidéo, cliquer sur le lien en haut à droite. let me introduce myself I'm Frank
Boucher Microsoft Azure MVP based at Montreal what I want to do today is use
this JSON file that I use in my reading notes that I publish every Monday and
extract the tags and only get single instance of it of each of one for
example in in those notes I have the cloud and the azure that came in every
one of them I want to keep only the unique tag I will do that
leveraging a logic app and as your functions let's do it
I'm in the portal in the logic app we created in the last episode if you miss
that episode the link will be in the description of this video so now what I
need to do is clean up a little bit so I can start from fresh so I still need to
read the file I'll still need to parse the JSON file the variable I don't need
a counter anymore but I needed a variable to hold all my unique tags so
let's call it unique tags and let's change it for a string and it will be
empty at the beginning now in the loop I don't need any more the create file
and I don't need to increment my variables I will delete that too perfect
let's save that now what I need to do is create a function and let's go in
another tab will maximize this ok let's create an HTP trigger and I will use C
sharp since it's the language I'm comfortable with won't call it keep
unique tags since it's what it does to speed up the process I already have the
code so we'll just copy-paste it so I can show you since I will be
manipulating some Jason I need this library and now what I'm expecting to
receive is a node that will have the node with one node and unique tags as an
element where I will have the list that I need to grow up so I will read the
content and create a new collection tags then I will take my content and make it
the decent object before king my tags collection I just need to check if it's
empty then I split it by dot and build my collections or otherwise it just
create any one then I will go read the data no tags so here node and tags and I
received this it's a string with dots so I split it by dot and now I have an
array and I will loop through them to extract any tag that it's not already
contain let's have a try see it's working perfectly every time I have a
new tag since now the unique tag was empty it founds seven of them so bunch
of details that was creating perfect now let's go back to our logic app so in the
for each we'll need to call a sure functions to do it we just need to add a
new step and click on the agile functions
then we'll pick a function App Cloud in five minutes in my case and we'll select
the functions we need keep unique tags
perfect remember I told you I wanna I was expecting a specific format so let's
specify this buddy so we'll use this remove everything yep voila and current
item is going here and in my union tag gonna set my variable perfect now every
time the function will be called and return unit add fact I need to take this
answer and set it as a decent object to do it you guess it I will use again
decent parse JSON parse and I will use the answer I receive from my my test to
generate so my content is the output of my functions and the schema you remember
we can use this link here to generate from a decent file and now we have our
schema so now what we need is to set our functions with this result
so set variable so we'll pick my variable unique tags and then for the
content I will use the second parts Jason I could have renamed it by the way
who will make more sense and use the tag perfect now my variable is set okay so I
think the only thing that left now is to save that file so out of the for each
because we want to create only one let's create another onedrive so we'll create
that and get back to you after and voila for the content of my father we'll use
the variable unique tags at the end of the loop it should contain every
instances one instances of every tag so voila save now we're ready to test it so
run let's bring that folder voila and I copy paste my jisun file and
we wait oh that was quick so I see everything is spend five turn and if I
open it in node a node in code we can see that I have one instances of every
tags that was available voila in a few clicks I was able to take
an azure function inside the logic app to parse a decent file and extract some
information and now I have a really server less social to see other videos
about logic app click here on the top to see another great video about cloud in
five minutes just click here on my site I hope you liked it and I hope this
video was useful see you next time
you