Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You have a working Azure Node.js web application and the source code is managed in a Git repository. The goal of the this tutorial is to automate the deployment of a Node.js web applications to Azure Web App.  This  This automation will include:

  • cloning the Node.js from a Git repository

  • package the Application Setting/Connection String properties file

  • update relevant Application Setting and Connection String properties in Azure Web App

  • deploying the Node.js web application source code archive to Azure Web App

  • make sure build and deployment of Node.js application happens in Azure Web App backend itself

  • retrieve the deployment log(optional) against the deployment executed

We will walk through each of the FlexDeploy features that will be created/configured to accomplish this goal and have the Node.js web application deployed in a very short amount of time.

Checklist

Checklist

Description

Azure Tenant Id

Azure Tenant Id for the company

Azure Subscription Id

Azure Subscription where the Web App exists

Azure Client ID

Client ID to connect to desired Azure Subscription

Azure Client Key

Password for the Client ID

Azure Client ID permission

The Client ID must have relevant access in target Web App to deploy code

Azure Web App

The Web App with relevant runtime should already be created

Azure Resource Group

The Resource Group containing the Web App

Azure CLI installation

Azure CLI needs to be installed where the plugin operation shall run (FlexDeploy server)

Azure CLI in class path

Azure CLI should be added to class path on the FlexDeploy Server. Else the path can also be set under FlexDeploy environment level property

Configure

...

Cloud Account

First, an Azureaccount needs to be configured under Topology. FlexDeploy will connect to the right Azure Subscription with provided details and do the deployment.

...

It should have a Client ID, Client Key, Tenant Id, and Subscription Id configured in it. The Client ID must have relevant access in the target Web App to deploy code and make other associated changes(Application Setting update etc).

...

  1. Client Key is a password field and hence needs to be kept hidden. To update the same click on the pencil icon as shown below

  2. Update the Client Key value under Secret Text. This is to make sure no one else can retrieve the password

...

Git repository structure

...

Git Repository Structure

The Git repository should contain the codebase. Alongside it can also contain any Application Setting and Connection String-related attributes in respective files(any naming convention allowed). These files are not mandatory, however, in case someone has any Application Setting and Connection String property to update this is recommended. Please review the Application Setting and Connection String property update for a detailed explanation.

The Sample Git repository structure is given below.

...

Build and Deploy Workflows

...

Workflows

...

Next, create one Build and Deploy workflow as shown below. The workflow Type field defines the type of workflow.

Build Workflow

  1. Navigate to the Workflows tab

  2. Select the “+” button from the left-hand pane to create a new workflow with type as Build.

...

Deploy Workflow

  1. navigate to the Workflows tab

  2. Select the “+” button from the left-hand pane to create a new workflow with type as Deploy.

...

The Workflow Group and Subgroup define the folder hierarchy. Once both workflows are created it should look like the below. No constraint on workflow or folder naming convention.

...

The steps of the workflow execution can be configured through the Definition section.

...

Navigate to Workflows and create a build and a deploy workflow using the (blue star) button as highlighted below.

...

Build Workflow

Below is a sample build workflow to build a Node.js Source code archive and create an artifact from it.

...

Note: the deployWebApp operation(Azure plugin) will search for the Application Setting and Connection String file name provided as part of Project properties. Irrespective of folder structure it will find the file. In case more than one file exists with the same name, flow shall the workflow will fail.

Deploy Workflow

Below given is a sample deployment workflow to deploy the archive to Azure Web App.

...

First, navigate to the Workflow Definition tab and click on the Create/View Input button as shown belowopen the Inputs popup.

...

Create two input variables, one each for Application Setting and Connection String as shown below.

...

The deployWebApp operation returns four output variables. To capture them and use them for further processing/evaluation, one can create four variables and map them against the output parameters. Return As Output drop down option should be set as Yeschecked.

  1. First, navigate to the Workflow Definition tab and click on open the X2 Variables buttonpopup

  2. Next use Create option to add four output variables.

...

Map the variables against the output of the deployWebApp operation to capture the responses.

...

Project

...

Configuration

Navigate to the Project tab and create a Project with a logical name (NodeJsAzureWebApp in this case)

...

Selecting the GREEN circle for DEV will display the configurable properties/Endpoint and allows for the configuration of

Properties

Mandatory Field

Description

Web Slot Name

 

Target slot for deployment

Target Slot to swap

Optional

In case slot swap is required

Azure Cloud Account

 

Azure account with relevant details

Absolute path of Azure CLI

Optional

Not required if Azure CLI already added to workflow execution m/c class path

GIT Path

Optional

Path to the Git executable. Required only if git is not on class path.

Below given are the environment-specific values which need to be updated.

...