Deploying to Azure

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:

  1. Right-click on your project and select Publish.... Now select Azure Function App | Create New as shown in the following screenshot:
If you've signed in to Visual Studio with a Microsoft ID that has an Azure subscription associated with it, then the next screen will be pre-populated with a subscription. If not, then you need to sign in to an account with an associated Azure subscription.
  1. Enter a memorable name and create a resource group and a consumption app service plan to match the following:
  1. Click on the Publish button to publish your function.
  2. 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.

This is not the recommended way to deploy to production. Azure Resource Manager (ARM) templates are the recommended way to deploy to production. ARM templates are JavaScript Object Notation (JSON) files. The resources that you want to deploy are declaratively described within JSON. An ARM template is idempotent, which means it can be run as many times as required, and the output will be the same each and every time. Azure handles the execution and targets the changes that need to be run.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.198.59