Creating a function application using Visual Studio 2019
In this recipe, you will learn how to create an Azure function in Visual Studio 2019 with the latest available Azure Functions runtime. You'll also discover how to provide access to anonymous users.
Getting ready
You'll need to download and install the following tools and software:
- Download the latest version of Visual Studio 2019, which can be found here: https://visualstudio.microsoft.com/downloads/
- During the installation, choose Azure development in the Workloads section and then click on the Install button.
How to do it…
In this section, you'll create a function application and a HTTP function using Visual Studio by performing the following steps:
- Open Visual Studio, choose Create a new project, select Azure in the platform dropdown, and then choose the Azure Functions template. Once you are ready, click on Next, as shown in Figure 4.1:
Figure 4.1: Create a new project
- Now, you need to provide a name for the function application. Click on the Create button to go to the next step. As shown in Figure 4.2, choose Azure Functions v3 (.NET Core) from the drop-down menu, then select Http trigger with Anonymous in the Authorization level dropdown, and click on the Create button:
Figure 4.2: Create a new Azure Functions Application
- You have successfully created the Azure Function application, along with an HTTP trigger (which accepts web requests and sends a response to the client), with the name Function1. Feel free to change the default name of the function application, and also be sure to build the application to download the required NuGet packages.
- After you create a new function, a new class will also be created, as shown in Figure 4.3:
Figure 4.3: Azure Functions Solution Explorer
You have now successfully created a new HTTP triggered function application using Visual Studio 2019.
How it works…
As explained earlier, Visual Studio tools for Azure Functions allow developers to use their preferred IDE, which they may have been using for years. Using the tools of Azure Functions, we can use the same set of templates that the Azure Management portal provides in order to quickly create Azure Functions and integrate them with cloud services without writing any (or minimal) plumbing code.
The other advantage of using Visual Studio tools for Functions is that we don't need to have a live Azure subscription. We can debug and test Azure Functions right in our local development environment. The Azure command-line interface (CLI) and related utilities provide us with all the required assistance to execute Azure Functions.
There's more…
One of the most common problems that developers face while developing any application in their local environment is that everything works fine on their local machine but not in the production environment. With Azure Functions, developers need not worry about this dilemma as the Azure Functions runtime provided by the Azure CLI tools is exactly the same as the runtime available on the Azure cloud.
Note
We can always use and trigger an Azure service running on the cloud, even when we are developing Azure Functions locally.
Now that you understand how to create a function application using Visual Studio 2019, in the next recipe, you'll learn about debugging C# Azure Functions.