In this section, we'll deploy our first function to the public cloud, and learn how to call it. We'll be going live with our Azure Function, starting to create our serverless architecture. And to ensure that it happens correctly, we'll need a function project and a valid Azure subscription. Let's begin by implementing the following steps:
- Right-click on your project and select Publish.... Now select Azure Function App | Create New as shown in the following screenshot:
- Enter a memorable name and create a resource group and a consumption app service plan to match the following:
- Click on the Publish button to publish your function.
- Open a browser, navigate to http://portal.azure.com, and find your function. You can use the search bar and search the name of your function. Click on your Function App, then click on the function name. Click the Get function URL in the upper-right corner paste the address of your function into Postman, and test it. Please bear in mind that if you have a paid subscription, these executions will cost a small amount of money—you are only charged for the compute resources that you actually use. On a free account, you get a million executions for free.
Outcome
You now have a fully deployed and working Azure Function in the cloud.
Anyone can execute your function if they can work out the address, which is why the security we discussed previously is a good idea to implement. We will further discuss the optimal way to employ security for a large enterprise using Azure Active Directory in the next chapter.
The old way of deploying Azure Functions allowed you to edit the C# code in the portal, but all of those sections will come up as read-only. For proper development, you should rarely even interact with the portal; everything is possible in Visual Studio with the Cloud Explorer.
You can remote debug Azure Functions using the Cloud Explorer. Click View Menu | Cloud Explorer and log in to your Azure account. Find your function under App Services. Select the function in the Cloud Explorer, and click Attach Debugger.