Book Image

Serverless computing in Azure with .NET

Book Image

Serverless computing in Azure with .NET

Overview of this book

Serverless architecture allows you to build and run applications and services without having to manage the infrastructure. Many companies have started adopting serverless architecture for their applications to save cost and improve scalability. This book will be your companion in designing Serverless architecture for your applications using the .NET runtime, with Microsoft Azure as the cloud service provider. You will begin by understanding the concepts of Serverless architecture, its advantages and disadvantages. You will then set up the Azure environment and build a basic application using a sample text sentiment evaluation function. From here, you will be shown how to run services in a Serverless environment. We will cover the integration with other Azure and 3rd party services such as Azure Service Bus, as well as configuring dependencies on NuGet libraries, among other topics. After this, you will learn about debugging and testing your Azure functions, and then automating deployment from source control. Securing your application and monitoring its health will follow from there, and then in the final part of the book, you will learn how to Design for High Availability, Disaster Recovery and Scale, as well as how to take advantage of the cloud pay-as-you-go model to design cost-effective services. We will finish off with explaining how azure functions scale up against AWS Lambda, Azure Web Jobs, and Azure Batch compare to other types of compute-on-demand services. Whether you’ve been working with Azure for a while, or you’re just getting started, by the end of the book you will have all the information you need to set up and deploy applications to the Azure Serverless Computing environment.
Table of Contents (23 chapters)
Title Page
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Sharing code between functions


In a C# script-based Function App, adding a new file to one of the functions will not make it available to other functions in the application.

To share code between functions, we will need to do the following two things:

  • Create a folder named Shared at the root level of a Function App, and add shared code files to this folder. The WebJobs SDK (that Azure Functions are based on) watches for any code changes in the Shared folder and makes sure that the changes are picked up by the functions.
  • Create #load directives to the specific location of the shared files in each function that references the shared code.

Note

You can add other folders to the function's watch list by modifying the watchDirectories setting of the WebJobs host here at https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json.

To show an example of the process, we will create a C# script-based version of the ScoreTweet function.

To share code between C# script-based functions in the same Function...