Reader small image

You're reading from  Azure Serverless Computing Cookbook. - Third Edition

Product typeBook
Published inJun 2020
PublisherPackt
ISBN-139781800206601
Edition3rd Edition
Concepts
Right arrow
Author (1)
Praveen Kumar Sreeram
Praveen Kumar Sreeram
author image
Praveen Kumar Sreeram

Praveen Kumar Sreeram is an author, Microsoft Certified Trainer, and certified Azure Solutions Architect. He has over 15 years of experience in the field of development, analysis, design, and the delivery of applications of various technologies. His projects range from custom web development using ASP.NET and MVC to building mobile apps using the cross-platform Xamarin technology for domains such as insurance, telecom, and wireless expense management. He has been given the Most Valuable Professional award twice by one of the leading social community websites, CSharpCorner, for his contributions to the Microsoft Azure community through his articles. Praveen is highly focused on learning about technology, and blogs about his learning regularly. You can also follow him on Twitter at @PrawinSreeram. Currently, his focus is on analyzing business problems and providing technical solutions for various projects related to Microsoft Azure and .NET Core.
Read more about Praveen Kumar Sreeram

Right arrow

3. Seamless integration of Azure Functions with Azure Services

In this chapter, we'll cover the following recipes:

  • Using Cognitive Services for face detection in images
  • Monitoring and sending notifications using Logic Apps
  • Integrating Logic Apps with serverless functions
  • Auditing Cosmos DB data using change feed triggers
  • Integrating Azure Functions with Data Factory pipelines

Introduction

One of the main goals of Azure Functions is to enable developers to just focus on developing application requirements and logic and abstract everything else.

As a developer or business user, inventing and developing applications from scratch for each business requirement is practically impossible. We would first need to research the existing systems and see whether they fit business requirements. Often, it would not be easy to understand the APIs of the other systems and integrate them, especially when they have been developed by someone else.

Azure provides many connectors that can be leveraged to integrate business applications with other systems pretty easily.

In this chapter, we'll learn how to easily integrate the different services that are available within the Azure ecosystem.

Using Cognitive Services to locate faces in images

Microsoft offers Cognitive Services, which helps developers to leverage AI features in their applications.

In this recipe, you'll learn how to use the Computer Vision API (Cognitive Service) to detect faces within an image. We will be locating faces, capturing their coordinates, and saving them in different areas of Azure Table storage based on gender.

Cognitive Services apply AI algorithms, so they might not always be accurate. The accuracy returned by Cognitive Services is always between 0 and 1, where 1 means 100% accurate. You can always use the accuracy value returned by Cognitive Services and implement your custom requirements based on the accuracy.

Getting ready

To get started, we need to create a Computer Vision API and configure its API keys so that Azure Functions (or any other program) can access it programmatically.

Make sure that you have Azure Storage Explorer installed and configured to access the...

Monitoring and sending notifications using Logic Apps

One of my colleagues, who works for a social grievance management project, is responsible for monitoring the problems that users post on social media platforms, including Facebook and Twitter. He was facing the problem of continuously monitoring the tweets posted on his customer's Twitter handle with specific hashtags. His main job was to respond quickly to the tweets by users with a huge follower count, say, users with more than 50,000 followers. Hence, he was looking for a solution that kept monitoring a particular hashtag and alerted him whenever a user with more than 50,000 followers tweets so that he can quickly have his team respond to that user.

Note

For the sake of simplicity, in this recipe, we will have the condition to check for 200 followers instead of 50,000 followers.

Before I knew about Azure Logic Apps, I thought it would take a few weeks to learn about, develop, test, and deploy such a solution. Obviously...

Integrating Logic Apps with serverless functions

In the previous recipe, you learned how to integrate different connectors using Logic Apps and developed a simple logic of checking whether the followers count is greater than 200. As it was a simple logic, you were able to implement that in Logic Apps itself. If you need to implement a complex logic, then it wouldn't be possible. In that case, you can implement the complex logic in Azure Functions and invoke Azure Functions from Logic Apps.

In this recipe, you will see how to integrate Azure Functions with Logic Apps. For the sake of simplicity, we will not develop a complex logic. However, we will use the same logic (followersCount > 200) in Azure Functions and invoke it from Logic Apps.

How to do it...

In this section, we'll integrate Azure Functions with Logic Apps by performing the following steps:

  1. Create a new function by choosing the HTTP trigger with Authorization Level as Anonymous, and name it...

Auditing Cosmos DB data using change feed triggers

You may have already heard about Cosmos DB, as it has become very popular and many organizations are using it because of the features it provides.

In this recipe, you will learn to integrate serverless Azure Functions with a serverless NoSQL database in Cosmos DB. You can read more about Cosmos DB at https://docs.microsoft.com/azure/cosmos-db/introduction.

It might often be necessary to keep the change logs of fields, attributes, items, and other aspects for auditing purposes. In the world of relational databases, you might have seen developers using triggers or stored procedures to implement this kind of auditing functionality, where you write code to store data in a separate audit table.

In this recipe, you'll learn how easy it is to audit the changes made to Cosmos DB containers by writing a simple function that gets triggered whenever there is a change to an item in a Cosmos DB container.

Note

In the world of...

Integrating Azure Functions with Data Factory pipelines

In many enterprise applications, the need to work with data is definitely there, especially when there are a variety of heterogeneous data sources. In such cases, we need to identify tools that help us to extract the raw data, transform it, and then load the processed data into other persistent media to generate reports.

Azure assists organizations in carrying out the preceding scenarios by using a service called Azure Data Factory (ADF).

Azure Data Factory is another cloud-native serverless solution from Microsoft Azure. ADF can be used as an Extract, Transform, and Load (ETL) tool to process the data from various data sources, transform it, and load the processed data into a wide variety of data destinations. Before we start working with the recipe, I would recommend that you learn more about Azure Data Factory and its concepts at https://docs.microsoft.com/azure/data-factory/introduction.

When we have complex processing...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Azure Serverless Computing Cookbook. - Third Edition
Published in: Jun 2020Publisher: PacktISBN-13: 9781800206601
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Praveen Kumar Sreeram

Praveen Kumar Sreeram is an author, Microsoft Certified Trainer, and certified Azure Solutions Architect. He has over 15 years of experience in the field of development, analysis, design, and the delivery of applications of various technologies. His projects range from custom web development using ASP.NET and MVC to building mobile apps using the cross-platform Xamarin technology for domains such as insurance, telecom, and wireless expense management. He has been given the Most Valuable Professional award twice by one of the leading social community websites, CSharpCorner, for his contributions to the Microsoft Azure community through his articles. Praveen is highly focused on learning about technology, and blogs about his learning regularly. You can also follow him on Twitter at @PrawinSreeram. Currently, his focus is on analyzing business problems and providing technical solutions for various projects related to Microsoft Azure and .NET Core.
Read more about Praveen Kumar Sreeram