Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Azure Functions

You're reading from   Learning Azure Functions Build scalable cloud systems with serverless architecture

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781787122932
Length 240 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Mitesh Soni Mitesh Soni
Author Profile Icon Mitesh Soni
Mitesh Soni
Manisha Yadav Manisha Yadav
Author Profile Icon Manisha Yadav
Manisha Yadav
Arrow right icon
View More author details
Toc

Why Azure Functions?

Yes, the immediate question can be what exactly is this Azure Function? In simple English, it is running a function in a cloud environment. It enables us to create a serverless application in a Microsoft Azure environment. Consider a scenario where we know the problem, we know the code that can fix the problem, and we don't want to worry about resources that execute this code. This is the easiest way to focus on logic and business and enhancing the scope of productivity. The biggest benefit is we only need to pay for what we use. Let's understand what exactly in terms of features are provided by the Azure Functions and Azure App Services:

Azure App Services (Web Apps, Mobile Apps), and Functions support different languages and frameworks, DevOps capabilities, scaling, load balancer and etc.

Azure Functions is a service provided by Microsoft for serverless computing. The Azure function is a combination of code plus events plus data. Azure Functions is open source and available on GitHub:

Let's see where Azure Functions is placed in Cloud Service Models in the following figure:

Azure Functions are similar to Azure Webjobs with some differences such as scaling policies, trigger events, and language support. We don't need to worry about infrastructure for execution of the piece of code or function. It is like a FaaS. We can execute Azure Functions in response to events as well.

The languages that are supported are C#, F#, Node.js, Python or PHP, batch, bash, or PowerShell.

There are two types of pricing plans available in the Azure Functions:

  1. Consumption plan: When we execute functions, Microsoft Azure provides all the resources. We don't need to worry about resource management, and we only pay for the time that our functions are executed. The consumption plan pricing includes a monthly free grant of 1 million requests and 400,000 GBs of resource consumption per month. Free grants apply to paid consumption subscriptions only.
  2. App Service plan: This executes functions just the way we execute Azure App Services. We can utilize the same App Service plan created for any application and execute Azure Functions on it without any extra cost.

Having App Service plan as the host for Azure Functions provides lots of benefits that are available with Azure App Services. We can utilize remote debugging, deployment slots, continuous deployment, vertical scaling and horizontal scaling, auto-scaling, and so on. If we use the Azure App Service, then it is a multitenant scenario. If we want to utilize a dedicated environment, then we can utilize the App Service Environment that is a dedicated service from Microsoft Azure, where we can host a function in a virtual network and configure network security groups (NSGs) for an enhanced level of security.

Triggers and bindings are the core of Azure Functions. It allows us to write a function to respond to events that occur in the Azure or other services. As the name suggests, trigger indicates how the function should be invoked and bindings are related to data. Azure Functions can have only one trigger associated with it. Bindings are the connection to the data from within the code available in the function. Unlike triggers, functions can have one or more input and output bindings.

The following table shows the triggers and bindings that are supported with Azure Functions:

Type

Service

Trigger*

Input

Output

Schedule

Azure Functions

Yes

HTTP (REST or Webhook)

Azure Functions

Yes

Yes**

Blob Storage

Azure Storage

Yes

Yes

Yes

Events

Azure Event Hubs

Yes

Yes

Queues

Azure Storage

Yes

Yes

Queues and topics

Azure Service Bus

Yes

Yes

Storage tables

Azure Storage

Yes

Yes

SQL tables

Azure Mobile Apps

Yes

Yes

No-SQL DB

Azure DocumentDB

Yes

Yes

Push Notifications

Azure Notification Hubs

Yes

Twilio SMS Text

Twilio

Yes

SendGrid email

SendGrid

Yes

(* - All triggers have associated input data)
(** - The HTTP output binding requires an HTTP trigger)

Let's try to get to grips with Azure Functions quickly:

  1. Go to https://functions.azure.com/try.
  2. Select Webhook + API as a scenario and select JavaScript as the language.
  3. Click on Create this function:
  4. Select an auth provider.
  1. Select any suitable authentication method and sign in with it:
  2. Wait for few seconds until a free trial fo Azure Functions is ready:
  1. The sample script is ready for Hello World!:
  1. Click on Test on the right side of the browser window. In Request body, provide the name:
  1. Click on Run and scroll down.
  1. See the Output and Status:

So, we have just executed the simple Hello World function. We will execute Azure Functions in a proper Azure subscription in later chapters.

The following are some of the benefits of Azure Functions:

Before we jump to Azure Functions, let's understand some basics of Microsoft Azure cloud. We will discuss the key components and services of Microsoft Azure in the next section.

You have been reading a chapter from
Learning Azure Functions
Published in: Sep 2017
Publisher: Packt
ISBN-13: 9781787122932
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image