Serverless in Context
Getting the Most From Azure Functions
The course is part of these learning paths
An Introduction to Azure Functions
Serverless Computing has emerged as a capable and low-friction means to execute custom logic in the public cloud. Whether you're using Amazon Lambda, Google Cloud Functions, or Azure Functions, you have a wide variety of target languages, ecosystem integrations, and deployment mechanisms to choose from. All this while leaving the heavy lifting of server provisioning and maintenance to the experts, which gives you plenty of time to focus on your differentiated application functionality.
In this "Introduction to Azure Functions" course, you’ll learn how to build Azure Function applications in the cloud. You'll discover the core feature set of Functions and see how to integrate with a variety of sibling Azure services. You'll explore Function topics like security, monitoring, deployment, and testing best practices. You'll also learn about ideal Functions use cases and the pricing model. Finally, you'll learn about how we've arrived at the serverless computing model, and where serverless is likely to go in the future. By the end of this course, you’ll have a solid foundation to continue exploring Functions on your own, and incorporating Azure Functions capability into your work.
An Introduction to Azure Functions: What You'll Learn
|Lecture||What you'll learn|
|Intro||What to expect from this course|
|Serverless Computing In Context||Understanding what serverless computing is, and how we got here|
|Core Features||A high-level overview of what Azure Functions is, and its basic capabilities|
|Creating Your First Function||A demo of creating your first function in the Azure portal|
|Security||A review of security features in Azure Functions|
|Using API Key Management||A demo of configuring an Azure Function to require API key use|
|HTTP Proxies||A discussion of lightweight HTTP Proxy support|
|Proxying Azure Blob Storage||A demo of using Functions' HTTP Proxy support to front Azure blob storage|
|Triggers and Bindings||Event-based triggering of functions and declarative binding of inputs and outputs|
|Triggering on Queues and Binding to DocumentDB||A demo of Triggering with Azure Queues and Binding Function Output to DocumentDB|
|Testing and Debugging||Tools and techniques for working with Functions during the development cycle|
|Deployment||Options for deploying Azure Function apps into production|
|Deploying From a Local Git Repo||A demo of deploying a complete Azure Function app to the cloud, from a local Git repository|
|Monitoring||Tools for monitoring Azure Functions during dev, test, and release|
|Use Cases||A discussion of ideal use cases for serverless compute and Azure Functions|
|Pricing||A review of how Functions are priced, and a demo of determining price using the Azure Pricing Calculator|
|Serverless in the Future||A short discussion on the future of serverless in the cloud|
|Summary||Course wrap up|
If you have thoughts or suggestions for this course, please contact Cloud Academy at email@example.com.
Okay, so let's take a closer look at the http proxy functionality in Azure Functions.
Now recall we said that you can use proxy capability to abstract not only function URLs, in other words, functions that are triggered via HTTP call, but you can actually proxy any publicly accessible URL, or set of URLs. So, that kind of a really nice feature.
So in order to demonstrate that, I'm going to show you, I have a couple of blobs, in blob storage, which are actually html files, and I've designated these as being publicly accessible. So if I navigate to my blob storage account, I have this web container, I've sort of set this all up ahead of time. Azure Blobs have an interesting capability, or an interesting feature, which is optional, you don't have to use it, you don't get it by default. But I've uploaded two blobs here, which are simple html files, just simply says this is page one or this is page two, accordingly. And these pages, or these blobs, I've designated as being publicly accessible, so I have a URL I can navigate to see these files.
So you can see, if I click on page one and look at the properties, I have this URL here. So if I copy that and then open that up in browser, you can see the URL that I've browsed to here, it corresponds to my blob storage, and this web is the name of my container, and page one is the name of the blob itself. So if I navigate to it, you can see, "This is the first page" and obviously, and unsurprisingly, if I navigate to page two, you see, "This is the second page".
Okay, if we just navigate directly to the pages, you can kind of see what we get. What we want to do is, is we want to use the proxy capability to sort of clean up that URL and allow us to have a kind of level of indirection that we designate whether we want to, through the proxy, we want to navigate to page one or page two.
So in order to make that happen, the first thing I need to do is, at the function app level, I need to enable the support for proxies. So I turn that on here, in the main settings window of the function app itself. So, now I've enabled proxies, now I need to actually create a proxy, so I come down on this left-hand side, and I click on the plus icon, and that gives me this window where I can configure some settings.
The first thing I need to do is specify a name, and we'll call this blob proxy, it can be anything, the name is just something for you to uniquely identify the proxy, you can, obviously have, create multiple proxies, so you just want a name to uniquely identify it. For the route template, this is sort of the URL suffix. This is the part of the URL that for the proxy that will appear after the core DNS name for the function app itself, so I'll use something like, this can be anything, but I'll use something like “/info”. This also supports things like route templates, so if you want to designate, say parts of the URL that you want to forward as arguments to say a function, you can specify route template using the curly brace syntax. But since I'm not proxying functions, I'm just proxying blob storage, I don't need that. I'll specify that I only want to support get calls via HTTP, you can obviously choose whichever one is appropriate, or whichever ones are appropriate for you, or you can say you support them all, if that's what you want to do. The last thing we have to configure is the back-end URL, and this is the URL that the proxy will forward to, once they arrive at the proxy. I'll paste in my URL for my page one in my blob storage. And then I'll create the proxy itself ... Okay.
So I have created my proxy and you can see that I have, now have a URL for my proxy, which is just the name, the DNS name of my function app, and then “whack” whatever my route template is, so in this case it's just info. So if I click on the button here, and I'll copy that template-- or I'll copy that URL. And I'll open that up in a browser. Now it looks like we didn't get it copied. Let's see if I go back here and copy it the old-fashioned way. There we go.
Alright, so we can see that I'm gonna hit the URL for my proxy. You can see, since it's forwarding to the first page, we see that I actually have the first page contents appear here. So, if I change this, just to demonstrate that the proxy actually works, and I'll point to page two, and now I'll go refresh, again I'm still pointed at the URL for my proxy, and if I refresh this page, you can see that now we are pointing at the second page, instead of the first page.
About the Author
Josh Lane is a Microsoft Azure MVP and Azure Trainer and Researcher at Cloud Academy. He’s spent almost twenty years architecting and building enterprise software for companies around the world, in industries as diverse as financial services, insurance, energy, education, and telecom. He loves the challenges that come with designing, building, and running software at scale. Away from the keyboard you'll find him crashing his mountain bike, drumming quasi-rythmically, spending time outdoors with his wife and daughters, or drinking good beer with good friends.