O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Azure Serverless Computing Cookbook - Second Edition

Book Description

Over 50 practical recipes that will help you develop and deliver high-quality and reliable cloud-centric Azure serverless applications for your organization

Key Features

  • Leverage practical use cases to build a robust serverless environment
  • Enhance Azure Functions with continuous deployment using Visual Studio Team Services
  • Deploy and manage cost-effective and highly available serverless applications using Azure Functions

Book Description

Microsoft provides a solution for easily running small segments of code in the cloud with Azure Functions. The second edition of Azure Serverless Computing Cookbook starts with intermediate-level recipes on serverless computing along with some use cases demonstrating the benefits and key features of Azure Functions. You'll explore the core aspects of Azure Functions, such as the services it provides, how you can develop and write Azure Functions, and how to monitor and troubleshoot them.

As you make your way through the chapters, you'll get practical recipes on integrating DevOps with Azure Functions, and providing continuous integration and continuous deployment with Azure DevOps. This book also provides hands-on, step-by-step tutorials based on real-world serverless use cases to guide you through configuring and setting up your serverless environments with ease. You will also learn how to build solutions for complex, real-world, workflow-based scenarios quickly and with minimal code using Durable Functions. In the concluding chapters, you will ensure enterprise-level security within your serverless environment. The most common tips and tricks that you need to be aware of when working with Azure Functions on production environments will also be covered in this book.

By the end of this book, you will have all the skills required for working with serverless code architecture, providing continuous delivery to your users.

What you will learn

  • Integrate Azure Functions with other Azure services
  • Understand cloud application development using Azure Functions
  • Employ durable functions for developing reliable and durable serverless applications
  • Use SendGrid and Twilio services
  • Explore code reusability and refactoring in Azure Functions
  • Configure serverless applications in a production environment

Who this book is for

