CHAPTER 1
Beginning Azure Function Apps
Introduction
In the first chapter of this book, we are going to talk about the Azure serverless architecture and why we should consider using this architecture in our applications. You will then go through some real-world business scenarios in the next section of the chapter.
This chapter will give you a basic idea of all the services in the serverless platform such as Azure Functions, Logic Apps, Event Grid, and Cosmos DB. Then it will walk you through different paradigms such as applications hosted in on-prem, Iaas, PaaS, and serverless applications.
Then, it will focus more on the main topic of the book: Azure functions. It will talk about the features of functions, different service integrations on functions such as Cosmos DB, Event Grid, Storage, and Notification Hub. After that, you will be able to get a better viewpoint of the released and experimental languages; and functions supported with different runtime versions.
You can learn about the heart of the function app, triggers and bindings in the next section of the chapter. In the end, you will get an idea of the different pricing options to host a function app and check the pros and cons of it.
Prerequisites
It would be better to have these prerequisites before going through this chapter:
- You should have an Azure subscription to try out the sample applications demonstrated in the chapter.
- Experience and understanding of different Azure services
- Experience in the C# or JavaScript languages
Structure
- Azure serverless architecture
- What is Azure serverless architecture
- Why serverless architecture
- Real-world case studies of serverless applications
- A single page web application
- Web application backend
- Mobile application backend
- IOT backend
- Real-time file processing
- Real-time stream processing
- Automating tasks
- SaaS Integration
- Azure serverless platform
- Azure Functions
- Logic Apps
- Event Grid
- Before it is serverless
- Applications in on-prem
- IaaS
- PaaS
- Serverless applications
- First s teps with Azure function
- What is an Azure function?
- Features of Azure functions
- Service integrations
- Azure Cosmos DB
- Azure Event Hub
- Azure Event Grid
- Azure Notification Hub
- Azure Service Bus
- Azure Storage
- Blob storage
- Azure file storage
- Queue storage
- Table storage
- Azure Logic Apps
- Azure SignalR
- Microsoft Graph
- Power BI
- Twilio API
- SendGrid API
- Language support for functions
- C#
- F#
- JavaScript
- Java
- Python
- TypeScript
- Php
- Batch
- Bash
- Powershell
- Triggers and bindings
- Triggers
- HttpTrigger
- TimerTrigger
- CosmosDBTrigger
- BlobTrigger
- QueueTrigger
- EventGridTrigger
- EventHubTrigger
- ServiceBusTrigger
- SendGridTrigger
- GraphAPITrigger
- NotificationHubTrigger
- SignalRTrigger
- TableStorageTrigger
- Bindings
- Type of functions
- Serverless web applications
- Serverless mobile backend
- Timer-based processing
- Real-time file processing
- Real-time stream processing
- Real-time bot processing
- Pricing in Azure functions
- Consumption plan
- Function scaling in consumption plan
- Billing in consumption plan
- App Service Plan
- Function scaling in app service plan
- Billing in app service plan
- When to use app service plan
Objective
- You will get an understanding of Azure serverless architecture and different application deployment paradigms like IaaS, PaaS, and serverless.
- You will get an understanding of the Azure functions and their features. Moreover, the services that you can integrate with functions such as Cosmos DB, Event Hub, Service Bus, Storage, and Logic Apps and third party services such as Twilio API and SendGrid.
- Then you will get an idea of language support for functions in different runtime versions along with experimental languages.
- Triggers and bindings on an Azure function are the primary building blocks in a function app; you will get a basic idea of them as well.
- Finally, you will cover an important part when deciding to move your code to an Azure function which is pricing plans. You’ll get an idea of different pricing plans available, their features, and when to use which plan.
Azure serverless architecture
In the first section of this chapter, let’s see what Azure serverless architecture is, why we need to go for serverless architecture, and what are its benefits. Then, let’s see some real-world scenarios where Azure serverless architecture is used and try to understand the applicability of it in our business domain.
Let’s explore Azure serverless platforms such as Azure Functions, Azure Logic Apps, and Azure Event Grid in detail and their features. You will get a basic understanding of these three Azure services under the serverless architecture. This book is going to give you a high-level understanding of the Azure functions using hands-on demos and real-world business scenarios.
The final section of this chapter describes the application deployment paradigms from applications deployed in a physical on-prem server, and then Infrastructure as a Service (IaaS) which provides a virtual environment to deploy your applications through virtual machines or hyper-v without worrying about the scaling and resource management. After IaaS, it talks about Platform as a Service (PaaS) that provides an environment to host your application without worrying about the operating system updates or security patches.
If you want to deploy a .NET web application, you will get all the required packages and libraries to host your application in this container and there is no need to install them manually. In the end, we will explore the latest serverless architecture after walking through all the paradigms and exploring its features. The serverless platform is a microservice-based architecture that focuses on application development instead of the platform. You can focus only on the application. There is no need to think about the host it’s running. When it comes to the pricing, in previous paradigms, you had to pay for the continuous running application. But in serverless code, you only pay for what you use in the application and only for the time the application runs.
What is Azure serverless architecture?
Azure serverless architecture focuses on developing applications faster without worrying about the application infrastructure. So, we don’t have to handle server or infrastructure. There is no need to worry about the operating system, its infrastructure, or configurations. We can only focus on the function implementation; in fact, server management and capacity planning is invisible to us and handled by Azure. Serverless code is event-driven; it works with triggers and bindings. Let’s talk about triggers and bindings in detail in the later stages of this chapter.
Why serverless architecture
Let’s see why serverless architecture is essential in real-world business applications. What are the features in that architecture and what is their usage?
- Build apps faster using serverless functions.
- There is no need to handle server or infrastructure and there are no administrative tasks.
- We don’t have to worry about the operating system, its configurations
- We can focus only on the function implementation and business logic.
- Applications can be scaled on demand without worrying about the infrastructure.
- Applications have high availability.
- Service billing is based on pay as you go: the number of resources consumed or the time our code is running.
- Create modern applications with real-time triggers and bindings
- Integrate Azure services such as Cosmos DB, Logic Apps, or else, use third-party services such as SendGrid and Twilio SMS API
- Work with intelligent services such as Azure machine learning and cognitive services
Real-world case studies of serverless applications
We have understood the features of serverless code and why we should go for a serverless architecture in the previous sections. Let’s explore some real-world case studies that used serverless code in their applications.
A single-page web application
We can create a SPA with a REST API service backend and deploy it into Azure. Single Page Application (SPA) will dynamically load the content to the page instead of a full-page load from the server. Angular, React, Vue, and, Ember JS are the most popular SPA frameworks to build web applications. In this way, you can use an Azure function to host your site and its pages and App calls functions using a webhook url and process its data. If we deploy a web application in a serverless environment, it will reduce the deploymen...