Create a v2 Azure Functions project in Visual Studio 2017. Add the extension for Table storage to be able to use the Table binding in the function.
- [Instructor] As we start to look at Azure functions, I'm going to go ahead and clean up all of these windows from my previous solution. And we're going to create a new project in Visual Studio for our function. Now if I go into Tools, Extensions and Updates, you'll see this Azure Functions and Web Jobs Tools, this got installed when we installed Visual Studio and chose the Azure Workload, but you may want to check and see whether it's automatically updating and if not, you want to update to the latest version.
Now I'll go to my solution and add a new project. Going to look for the Azure Functions project, so I'll go under C# in Cloud, and there's my functions. So I'll call this FunctionApp our HPlusFunctions, we'll add that in. And now we get to choose a couple of things. First, we get to choose the runtime version of the framework that function runs on. First one runs on the full .NET Framework, version two runs on .Net Standard.
I'm going to go ahead and pick that, cause that's the way things are going and that's where I'm going to want to focus my attention. I'm going to choose an Http trigger, so this is going to be the mechanism by which our function gets started. It will be an Http Post. You can see that I have other options here, to monitor our Queue, or a Blob store or Service Bus, as well as being able to run on a schedule or a timer. The other piece that functions need is a storage account or to store some of its logging information.
So if I go to browse here, I can browse my subscription and I can find my Storage Account. So for us, it's going to be our storage under hplussports. And so like that, and the Access Rights I'm going to leave at Function, cause I don't want to allow anonymous access to this, I want this to be able to be invoked by my applications, such as my logic app. There we go, we've got a function now, we got some Json files with settings and we have the core function file.
You'll notice the dependencies aren't quite updated yet, but when we build, they will be. Let's go ahead and rename this, we'll call this our OrderFunction. We'll go ahead and rename the file and we'll also get the string updated for the function name. So everything looks good. You can see that by default, this is set up with a Http Trigger, that's got get and post and it has a Route information which is currently null.
And it's expecting as an input this Http Request and a Log or a TraceWriter. So this is set up to be able to be triggered by Http, it gets an IActionResult in return, so it's very much like a web API or ASP.Net MVC Function. Last thing I'm going to do is go manage the new get packages and you may need to do this as well and check for updates, cause as you can see, there's a slightly newer version of this SDK.
So I'll update to that. You can see we've got some things getting installed and some getting updated, quite a few packages that are backing this up. Accept the license terms and now we've got that updated. And notice we now get a warning that that TraceWriter's obsolete, we should use Ilogger instead, so let's go ahead and fix that.
Ctrl+. to get our suggestions will do the Microsoft Extensions Logging. And now we've got this all set up, Logger's a little bit different. And so, I'm going to get rid of this implementation, cause it's just getting an Http Request and responding. We're going to empty that out so we can do some additional work here. We'll save that and now we've got the framework to be able to add in our implementation for our order getting posted to this, and being able to write to that Azure Table Storage.
And we'll just add one more step here so that this can build. We'll just return a new OkResult, so we get our return type there and we're able to build that project and make sure everything's all set up correctly
- Planning your web app
- Choosing compute, storage, integration, and networking solutions
- Creating the web app and API on Azure
- Creating the Azure Cosmos DB resources used by the app
- Data consumption in the app
- Creating an Azure Functions project
- Building, publishing, and testing Logic Apps
- Packaging resources