If you are a cloud administrator, architect, or developer who wants to build scalable systems and deploy serverless applications with Azure Functions, then the Azure Serverless Computing Cookbook is for you. Hands-on experience with Microsoft Azure core services is required.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Azure Serverless Computing Cookbook Second Edition
  3. Dedication
  4. About Packt
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  7. Developing Cloud Applications Using Function Triggers and Bindings
    1. Introduction
    2. Building a backend Web API using HTTP triggers
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    3. Persisting employee details using Azure Storage table output bindings
      1. Getting ready
      2. How to do it...
      3. How it works...
        1. Understanding storage connection
        2. What is the Azure Table storage service?
        3. Partition key and row key
      4. There's more...
    4. Saving the profile images to Queues using Queue output bindings
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Storing the image in Azure Blob Storage
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  8. Working with Notifications Using the SendGrid and Twilio Services
    1. Introduction
    2. Sending an email notification to the administrator of a website using the SendGrid service
      1. Getting ready
        1. Creating a SendGrid account
        2. Generating an API key from the SendGrid portal
        3. Configuring the SendGrid API key with the Azure Function app
      2. How to do it...
        1. Create Storage Queue binding to the HTTP Trigger
        2. Create Queue Trigger to process the message of the HTTP Trigger
        3. Create SendGrid output binding to the Queue Trigger
      3. How it works...
      4. There's more
    3. Sending an email notification dynamically to the end user
      1. Getting ready
      2. How to do it...
        1. Accept the new email Parameter in the RegisterUser function
        2. Retrieve the UserProfile information in the SendNotifications trigger
      3. How it works...
      4. There's more...
    4. Implementing email logging in Azure Blob Storage
      1. How to do it...
      2. How it works...
    5. Modifying the email content to include an attachment
      1. Getting ready
      2. How to do it...
        1. Customizing the log file name using IBinder interface
        2. Adding an attachment to the email
    6. Sending an SMS notification to the end user using the Twilio service
      1. Getting ready
      2. How to do it...
      3. How it works...
  9. Seamless Integration of Azure Functions with Azure Services
    1. Introduction
    2. Using Cognitive Services to locate faces in images
      1. Getting ready
        1. Creating a new Computer Vision API account
        2. Configuring application settings
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Azure SQL Database interactions using Azure Functions
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Monitoring tweets using Logic Apps and notifying users when a popular user tweets
      1. Getting ready
      2. How to do it...
        1. Creating a new Logic App
        2. Designing the Logic App with Twitter and Gmail connectors
        3. Testing the Logic App functionality
      3. How it works...
    5. Integrating Logic Apps with serverless functions
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    6. Auditing Cosmos DB data using change feed triggers
      1. Getting ready
        1. Creating a new Cosmos DB account
        2. Creating a new Cosmos DB collection
      2. How to do it...
      3. How it works...
      4. There's more...
  10. Understanding the Integrated Developer Experience of Visual Studio Tools
    1. Introduction
    2. Creating a function app using Visual Studio 2017
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Debugging C# Azure Functions on a local staged environment using Visual Studio 2017
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Connecting to the Azure Storage cloud from the local Visual Studio environment
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Deploying the Azure Function app to Azure Cloud using Visual Studio
      1. How to do it...
      2. There's more...
    6. Debugging a live C# Azure Function, hosted on the Microsoft Azure Cloud environment, using Visual Studio
      1. Getting ready
      2. How to do it...
    7. Deploying Azure Functions in a container
      1. Getting ready
        1. Creating an ACR
      2. How to do it...
      3. Creating a Docker image for the function app
      4. Pushing the Docker image to the ACR
      5. Creating a new function app with Docker
      6. How it works...
  11. Exploring Testing Tools for the Validation of Azure Functions
    1. Introduction
    2. Testing Azure Functions
      1. Getting ready
      2. How to do it...
        1. Testing HTTP triggers using Postman
        2. Testing a Blob trigger using Microsoft Storage Explorer
        3. Testing the Queue trigger using the Azure Management portal
      3. There's more...
    3. Testing an Azure Function on a staged environment using deployment slots
      1. How to do it...
      2. There's more...
    4. Load testing Azure Functions using Azure DevOps 
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    5. Creating and testing Azure Functions locally using Azure CLI tools
      1. Getting ready
      2. How to do it...
    6. Testing and validating Azure Function responsiveness using Application Insights
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Developing unit tests for Azure Functions with HTTP triggers
      1. Getting ready
      2. How to do it...
  12. Monitoring and Troubleshooting Azure Serverless Services
    1. Introduction
    2. Troubleshooting your Azure Functions
      1. How to do it...
        1. Viewing real-time application logs
        2. Diagnosing the entire function app
      2. There's more...
    3. Integrating Azure Functions with Application Insights
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Monitoring your Azure Functions
      1. How to do it...
      2. How it works...
    5. Pushing custom telemetry details to Application Insights Analytics
      1. Getting ready
      2. How to do it...
        1. Creating an Application Insights function
        2. Configuring access keys
        3. Integrating and testing an Application Insights query
        4. Configuring the custom derived metric report
      3. How it works...
    6. Sending application telemetry details via email
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Integrating real-time Application Insights monitoring data with Power BI using Azure Functions
      1. Getting ready
      2. How to do it...
        1. Configuring Power BI with a dashboard, a dataset, and the push URI
        2. Creating an Azure Application Insights real-time Power BI – C# function
      3. How it works...
      4. There's more...
  13. Developing Reliable Serverless Applications Using Durable Functions
    1. Introduction
    2. Configuring Durable Functions in the Azure Management portal
      1. Getting ready
      2. How to do it...
      3. There's more...
    3. Creating a Durable Function hello world app
      1. Getting ready
      2. How to do it...
        1. Creating an HttpStart function in the Orchestrator client
        2. Creating the Orchestrator function
        3. Creating an activity function
      3. How it works...
      4. There's more...
    4. Testing and troubleshooting Durable Functions
      1. Getting ready
      2. How to do it...
    5. Implementing multithreaded reliable applications using Durable Functions
      1. Getting ready
      2. How to do it...
        1. Creating the Orchestrator function
        2. Creating a GetAllCustomers activity function 
        3. Creating a CreateBARCodeImagesPerCustomer activity function
      3. How it works...
      4. There's more...
  14. Bulk Import of Data Using Azure Durable Functions and Cosmos DB
    1. Introduction
      1. Business problem
      2. Durable serverless way of implementing an Excel import
    2. Uploading employee data into Blob Storage
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Creating a Blob trigger
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Creating the Durable Orchestrator and triggering it for each Excel import
      1. How to do it...
      2. How it works...
      3. There's more...
    5. Reading Excel data using activity functions
      1. Getting ready
      2. How to do it...
        1. Read data from Blob Storage
        2. Read Excel data from the stream
        3. Create the activity function
      3. There's more...
    6. Auto-scaling Cosmos DB throughput
      1. Getting ready
      2. How to do it...
      3. There's more...
    7. Bulk inserting data into Cosmos DB
      1. How to do it...
      2. There's more...
  15. Implementing Best Practices for Azure Functions
    1. Adding multiple messages to a queue using the IAsyncCollector function
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    2. Implementing defensive applications using Azure Functions and queue triggers
      1. Getting ready
      2. How to do it...
        1. CreateQueueMessage – C# console application
        2. Developing the Azure Function – queue trigger
        3. Running tests using the console application
      3. How it works...
      4. There's more...
    3. Handling massive ingress using Event Hubs for IoT and other similar scenarios
      1. Getting ready
      2. How to do it...
        1. Creating an Azure Function event hub trigger 
        2. Developing a console application that simulates IoT data 
    4. Avoiding cold starts by warming the app at regular intervals
      1. Getting ready
      2. How to do it...
        1. Creating an HTTP trigger
        2. Creating a timer trigger
      3. There's more...
      4. See also
    5. Enabling authorization for function apps
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Controlling access to Azure Functions using function keys
      1. How to do it...
        1. Configuring the function key for each application
        2. Configuring one host key for all the functions in a single function app
      2. There's more...
    7. Securing Azure Functions using Azure Active Directory
      1. Getting ready
      2. How to do it...
        1. Configuring Azure AD to the function app
        2. Registering the client app in Azure AD
        3. Granting the client app access to the backend app 
        4. Testing the authentication functionality using a JWT token
    8. Configuring throttling of Azure Functions using API Management
      1. Getting ready
      2. How to do it...
        1. Integrating Azure Functions with API Management
        2. Configuring request throttling using inbound policies
        3. Testing the rate limit inbound policy configuration
      3. How it works...
    9. Securely accessing SQL Database from Azure Functions using Managed Service Identity
      1. Getting ready
      2. How to do it...
        1. Creating a function app using Visual Studio 2017 with V1 runtime
        2. Creating a Logical SQL Server and a SQL Database
        3. Enabling the managed service identity
          1. Retrieving Managed Service Identity information
          2. Allowing SQL Server access to the new Managed Identity Service
          3. Executing the HTTP trigger and testing
      3. There's more...
      4. See also
    10. Shared code across Azure Functions using class libraries
      1. How to do it...
      2. How it works...
      3. There's more...
    11. Using strongly typed classes in Azure Functions
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  16. Configuring of Serverless Applications in the Production Environment
    1. Introduction
    2. Deploying Azure Functions using the Run From Package
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Deploying Azure Function using ARM templates
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Configuring custom domain to Azure Functions
      1. Getting ready
      2. How to do it...
        1. Configuring function app with an existing domain
    5. Techniques to access Application Settings
      1. Getting ready
      2. How to do it...
        1. Accessing Application Settings and connection strings in the Azure Function code
        2. Application setting – binding expressions 
    6. Creating and generating open API specifications using Swagger
      1. Getting ready
      2. How to do it...
    7. Breaking down large APIs into small subsets of APIs using proxies
      1. Getting ready
      2. How to do it...
        1. Creating microservices
        2. Creating the gateway proxies
        3. Testing the proxy URLs
      3. There's more...
      4. See also
    8. Moving configuration items from one environment to another using resources
      1. Getting ready
      2. How to do it...
  17. Implementing and Deploying Continuous Integration Using Azure DevOps
    1. Introduction
      1. Prerequisites
    2. Continuous integration – creating a build definition
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Continuous integration – queuing a build and triggering it manually
      1. Getting ready
      2. How to do it...
    4. Configuring and triggering an automated build
      1. How to do it...
      2. How it works...
      3. There's more...
    5. Continuous integration – executing unit test cases in the pipeline
      1. How to do it..
      2. There's more...
    6. Creating a release definition
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Triggering the release automatically
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think