Advanced Scenarios in Azure Functions

Development and Debugging Experience

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This video segment demonstrates debugging Azure functions in VSCode.

Keywords

  • Azure
  • Azure Functions
  • Visual Studio Code
  • VSCode

About this video

Author(s)
Sahil Malik
First online
20 December 2019
DOI
https://doi.org/10.1007/978-1-4842-4408-1_9
Online ISBN
978-1-4842-4408-1
Publisher
Apress
Copyright information
© Sahil Malik 2019

Video Transcript

Sahil Malik: Let’s talk about the development and debugging experience using VSCode for Azure Functions. So this is what a typical generated Azure Function code project looks like in VSCode. I just generated this, now let’s look at the development and debugging experience. Development is fairly straightforward. I can choose to add more functions here as I wish. This function app can contain more than one function. I can go here, I can click this button to add more functions. Just feel free to play with that. I’m not going to do that because that’s fairly straightforward. Also in this here, I don’t quite have intellisense because this is not TypeScript, it doesn’t have a .d.ts file, but I get some level of intellisense, whatever VSCode can understand. For instance, it sees a property here called req.query, so when I type req., so you see that it understands some of these things. It’s just trying to guess and help me out. So if you did write a .d.ts file here, then you’d get proper intellisense here as well. It doesn’t generate that out of the box for you.

For the function.json file, it gives me some basic intellisense as you see over here. So you can play with that. Similarly in the other JSON files, so proxies.json, it’s attached to a schema. So here it’ll give me some sort of intellisense here as well. So I can go about write this code but where it gets really interesting is when I wish to be able to debug this. So what I can do now is that I can set a breakpoint here. Go to the debug menu and just click on start debugging or just hit F5. Note that I have a breakpoint here, so please keep that in mind. And the steps that I’m showing will work with both C# and they will work with JavaScript. When you’re using C#, obviously you’ll need to have .NET Core installed. In fact, as you see here that even though I am writing everything in JavaScript, you saw that there was a little bit of .NET Core scrolling by there. You need .NET Core installed for this extension to work anyway.

So here we go. It went ahead and started this HttpTrigger over here. This font can be fixed in the settings of VSCode but it’s legible so I’ll leave that as is because it’s technically not part of Azure Functions. Now I can go ahead and hit control click to follow this link. Let’s click on that. And as you see over here that now I’m in debug mode and I can hit F10 or I can step over like this and I can basically debug this as I feel. Hit continue and basically these results come out here. The debugger is still attached and I can see the results come out here.

Okay, now the important point to take home over here is that everything running here is not running on Azure. It is running on my local machine. So I can completely debug this, build this function, complicated logic right here on my local machine. I don’t even need to put this in Azure. When I’m ready to deploy it is when we start worrying about the next step which is the deployment experience. When you’re done debugging, hit this button here and now you’re not debugging anymore.