Creating Microsoft Azure App Service to host a Node.js webhook

Since you successfully tested your locally running Fortune Cookie webhook, you are ready to host the webhook on the Microsoft Azure App Service Node.js server:

  1. Open Command Prompt, type az login, and follow the instructions on the screen.
  2. Once you've logged in, type az account list to view a list of the accounts that you are managing. If you have multiple accounts, you will need to set the account you want to use using az account set --s put-account-id.
  3. Create a resource group using az group create --name HenryResourceGroup --location eastus. Resource group is the logical name given to a container that contains multiple services. For example, let's say you created a resource group called myWebApplication, which contains the web server, the database, the file storage, and the virtual network. You can easily view all of the Microsoft Azure resources used by simply going to the myWebApplication resource group. You can also delete all the resources associated with creating myWebApplication.
  4. Create a Microsoft Azure App Service Plan by using az appservice plan create --name myAppServicePlan --resource-group HenryResourceGroup --sku FREE. Think of an App Service plan as a server cluster that contains the collections of the servers. In your case, you will be creating a collection of Node.js servers that are highly available and redundant.
  5. Create a Node.js web server using
    az webapp create --name henryApp1234 --resource-group HenryResourceGroup --plan myAppServicePlan --runtime"NODE|8.1".
  1. Create a user that you will use to access the FTP site to deploy the code files with az webapp deployment user set --user-name myusername --password mypassword.
  2. Let's view all the resources you have created so far. Log in to the Microsoft Azure portal (https://portal.azure.com).
  3. Click on Resource groups on the right-hand menu and you will be able to see the resource that you just created.

The following image shows the Resource groups:

Resource groups
  1. Click on the HenryResourceGroup and you will see the henryApp1234 Node.js server created using the Azure CLI.

The following image shows the list of resources under HenryResourceGroup:

List of resources in the resource group
  1. Click on henryApp1234henryApp1234 is the Node.js server. 

The following screenshot shows the henryApp1234 Node.js server information:

henryApp1234 Node.js server

Take a note of the following properties:

  1. Open FileZilla and go to File | Site manager.
  2. Add New Site and enter the Host, the username, the password, and select Use explicit FTP over TLS if available.

The following screenshot shows the FTP configuration for connecting to the Node.js server host in Microsoft Azure:

FTP site configuration connecting to Node.js server in Microsoft Azure
  1. Click Connect. You will be deploying three files (web.config, server.js, and package.json) to /site/wwwroot.

The following screenshot shows the deployment of three files to the Node.js server via the FTP file manager:

Deploying Node.js files to Microsoft Azure via FTP
  1. You tested locally by pointing Postman to http://localhost:8000/fortuneCookie. Test with Postman by pointing the URL to https://henryapp1234.azurewebsites.net/fortuneCookie.