Reader small image

You're reading from  Hands-On Azure for Developers

Product typeBook
Published inNov 2018
PublisherPackt
ISBN-139781789340624
Edition1st Edition
Tools
Right arrow
Author (1)
Kamil Mrzygłód
Kamil Mrzygłód
author image
Kamil Mrzygłód

Kamil Mrzygłód is a technical lead and technology advisor, working with multiple companies on designing and implementing Azure-based systems and platforms. He's a former Microsoft Azure Microsoft Most Valuable Professional (MVP) and certified trainer, who shares his knowledge via various channels, including conference speeches and open source projects and contributions. Kamil lives in Poland with his two cats and one dog, dedicating some of his time to video games, cooking, and traveling.
Read more about Kamil Mrzygłód

Right arrow

Serverless and Azure Functions

Azure Functions are the main product of serverless architecture in Azure. They allow for executing small pieces of code within fully managed runtime, so we don't have to care about performance and scalability. They are open source, open for extensions, and built on top of App Services, so they provide a similar experience to WebJobs. Microsoft pays much attention to developing new features for Azure Functions and, with great support from the community, it's one of the best tools for quickly developing both simple and serious applications.

The following topics will be covered in this chapter:

  • Understanding Azure Functions
  • Configuring local environment for developing Azure Functions
  • Creating a function
  • Azure Functions features
  • Workflow in Azure Functions—Durable Functions
  • Integrating functions with other services
...

Technical requirements

To start using Azure Functions and to perform the exercises in this chapter, you will need the following:

  • Visual Studio 2017 with Azure workload installed
  • Azure Functions and the WebJobs tools extension for Visual Studio

Understanding Azure Functions

Azure Functions are a part of so-called serverless components that are available in the Azure cloud. Before you start learning about this particular service, you will have to understand what serverless really means. While, initially, you may think that this concept implies no servers at all, you will quickly re-evaluate your way of thinking (as, we are still quite far away from not using any kind of machine for our applications and workloads).

Being "serverless"

You can easily find many different articles describing the term serverless—to be honest, I would like to avoid promoting a one and only correct definition, as this topic is currently so fuzzy, it is hard to find the best...

Configuring the local environment for developing Azure Functions

To get started with Azure Functions, we will need an environment that will allow us to test our functions and start developing them quickly and seamlessly. Fortunately, this particular Azure service comes with multiple tools that help us during programming and running them locally. I will describe some extra applications as well, which should help you analyze and debug possible problems and test triggers before deploying to the cloud.

Starting with Azure Functions locally

If you have installed all of the required software mentioned at the beginning of this chapter, you should be able to start developing them without any additional configuration. To get started...

Creating a function

We discussed the overall serverless approach and went through local configuration to make sure that we have some basic understanding of what Azure Functions are and how we can start working with them. In the following of this chapter, I will show you what exactly this service offers and how to work with it on daily basis. This will help you start developing full projects with Functions—from the simplest to the most advanced ones.

Using Visual Studio

In the previous section, you created a function using a wizard in Visual Studio. If you go back to this particular project and open its file, you will see some common code, which is always created with this particular template. Here, you can find the...

Azure Functions features

Azure Functions is not only about providing executable code, which will be handled by the runtime. It allows for even more advanced scenarios, which make this service an excellent choice when you want to start developing quickly and with minimal configuration required. In this section, I will show you how to leverage more advanced features of functions and how to progress with your skill in using this Azure component.

Platform features

As you may remember, Azure Functions is built on top App Service, which allows you to use multiple already known features, such as Custom domains, Application settings, and Authentication/Authorization. To access all available Platform features, go to your function app...

Workflow in Azure Functions – Durable Functions

In most cases, the best idea for working with functions is to keep them stateless. This makes things much easier as you do not have to worry about sharing resources and storing state. However, there are cases where you will like to access it and distribute between different instances of your functions. In such scenarios (such as orchestrating a workflow or scheduling a task to be done), a better option to start with would be to leverage the capabilities of Durable Functions, an extension to the main runtime, which changes the way you work a little bit.

It changes the way Azure Functions works as it lets you resume from where the execution was paused or stopped and introduces the possibility to take the output of one function and pass it as input. We will not cover this in detail, as this book is not only about Azure Functions...

Integrating functions with other services

In the last part of this chapter, we will focus a little bit on understanding how Azure Functions integrate with other Azure services. We will take a look at the available triggers and bindings and try to figure out the best use cases for them and how they really work. This section is designed in a way that enables you to explore more by yourself, thanks to a common understanding of how Azure Functions work.

Function file

When you take a look at your bin directory, where compiled functions are available, you will find a bit of a different structure than in traditional applications.

Here, you can find my folder from the exercise from this chapter:

As you can see, it contains the Function1...

Summary

In this chapter, you have learned a lot about Azure Functions and how to work with this serverless component. You read about the differences in pricing models, scalability concerns, and basic triggers and bindings. We worked on some simple scenarios regarding monitoring, deploying, and developing this Azure service.

In the following chapters in this book, you will learn even more about serverless services. We will then come back to work even more with functions, as this is one of the most popular Azure components that can be easily integrated with other tools and products.

Questions

  1. What is the difference between App Service and the consumption pricing model?
  2. What is GB/s?
  3. Can you create stateful services with Azure Functions?
  4. What is the name of a container that's used for functions?
  5. Can you use Python in Azure Functions?
  1. Can a binding act both as a trigger and output? Can you provide an example?
  2. Why is a function app mode sometimes set as read-only?
  3. Can you use the Application Settings feature in the same way as in App Services?
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Azure for Developers
Published in: Nov 2018Publisher: PacktISBN-13: 9781789340624
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 AU $19.99/month. Cancel anytime

Author (1)

author image
Kamil Mrzygłód

Kamil Mrzygłód is a technical lead and technology advisor, working with multiple companies on designing and implementing Azure-based systems and platforms. He's a former Microsoft Azure Microsoft Most Valuable Professional (MVP) and certified trainer, who shares his knowledge via various channels, including conference speeches and open source projects and contributions. Kamil lives in Poland with his two cats and one dog, dedicating some of his time to video games, cooking, and traveling.
Read more about Kamil Mrzygłód