Azure functions, HTTP Trigger & send an event from function to Azure service bus queue & vice-versa

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back in this video we are going to learn about azure functions azure function is basically used to you know like have a small kind of like a very lightweight feature where you don't want to write end to end any dotnet application or any other kind of application so for example let's say you want to send some kind of notification or you want to send email or you want to run a background you know or some job or i would say some kind of cleanup activity or some kind of you know migration activities those for those sort of things i think we can use as your functions so in this video i will be covering two topics the like http trigger function and the uh azure azure service bus triggered a function in that case what will happen whenever there is a new event in the particular queue then this function will be called and then this functions output can be sent to another queue or you can log it into your console something like that all right so for creating the function you should have a function app which you can obviously create from the azure portal and then once you create that function you just need to add a trigger so in this case you can see this like http trigger is there and i was talking about the azure service was q trigger all right so when you select this http trigger you will get this pretty much you know i would say this code all right and what it's doing is saying like okay the whatever this will actually give you the key url and in that you can have a query parameter or you can have if it support if you want to make it like a post then you can have entirely json object all right so it will it will take care of both the stuffs so let me run this one first i'm running locally right now so you can see this http trigger function is up and running and we got this local url let me copy this one and if i go to the url if i directly hit it it will say let me remove this debugger it's saying like there is no parameter pass please pass a parameter so for example for queries parameter we can use always question mark and type our parameter name which is name obviously this you can change in the code if you want to have something else and let's say i'll type ng you can say hello ng this http function is executed all right so this is what is happening same thing we can do it from the postman i mean like if it's a post so you want to make it like a post api just copy this url and then go to postman okay so i think it's the same port okay yes and then again here also you can say uh name is equals to whatever it is it's just a you know j you are passing this as a you know post body now if you send you should get the pretty much same output you can say if i change this output let's say one two three see it's getting executed it's that simple so it's just to tell you how it will work now it's up to you what you want to do when someone is calling this get api or a post api what you want to do that is up to your business logic what you want to do all right second thing let's say i was saying you will send your application sending a message to particular queue let's say q1 and then you want to capture that event in the function as your function and then you want to trigger it all together new you went to a different queue that is also possible and like that you can do many things so for that let me uh open that old solution which i have covered in the past videos uh zero service bus skew in that if i tell you right now i have two events event one and even two what actually i will be doing from this application i will be sending event to this queue i'm like uh for the q1 and then what will happen this even will go to the azure function and azure function will send to the event 2 which is nothing but the sample demo 2 even for that also you can use pretty much same function so i'll tell you how you will be creating actually i just directly created let me add one more [Music] sorry now see it's telling all that like when this function should be on what basis it will be getting triggered so you have these many you know like like you can use signal you can use a topic trigger i'm covering this right now q trigger and i showed you just now stp trigger like then you can use whatever you want to use all right so let me cancel this one i'll go back and when you select this as your service bus trigger you will get this pretty much code you won't get these believe below three photo lines for that what you need to do you need to have that you know your entire json will be coming to this parameter which is my queue item and then what you can do you can deserialize this object and once you deserialize you can let's say you want to temper the message or you want to do something else and what i am doing i am just changing the message i am saying from azure service from azure function so whatever is the message i will be sending to uh my q1 it will change and it will append this say you know this string you can see from azure function and then it will send that event again to that q2 so and where we are defining this you can see obviously in the parameter so this is my uh event one that is nothing but q1 and where it should go that is like service bus and this is the queue too all right so if you run this one i'll just show you i'll go back to this q application and if i run this one and let me add a debugger first in my handlers so i have handler one and handler two all right my application is up and running this message i'll show you where i'm sending also all right let me send this message i'll say hello world and you should see i'm sending event to sample demo one event all right that means the first queue if i release this see the callback came or i'm like the we got the event from the event too and if you see the message you should see from azure function hello world and we just pass hello world all right so you are able to see how we are able to do and i'll just show you the settings as well so for example if you are doing from portal right there is one small catch so i mean this is how you will be creating the function once you create and you will be adding a trigger instead of uh storage you will be selecting the service bus and then you will see a method like this one so if you see in our current code i am just sending this like we are defining like this uh out we are returning this output as a written but in case of if you are doing from the portal directly then you need to have a out parameter actually here you will say comma and then say out parameter and whatever the variable name you will define in the output window i will show you where it will come [Music] yeah it's over here so when you will select like where the what where the no output of the function should go so in that case you will be clicking on this as add output and then select that window and then you will be giving a you know variable name over there the same variable you have to you know mention in your this parameter and it should be as a out parameter all right that's pretty much about this video thank you very much
Info
Channel: Rakriative
Views: 7,634
Rating: undefined out of 5
Keywords: azure functions, azure, azure function, azure function app, azure functions tutorial, azure functions http trigger, http trigger azure function, functions, http trigger, time trigger azure function in azure, what are azure functions?, azure functions c#, testing azure functions, azure functions triggers, azure functions for beginners, microsoft azure functions, how to use azure functions?, azure functions timer trigger, azure serverless functions
Id: q6tfjncuDSk
Channel Id: undefined
Length: 8min 12sec (492 seconds)
Published: Wed Sep 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.