
eBook - ePub
Build Azure functions and integrate them with Azure Cosmos DB data models
Leverage Azure functions and Cosmos DB for building serverless applications (English Edition)
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
Build Azure functions and integrate them with Azure Cosmos DB data models
Leverage Azure functions and Cosmos DB for building serverless applications (English Edition)
About this book
Build Azure functions and integrate them with Azure Cosmos DB data models
Key Features
- Expert-led coverage on integrating Azure functions
- Industry-proven examples and best practices on implementation of Azure Cosmos DB
- Learn to work on performance optimization and error handling
- Integration of Azure function with other Azure services Description
This book provides examples to start with Azure functions and Azure Cosmos DB. It demonstrates the features available in both of the mentioned Azure services and discusses them in detail with some real-world examples. Reading a csv file and write to a Cosmos DB table store, Read emails using Microsoft Graph API and save them in a Cosmos DB, Cosmos DB trigger function to send SMS notifications to clients, A queue trigger to create new nodes in the Cosmos DB graph data store are some of them. You will be able to see the above case studies with code samples implemented in C#.NET Core, TypeScript, and Python. It consists of a very basic example, two intermediate samples, then and an advanced level one.You will experience the triggers and input/output bindings available for a function, like queue trigger, blob trigger, and Cosmos DB trigger to name a few. Also, you will be able to see some interesting features available in Azure functions like performance optimizations, scalability of a function app, geographical distribution of the function in different locations, error handling, writing unit tests for the functions to avoid breaking changes, how to ensure a function app is secure, and then how to deploy a function, and monitor and troubleshoot a function app.At the end of this book, you will gain strong experience in using Azure functions and how to manage serverless applications seamlessly without any failure with utmost performance. What you will learn
- You will be able to create an Azure function and integrate it with many Azure services including the Azure Cosmos DB
- You will get experience implementing a function using programming languages like C#.NET Core, TypeScript, and Python.
- You will get hands-on experience on the performance optimizing of a function, how to scale them, how to apply security to the function app, error handling and testing in a function. Who this book is for
This book is for developers who want to get the knowledge and experience in Azure Functions and Azure Cosmos DB. If you have a programming knowledge of.NET, TypeScript, Python, or any other programming language, it will be enough to understand the concepts and samples in this book. If you have worked with a cloud technology or have experience in any of the Azure cloud services, then it will be a definite advantage.. Table of Contents
1. Beginning Azure Function Apps
2. Your First Azure Function App
3. Let's Get Started with Cosmos DB
4. Structure Your Data in Cosmos DB
5. Your First Cosmos DB
6. Serverless Design Patterns
7. Performance and Scalability of a Function App
8. Geo-Distribution in a Function App
9. Error Handling and Testing
10. Secure Your Function App
11. Deployments in a Function App
12. Monitor and Troubleshoot Function Apps
13. Azure Functions with Cosmos DB Table API
14. Azure Functions with Cosmos DB SQL API
15. Cosmos DB Trigger in Azure Function
16. Azure Functions with Cosmos DB Gremlin API About the Author
Hansamali Gamage is an enthusiastic and dedicated professional with over eight years of experience in.NET stack, Azure, and front-end technologies. She has also been an MVP (Azure) for three consecutive years and is a Microsoft Certified Trainer. She is a frequent speaker at tech conferences and an award-winning writer on the Microsoft Tech Net forum. Blog links: http://hansamaligamage.blogspot.com/
LinkedIn Profile: https://www.linkedin.com/in/hansamali-gamage-37777a50/
Frequently asked questions
Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Build Azure functions and integrate them with Azure Cosmos DB data models by Hansamali Gamage in PDF and/or ePUB format, as well as other popular books in Computer Science & Cloud Computing. We have over one million books available in our catalogue for you to explore.
Information
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
- Azure Storage Blob Storage
Queue Storage
Table Storage
Cosmos DB
Event Grid
Event Hub
Http and Webhook
Microsoft Graph
Mobile Apps
Notification Hub
SendGrid
Service Bus
SignalR
Timer
Twilio
- Azure Storage
- Triggers
- 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
- Consumption 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...
Table of contents
- Cover Page
- Title Page
- Copyright Page
- Dedication Page
- About the Author
- About the Reviewer
- Preface
- Errata
- Table of Contents
- 1. Beginning Azure Function Apps
- 2. Your First Azure Function App
- 3. Let’s Get Started with Cosmos DB
- 4. Structure Your Data in Cosmos DB
- 5. Your First Cosmos DB
- 6. Serverless Design Patterns
- 7. Performance and Scalability of a Function App
- 8. Geo-Distribution in a Function App
- 9. Error Handling and Testing
- 10. Secure Your Function App
- 11. Deployments in a Function App
- 12. Monitor and Troubleshoot Function Apps
- 13. Azure Functions with Cosmos DB Table API
- 14. Azure Functions with Cosmos DB SQL API
- 15. Cosmos DB Trigger in Azure Function
- 16. Azure Functions with Cosmos DB Gremlin API
- Index