Azure Functions

Walkthrough of a Created Azure Function

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

Demo: A look around the generated code for an Azure function, and purposes of each file.

Keywords

  • function.json
  • function proxy
  • deployment slots
  • azure function

About this video

Author(s)
Sahil Malik
First online
31 March 2019
DOI
https://doi.org/10.1007/978-1-4842-4104-2_12
Online ISBN
978-1-4842-4104-2
Publisher
Apress
Copyright information
© Sahil Malik 2019

Video Transcript

In a few minutes, you should see the following things appear inside of your all resources area, just make sure you have these drop-downs not filtering anything out that you wish to see. Now let’s hide this side, so I have some more area to work with and click on the Azure function that you just created.

You should see a user interface that looks something like this, here I can choose to add a function, proxys or slots. Slots is related to deployment, so the idea being that you have something in production and you create another something that is not production that you can test and then you can slot in what you’ve just tested into production and therefore that becomes production. So, this is a concept they have carried over from app service, so this is how we deploy websites etc. so same concept is coming over to functions as well. Functions is where we define APIs. We are going to define a function very soon. Proxys basically allows you to breakup a large API into multiple function apps like micro services architecture and you can still present a single API surface for clients.

So, let’s go ahead and create a function, so click on this create_new button and I’m going to go with JavaScript, I will choose to go with webhook timer. Remember that you can scroll down here and you can choose to create a custom function as well, but I will show that you can change this definition later on as well. So, let’s just click on create this function and it creates a simple function for me. There is a context.log, it says this function process the request and it says body: “hello world” and it expects an input and the input being the name or you know request or query.name or request or body.name, so either in the query string or in the body, you know you need to specify a name and it’ll just say hello whatever name you pass in that you pass in, it will return a http//400 and it will give you an error saying you need to pass in the name or the query string or the body. How is all this stitched together? Let’s open this here, where we say view files and let’s open function.json, so here you see that there is a binding in which we have a type called httpTrigger, okay, so basically this function is being called on http and the direction in type in and you know so it’s got some of these bindings and parameters associated with it. Let’s click on this test tab here as well and here it’s showing you how to test this particular function. So you are saying you can do a post method or a get method, so this guy gets disabled and you can add various query strings etc. and this is typically how you can go about testing this function.