PDFelement Anniversary Sale 40% OFF
Coursera: Build New Skills Anytime, Anywhere with 100% online courses. Start Now!
Python Specialization from University of Michigan

Serverless tutorial – Invoke Azure functions using HTTP Trigger

Serverless services or FaaS like Azure Functions lets you run code without provisioning or managing servers. You pay only for the compute time you consume there is no charge when your code is not running. You can run code for virtually any type of application or backend service all with zero administration. Just upload your code and FaaS provider would take care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other services or call it directly from any web or mobile app.

You can read more about FaaS or Serverless here.

Step #1.Create Function App

A function app lets you group functions as a logic unit for easier management, deployment, and sharing of resources.

Once you login to Azure Portal,Click the New button on the upper left-hand corner of the Azure portal, then select Compute > Function App.

Microsoft Azure Portal - Click Function App

Image – Microsoft Azure Portal – Click Function App

11.11 Shopping Festival | Up to 90% Off for Cloud Server Plus $1000 Coupons on Alibaba Cloud

On the Function app,choose App name,Resource group appropriately

Function App Settings

Image – Function App Settings

Ivacy VPN

Subscribe to Emails

More than 100,000 subscribers across the world trust & read Upnxtblog articles. Subscribe to emails updates!
* indicates required

Hosting plan defines how resources are allocated to your function app. Default is Consumption Plan, resources are added dynamically as required by your functions.

Click on ‘Create’ to create the new function app.

Step #2.Create HTTP trigger function

So now we have function app,next step is to create new function that gets triggered by HTTP request.

A powerful and intuitive video editing experience
Function app

Image – Function app

On the left hand side, under new Functions app,Click on ‘+’ to create new function.

New Function
Halloween Discount for PDFelement

Image – New Function

Choose Webhook + API scenario since we are going to create function based on HTTP trigger.Appropriate launguage can be chosen,I’m going ahead with default language CSharp.In the next step,we can write sample code to print Hello <user>

Step #3.Test HTTP trigger function

Now that new function is created,we can test it by issuing HTTP request.

NordVPN Black Friday deal: grab the 3-year plan with 83% off and get two amazing gifts: 3 extra months + NordLocker file encryption app (worth $312)

Below is the console where you can modify the code if needed since this in an example,I’m going to the next step.Below code parses query parameter & sets it to variable then printed.

Code for new Function

Image – Code for new Function

There is an option to test the code inside the console itself.

Test Function

Image – Test Function

Copy the function URL.

Get Function URL

Image – Get Function URL

To the function URL append query parameter &name=<name> and make request to the function.

Test the function from browser

Image – Test the function from browser

Congrats! you have now created function app that can be triggered by HTTP request.In the next article,we can check on how to store the request data on to Azure Cosmos DB.

Like this post? Don’t forget to share it!

Additional Resources :

Summary
Article Name
Invoke Azure functions using HTTP Trigger
Description
This article explains how to set up your code to automatically trigger from other services or call it directly from any web or mobile app.
Author
Publisher Name
upnxtblog
%d bloggers like this: