Learn how to create an Azure function that is triggered by an HTTP request.
- [Instructor] With the timer function under our belt, let's take a look at creating an HTTP triggered function. We return to our functions and click new. A set of templates comes up, and we are looking for HTTP trigger C#, which is this one right here. Scroll down on the page to name our function, and we'll take the default name, and we're going to click create.
Notice that it generates a good amount of code for us. It has a task which returns an HTTP response message. Here's our run, which you'll remember is the entry point for these functions, and that takes an HTTP request message, and of course a trace writer. The first thing that it's going to do is log that it's got a request. Then it's going to create the HTTP request, and it's going to return whatever response we get.
In order to test this, we want to come up and click on this symbol, that is, angle bracket slash angle bracket, and that gives us a URL which we can copy, and that copies it to the clipboard. Open up a browser window and drop in the URL we just copied. And notice that it ends in an equal sign.
We're going to add ampersand name equals, and I'll just put in my first name, and that completes the query string. So let's go ahead and hit enter. And you can see that it returned a legitimate HTTP response with the phrase "Hello Jesse." So we know that that function fired and worked appropriately. Let's go back to our functions.
Take the function name, as we did last time. Click on that. Add SCM to bring us back to Kudu. Let's refresh. Go to the logs by going to debug console, Command, LogFiles, Application, Functions, function. Notice we now have two. The one that we want this time is HttpTriggerCSharp1.
We can download that log file, open that up in its folder. Here's our latest. Double click on that, and now we can show that in fact, the HTTP trigger processed the request and completed with a success code indicating that our entire round trip worked successfully.
- Examining and personalizing the Azure portal
- Creating an app service
- Creating an ASP.NET application with Visual Studio
- Viewing your published app
- Creating a virtual machine
- Triggering Azure functions