Microsoft Azure Functions are a gift to Tech Startups

Akshay Sura - Partner

19 Aug 2020


Transcript

Note: The following is the transcription of the video produced by an automated transcription system.

Hey guys, this is Akshay Sura, today, we’ll be looking at Azure functions. Azure functions or is something I started working on recently and I’m just basically amazed at how much work you can do nowadays on using Azure functions on Azure. The infrastructure is great. I remember back in the day when Azure started, I wasn’t too impressed with it compared to AWS at that time. But, you know, Rome wasn’t built in a day right. So, over the years, they’ve constantly improved. They’ve added more functionality and it’s just purely amazing. Like all technologies, you go through periods of frustration, but most of it comes with the lack of knowledge. And this Azure function stuff is fairly well documented on Microsoft, it’s also in the odd case of you running into an issue where, you know, you’re stuck, you find the occasional blog which resolves that issue. So, again, props to Microsoft for sure. So Azure Functions, they’re interesting in the way you can build them. You just quickly went through a couple of different scenarios where you can chain them together. You base it on basically, they’re based on events. So, if something falls in a queue, you can trigger an azure function an HTTP request could trigger. Now, as your function schedule tasks several other ways of triggering these azure functions. Each is a small piece of code and you want to keep it typically small. So, imagine, you know, if you’re having a recursion of a thousand items, you don’t want to write the code for the thousand items processing in one piece of code.

You split it up into maybe like a loop iterating through and then the actual functionality, which is common for all those thousand items and in different pieces of functions in the same exact way you try to put messages in the queue with the proper message that triggers a function. You do a piece of work and the piece of work is tiny. It just gets done and then you don’t have to worry about it. And again, if we on ZipComply, we run probably Azure Functions a good 30 to 50 thousand times a day with the current traffic we have, and we have no issues at this moment in time. Our daily infrastructure cost is about less than seven dollars. So, this is just purely amazing. And this is also like a startup dream, to be honest. We were thinking about how exactly do we build something. Serverless, which works which scales and traditional ways of using dot net to come up with, you know, in ASP.NET MVC application, doing the same exact thing would cost a lot more to host, to be very honest. So, we’re really, really happy. There’s different consumption plans for azure functions and azure stuff in general. But depending on your needs, you subscribe to what fits your, you know, situation he best. Documentation, like I mentioned, fairly well documented docs.Microsoft.com. Really rarely do you have to go into different areas other than the documentation website to find more things.

So, let’s talk about triggers, so triggers, you know, by definition are something which start they trigger, and they run a piece of functionality, every trigger has a bit of data associated with it. So, the payload contains information on what exactly you need to do, either to save this specific thing in a queue or this is the trigger. The queue just fired. This is the message. So different ways of using triggers, bindings, there’s input output, bindings.They let you bind resources to what you’re trying to call at this moment in time. So, for instance, a queue is something you would bind in order for you to get the message out of the queue. If you are using table storage, you would probably want to have a binding to be able to store in the table storage for HTTP trigger to different bindings. So, based on the bindings you require, it’s just a different way of thinking in terms of how exactly you want to structure it. Once you get into it, you start realizing, oh my gosh, you know, if you’re someone you do at your functions, you figure out that you could break it out into different, different ways. There’s no one answer to every situation. Right. So, for ZipComply, we have a gazillion queues triggering things and putting it inside messages, inside other queues.

And we have a lot of HTTP secure endpoints pulling in data from all of these content websites. Again, development is fairly simple. You know, once you get into it, it’s all .NET core based. I use see sharp for it. You can use python or PowerShell certainly. Up to you, .NET Core is based on three one for the Azure functions three. We have a couple which are based on node which run off of a Linux container in Docker because we use puppeteer and chromium in order to pull a lot of information about a website. Just today I saw a note on Twitter that it’s now part of the Linux base functions on Azure, which is amazing, so that even the tiny bit of cost for us having a docker container with Debian running on it is something which we can get rid of with this new version. And its constantly new things coming up, new abilities inside of Azure functions. So, I cannot sing enough praises about Azure functions. So next, we’ll take a look at how to build an Azure Function. We’ll build your first Azure Function. It’s super easy. You don’t even need an Azure subscription to locally run it and test it. Of course, not all types of bindings, but binding such as an HTTP binding is something really easy. Sorry HTTP function as well as a queue-based functions are really easy to run locally to test out. I just use Azure storage explorer locally, make sure it’s set up and then, you know, you can basically run your application. So, let’s take a look at that.

So, make sure you have the C sharp extension enabled on in Visual Studio Code and also you azure functions extension. Once those two are installed, we can go ahead and hit the Azure functions icon on the left, create a new project, select a folder and select the language which is C sharp, followed by what type, which is HTTP Trigger. We’ll give it a name. And then select the namespace. Select that it’s anonymous and added to the workspace, so once you have that, you’re pretty much set at this point, you know, press F5 it might give you some notification to install some silly stuff, but just make sure that your set-location is not set on your Windows terminal or your PowerShell, because if that’s in your profile, then you’ll run into issues. So, once you run it, it’s fairly straightforward. Similar to Visual Studio, you’ll get a new URL which is based off of localhost port. If you run this in another browser, which I’m going, which I’m doing in my other monitor, and you’ll see output here where it’s actually executing that function. Let me bring that window in here and I’ll re-execute it again. And you can see that it’s actually processing that request so that there you go. That’s your first, um, Azure Function.

Thanks again for joining us. Follow us on LinkedIn and Twitter. You can reach us using the common social channels. We hope to bring you more informative videos shortly as we are ramping up and producing a lot more of these videos. So, I hope you enjoyed it.

If you have any questions, please get in touch with me. @akshaysura13 on twitter or on Slack.

Follow us on Twitter Follow us on LinkedIn Follow us on YouTube

Sign up to our newsletter

Share on social media

Akshay Sura

Akshay is a nine-time Sitecore MVP and a two-time Kontent.ai. In addition to his work as a solution architect, Akshay is also one of the founders of SUGCON North America 2015, SUGCON India 2018 & 2019, Unofficial Sitecore Training, and Sitecore Slack.

Akshay founded and continues to run the Sitecore Hackathon. As one of the founding partners of Konabos Consulting, Akshay will continue to work with clients to lead projects and mentor their existing teams.


Subscribe to newsletter