In this article, we’ll learn about Azure Functions and Azure Function app. Then we’ll go ahead and learn the process of creating the Azure Function app step-by-step. Next, we’ll create the HTTP trigger function and finally test it too.
Azure Functions is the popular serverless compute platform on Microsoft Azure, supporting rapid integration with the Microsoft suite of products. Azure Functions is an event-driven serverless compute platform which enables complex orchestration difficulties to be solved easily. Using Triggers and Bindings, services can be integrated. Applications can be deployed and scaled flawlessly in the cloud with Azure functions. Depending on the workload volume, the infrastructure scales automatically. Building, debugging, deploying, and monitoring are all possible with ease with the built-in DevOps capabilities supported by the Azure Functions. It supports multiple programming languages from C#, Python, Java, or Node.js. With the use of Azure Functions, it can drastically minimize the time to solve problems compared to traditional approaches thus saving the time of developers and duration to provide service to the clients. Learn more about Azure Serverless from the previous article, Azure Serverless. The Azure Function allows us irrespective of the setup of virtual machines or publishing of the web applications to run our code in the serverless environment.
Azure Function App
In order to host the execution of the functions, Azure Function App is integral. The function app allows grouping of the functions for convenience in deployment, management, resource sharing, and scaling as one logical unit. Let us learn to create the function app in Azure through the step-by-step tutorial.
First of all, visit the Azure Portal and click on Create a resource.
Now, on the search bar in the marketplace, find Function App.
Click on Function App.
Under the Function App plan, click on Create.
Now, we are taken to the page to fill the details to create the function app.
Select the appropriate subscription and choose your resource group. If you don’t have one, create a new one.
Fill in the instance details: the function app name, the method of publishing, runtime stack, version, and region. I’ve selected Code for publishing and .NET as runtime. The region is the location where you want to setup this service. It is better to select one near to the expected location of your users.
Under the Operating System, I’ve selected Windows and Consumption (serverless) for the plan type.
Now, under Monitoring, select yes for enabling the Application insights.
Once done, click on Review + Create.
Next, Click on Create.
The deployment process is initialized.
As the deployment process proceeds, we can see the services and templates being created.
As the deployment is complete, we are provided with the “Go to resource” button to access the service we created.
We can see the details of the Azure Function app we created here. The URL is also showcased to explore.
The Metrics are all visualized for Memory, Function Execution Count and the time duration of the execution unit.
Creating the Trigger Function
Now, Under Functions in the left menu, click on Functions.
Now, click on Create Button.
Here, we are provided with the Development Environment through the Portal itself.
Also, we are given the choice of the template we want to use with the options of HTTP Trigger, Azure Queue Storage Trigger, Azure Event Hub Trigger and more. Aside is described in detail about the function.
We’ll select the HTTP Tigger.
Now, we name our New Function and set the Authorization level to Function.
Once, all is set, Click on Create.
The notification is updated about the creation of the function HttpTriggerEx1.
As we visit the details page of our function, we can see visualizations in detail. We can see the status is Enabled i.e. It’s currently running.
Now, under the Developer menu, select Code + Test.
Here, we have the HTTP Trigger code where we have an output message once the function is executed successfully.
Click on Get Function URL.
Set the Key to Default and copy the URL.
Now, on your browser, paste the URL.
We can see the HTTP trigger success message that the HTTP Triggered function has been successfully executed.
We can also see the logs about the execution with more details such as the time duration and on-going request processing.
Thus, in this way, we can create Trigger functions using the Azure Function App which can be used for various applications for different needs ranging from HTTP Trigger to Azure Event Hub, Azure Service Bus, Azure Storage, and more.
Thus, in this article, we learned about Azure Functions and Azure Function App. Thereafter, we went through a step-by-step tutorial to create the Azure Function App, create a Trigger in the development portal itself and tested it. With this article, we have now successfully learned to use the Azure Function App. This knowledge can now be applied to different use case scenarios for various project when we want the Azure Serverless functionality.