Azure Functions — Part 2
hello folks, this is gonna be the second part of my azure function series. In case you haven’t read the first part, you can check it out here.
Alright, lets dive in. In this post, we will be looking at how can we create azure functions from Visual Studio.
So first, open visual studio, and search for a ‘function’ template.
name the project, and I have selected the empty template here.
We have our first azure function app solution ready now. Here is how my solution explorer look like.
Now, right click on the solution explorer ->Add New Item -> Select the “New Azure Function” template.
Select the http trigger function with anonymous access.
Now here is the built in azure function that came along with the template.
the http trigger highlighted in the above screenshot indicates that this action is invoked by an http request (get or post).
if we look at the code closely, it is almost similar to what we did in the portal. It intercepts the http request, looks for a querystring param called “name”, and returns an output based on the param.
Lets build the function app, and then run. When I hit the run, it opened up a azure function runtime which can be seen in a console window shown below.
If you look closely in the console, you can find a url, which can be used to invoke the azure function. Let’s give it a try
Here we can see that the querystring param which I provided got picked up by Azure function app, returned an out put according to the code we wrote.
Let’s also check out what happens if we provide an incorrect param name
Here the function handles the situation correctly, as you can see from the above screenshot.
Thanks for reading!