Microsoft Azure Developer: Create Serverless Functions in Azure Portal
Microsoft Azure Developer: Create Serverless Functions in Azure Portal

Create Serverless Functions in the Azure Portal. Azure functions have the capability to greatly speed up your development, reduce your cost, and allows you to automatically scale to meet the high demand.

What is Azure Functions?

Functions as a Service (FaaS) - A platform for running "functions", which are nothing but your code running in response to an event.

Features of Serverless Functions

  • Automated and flexible scaling based on your workload volume.
  • Integrated programming model based on triggers and bindings.
  • End-to-end development experience, from building and debugging to deploying and monitoring with integrated tools and built-in DevOps capabilities.
  • Variety of programming languages and hosting options.
azure functions supported language

Triggers

Various triggers used to invoke Azure Functions.

  • A function runs at a specific time using a timer trigger.
  • Message Trigger: Listen to a message in a queue and process it as and when a message arrives.
  • HTTP Request: create a web API that responds to different HTTP methods.
  • Azure functions respond to the webhook callback. Third-party service triggers callbacks.
azure serverless functions trigger
Triggers

Bindings

Binding to a function is used to connect another resource to the function.

Different bindings, input bindings, output bindings, or both can be used. Data from bindings are provided to the function as parameters.

You can mix and match different bindings to suit your needs. Bindings are optional. A function might have one or multiple inputs and/or output bindings.

azure serverless functions bindings

Read more on Azure Functions triggers and bindings concepts this has details on supported bindings.

Serverless Architecture

What is Serverless Architecture? what are the benefits that brings to us ?

  • Azure will manage servers.
  • Per-second billing model. Pay only when your code runs. There is also a monthly free grant which is sufficient for any developers who are exploring serverless functions.
  • Automatic scaling. Application demands met automatically.

Azure functions is simpler, cheaper and more scalable.

azure serverless functions hosting models

Creating Functions in the Azure Portal

In this module, I will show how to create azure functions in a azure portal.

Visit https://Portal.azure.com and login with your azure portal account.

If you are new or do not have Azure subscription, visit Create your Azure free account today and get your free $200 credit.

Create Azure Function App

Search for "Function App" in the search box in the top and click on "Function App" to create.

Creating Functions in the Azure Portal
dashboard of function app

Above page is the dashboard of Function App. Click on "Create Function App" to create a new one.

Basic Configuration

creating function app basic configuration

Always create a new resource group for any new service that you create. This will help in managing it easily.

What is a resource group? A resource group is a container that holds related resources for an Azure solution.

Choose a unique name for the Function App. I have provided as "karthiktechblog-function-app" that will end up forming a base URL as http://karthiktechblog-function-app.azurewebsites.net/.

Choose the publish option as code or docker. In this example, we choose as code and in docker post, I will show how to use Docker as publish option.

Next is to choose the Runtime Stack and its version. last part in the basic configuration section is to choose the region. Choose the close one near by your location.

Hosting Configuration

creating function app hosting configuration

Monitoring Configuration

creating function app monitoring configuration

Select Application Insights which is useful to find details of request in case of error.

Tags used to apply in your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. To read more about Tags visit here Use tags to organize your Azure resources and management hierarchy

Review & Create Configuration

This is the final page to verify the configuration made so far.

Review and create function app

Alright, now we have successfully created Function App. Now its time to create a new function and consume it from portal.

Creating a Function in Azure Portal

azure function app dashboard

From the azure Function App dashboard, click on Function in the left navigation bar. This will show you the available functions under this Function App.

azure function dashboard

Click on Add to create a new Function.

Next is to choose a template. There are many inbuilt templates that are available to the right-side panel, choose the one that fits your requirement. In my example, I will choose the HTTP Trigger.

azure function template

Next is to name the function and select the authorization level for the function.

function trigger details
  • anonymous: No API key is required.
  • function: A function-specific API key is required. This is the default value if none is provided.
  • admin: The master key is required.
Microsoft Azure Developer: Create Serverless Functions in Azure Portal

Now the function is ready. Click on Code and Test, you will see the default code created by the template.

This simple API will read the request and try to find a parameter called "name" and send a hello message. If name parameter is not sent, you will get a Bad Request (HTTP 400 status code).

Output is seen in the output tab and logs can be seen in the console.

Related Post

This post is part of Implement Azure functions, skill measured in AZ-204 and Exam AZ-203: Developing Solutions for Microsoft Azure

Conclusion

In this post, I showed you how to create Serverless Functions in the Azure Portal. That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights