Friday, September 4, 2020

Call Azure Function using Console Application – Part 4

Previous Post - Calling Azure Function using Postman – Part 3

In this part, we will create a Console Application (.Net Framework) and call Azure Function from it.

Step 1 – Open Visual Studio and create Console Application (.Net Framework) project.

 

Step 2 – Add a class “StudentDetail”and its data members as below.

We will be using these data members to send request to the Azure Function.





















Step 3 – We will "set" static values to data members of the Student Details class. 

Add below code to your Program class.


















Step 4 – Create "WebClient" to call Azure Function.

We will use “WebClient” method for sending request and receiving response and “Newtonsoft Json” library to convert student object to json string that will be further used as request parameter to Azure Function.

Add below code to your “Program” class.

Step 5Debug code line by line and see the request and response.

Request










Response








The reason why we are getting this response is because of below code in our Azure function that we had deployed.



Yay!! We Did it.

Stay Connected, to see next part of the series.

Reference to MS Documentation - 

https://docs.microsoft.com/en-us/azure/azure-functions/

Happy Learning, LET'S SHARE !

No comments:

Post a Comment

Popular Posts