Book Image

Learning Azure Functions

By : Manisha Yadav, Mitesh Soni
Book Image

Learning Azure Functions

By: Manisha Yadav, Mitesh Soni

Overview of this book

Functions help you easily run small pieces of code in cloud with Azure functions without worrying about a whole application or the infrastructure to run it. With Azure functions, you can use triggers to execute your code and bindings to simplify the input and output of your code. This book will start with the basics of Azure Functions. You will learn the steps to set up the environment and the tools that we will be using in the further chapters. Once you have a better understanding of this, we will be creating our first hello world function app. Later you will be introduced to triggers, how they are used to activate a function, and how binding can be used to output results of a function.You will also explore the steps to create an assembly with complex functionality that can be used by functions. Next, this book will teach you to scale your functions and use them to process data, integrate systems, and build simple APIs and microservices. Finally, this book will cover some diagnostic techniques with Azure App services and best practices of working with Azure Functions. By the end of this book, you will be well-versed with the techniques of scaling your Azure functions and making the most of serverless architecture.
Table of Contents (10 chapters)

Azure Services versus AzureFunctions versus AWS Lambda

Let's try to compare Azure App Services, Azure Functions, and AWS Lambda. The following table may not contain all the points:

Azure App Services

Azure Functions

AWS Lambda

Category

Platform as a Service.

Allows you to develop serverless applications on Microsoft Azure.

Allows you to develop serverless applications on AWS.

Definition

Microsoft Azure App Service is a PaaS offering. We can create web and mobile apps for any platform or device.

Azure Functions is a service provided by Microsoft to run small pieces of code, or functions, in the Microsoft Azure cloud. We only need to focus on the problem and not the resources required for the solution.

AWS Lambda allows us to execute code in serverless architecture, where the resources are managed by AWS.

Vendor

Microsoft Azure.

Microsoft Azure.

Amazon/AWS.

Available from

2015.

2016.

2014.

Languages Supported

ASP.NET, Node.js, Java, PHP, and Python.

C#, F#, Node.js, Python, PHP, batch, bash, or any executable.

Node.js (JavaScript), Python, Java (Java 8 compatible), and C# (.NET Core).

Integrated development environment support

Yes (Microsoft Visual Studio IDE).

Yes (Visual Studio).

Yes (Eclipse IDE and Visual Studio IDE).

Environment variables support

Yes, in Application Settings.

Yes.

Yes.

Cost

App Service plan can be hosted are FREE (try for free), SHARED (host basic apps), BASIC (more features for Dev / Test), STANDARD (go live with web and mobile), and PREMIUM (enterprise scale and integration).

For more details go to https://azure.microsoft.com/en-in/pricing/details/app-service/.

Consumption plan means that 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 function runs.

For more details go to https://azure.microsoft.com/en-in/pricing/details/functions/.

The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month.

The first 1 million requests per month are free and $0.20 per 1 million requests thereafter ($0.0000002 per request).

For more details go to https://aws.amazon.com/lambda/pricing/.

Eligible for free tier

Yes.

Yes.

Yes.

Flexibility in configuration of resources

Yes.

Limited. (If App Service plan is used then configuration of resources is available.)

No (need to verify).

Execution time

N/A.

Azure Function must complete execution within 300 seconds.

AWS Lambda function must complete execution within 300 seconds.

Limit to the number of functions that can be executed

N/A.

No.

No.

Concurrent executions

N/A.

No limit.

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000.

Scalability

Manual and automatic scaling available in the form of an App Service plan.

Manual and automatic scaling has two plans available for costing; a Consumption plan and an App Service plan. For more details, check the Cost section in this comparison table.

Automatic scaling.

Monitoring

Azure App Insights / Azure App Service Default Monitoring.

N/A

Amazon CloudWatch console or AWS Lambda console.

Templates

Web

Web + SQL

Web Apps

Mobile Apps

Logic Apps

Media services

Blogs + CMSs

Starter web apps

Web app frameworks

Ecommerce

Add-ons

BlobTrigger

EventHubTrigger

Generic Webhook

GitHub Webhook

HTTPTrigger

QueueTrigger

ServiceBusQueueTrigger

ServiceBusTopicTrigger

TimerTrigger

Blank function

kinesis-firehose-syslog-to-json

alexa-skill-kit-sdk-factskill

batch-get-job-python27

kinesis-firehose-apachelog-to-json

cloudfront-modify-response-heade

s3-get-object-python

config-rule-change-triggered

lex-book-trip-python

Supported event sources /integrations

N/A.

Azure Cosmos DB

Azure Event Hubs

Azure Mobile Apps (tables)

Azure Notification Hubs

Azure Service Bus (queues and topics)

Azure Storage (blob, queues, and tables)

GitHub (Webhooks)

On-premises (using Service Bus)

Twilio (SMS messages)

Amazon S3

Amazon DynamoDB

Amazon Kinesis Streams

Amazon Simple Notification Service

Amazon Simple Email Service

Amazon Cognito

AWS CloudFormation

Amazon CloudWatch Logs

Amazon CloudWatch Events

AWS CodeCommit

Scheduled Events (powered by Amazon CloudWatch Events)

AWS Config

Amazon Alexa

Amazon Lex

Amazon API Gateway

Other Event Sources: Invoking a Lambda Function On Demand

Sample Events Published by Event Sources

URL

https://azure.microsoft.com/en-us/services/app-service/

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

https://aws.amazon.com/lambda/

Documentation

https://docs.microsoft.com/en-us/azure/app-service/

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

https://aws.amazon.com/documentation/lambda/