web,

ARM for NodeJS Azure Web App with App Configuration Integration

Sven Malvik Sven Malvik Connect Jun 13, 2020 · 2 mins read
ARM for NodeJS Azure Web App with App Configuration Integration

Our Azure infrastructure has some configurations that our developers need to know like the name of the currently active AKS cluster and APIM instance. We store these configurations in an Azure App Configuration instance and expose them as an API through an Azure App Service Web App that is written in NodeJS. This post shows how we provision the NodeJS Web App with an ARM template.

We can provision the App Service Plan and App Service from the portal, and then setup deployment of a GitHub repository for the NodeJS application. But I wanted it to be 100% automated without setting up anything, so I decided to try ARM templates.

The ARM template explained

An ARM templates contains of 4 sections, parameters, variables, resources, and outputs. We will focus on only two of them. parameters and resources.

In parameters I defined a name for the site, a connectionString for the App Configuration Service, a repositoryUrl of the NodeJS application, and a branchName of the application that I want to deploy.

In the resources section, I defined 4 resources. an App Service Plan that has the type Microsoft.Web/serverfarms, an App Service with type Microsoft.Web/sites, a configuration for the App Service with type Microsoft.Web/sites/config, and the hostname binding so we can reach the web app with type Microsoft.Web/sites/hostNameBindings.

App Service Plan

You get one free App Service Plan with SKU B1 for one month and subscription, at least for now. If you automate the provisioning of the entire setup as described in this post, you could trigger it with an Azure Runbook if you want.

App Service

The App Service depends on the App Service Plan. In ARM we can define this dependency that has to exist with dependOn. This example is a simplification and http only. You shouldn’t run this in production.

This App Service section also describes 2 resources, sourcecontrols where I defined the GitHub repository, and config where I store the connectionString for Azure App Configuration. Since I chose type Custom for my connectionString, I can access the value from my NodeJS application with the prefix key CUSTOMCONNSTR_. The fully key would be CUSTOMCONNSTR_AppConfigConnString. The connectionString is stored as an environment variable that my NodeJS application can access with process.env.CUSTOMCONNSTR_AppConfigConnString.

App Service Configuration and hostname binding

In these resource, we configure our App Service. I exported these resources directly from the portal and made a few changes like the scmType which is in my case GitHub.

NodeJS Application

The NodeJS application is in a separate GitHib repository that uses the azure/app-configuration module. Every commit to the branch that you defined when deploying the ARM template will deploy a new version and restart the application.

Conclusion

This ARM template will deploy App Service Plan, App Service, and deploy the NodeJS application.

az deployment group create --name "YOUR_WEBAPP" --resource-group "YOUR_RG" --template-file PATH_TO_YOUR_ARM_TEMPLATE
Join Newsletter
Get the latest updates right in your inbox. I never spam!
Sven Malvik
Written by Sven Malvik

Latest Stories

Event-Driven Infrastructure with App Configuration

Azure App Configuration is great for externalizing application configurations. But what if an application is our infrastructure? How coul...

Sep 12, 2020

Azure App Configuration Introduction

We build this great application that we configure exactly the way it fits into our environments, and then we realize that changing a conf...

May 09, 2020

Using App Configuration in Azure DevOps

Application deployments dependent often on environment specific data like the name of a resource group, location or flags for certain use...

Aug 01, 2020

Azure App Configuration Introduction #3

After playing around with Azure App Configuration Service and how to read a configuration entry with REST, and then using feature flags i...

May 23, 2020

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

Microsoft updated it’s role based exam for AZ-300. It’s now called AZ-303 and launched last year. This certification is a great proof for...

Feb 01, 2021

Introduction to Azure API Management

Azure API Management (APIM) is a way to create consistent and modern API gateways for existing backend services. It provides an interface...

Jan 25, 2021

Using Feature Flags with Azure App Configuration

Sometimes we would like to test a new feature of an application. Or we would like to disable code junks because they are not fully implem...

May 16, 2020

Introduction to Farmer - IaC with Azure

As many companies move their services to the cloud, the way we interact with the cloud, the tooling, becomes more important. In Azure we ...

Sep 26, 2020

Sync Azure App Configuration with GitHub Actions

One questions we might ask us when we move our properties files from an application to Azure App Configuration is how we can do this with...

Sep 05, 2020

How to Secure Azure Functions App with Azure API Management

How to use an Azure Managed Identity to authenticate against an Azure Functions app that is exposed through Azure API Management. Our Fun...

Feb 02, 2021

Parameters in Farmer - IaC with Azure

This is part 2 of my learning adventure of Farmer for Azure resource deployments. This time, I wanted to look at parameters, variables, o...

Oct 10, 2020

Latest Stories

Event-Driven Infrastructure with App Configuration

Event-Driven Infrastructure with App Configuration

Azure App Configuration is great for externalizing application configurations. But what if an application is our infrastructure? How coul...

Sep 12, 2020

Azure App Configuration Introduction

Azure App Configuration Introduction

We build this great application that we configure exactly the way it fits into our environments, and then we realize that changing a conf...

May 09, 2020

Using App Configuration in Azure DevOps

Using App Configuration in Azure DevOps

Application deployments dependent often on environment specific data like the name of a resource group, location or flags for certain use...

Aug 01, 2020

Azure App Configuration Introduction #3

Azure App Configuration Introduction #3

After playing around with Azure App Configuration Service and how to read a configuration entry with REST, and then using feature flags i...

May 23, 2020

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

Microsoft updated it’s role based exam for AZ-300. It’s now called AZ-303 and launched last year. This certification is a great proof for...

Feb 01, 2021

Introduction to Azure API Management

Introduction to Azure API Management

Azure API Management (APIM) is a way to create consistent and modern API gateways for existing backend services. It provides an interface...

Jan 25, 2021

Using Feature Flags with Azure App Configuration

Using Feature Flags with Azure App Configuration

Sometimes we would like to test a new feature of an application. Or we would like to disable code junks because they are not fully implem...

May 16, 2020

Introduction to Farmer - IaC with Azure

Introduction to Farmer - IaC with Azure

As many companies move their services to the cloud, the way we interact with the cloud, the tooling, becomes more important. In Azure we ...

Sep 26, 2020

Sync Azure App Configuration with GitHub Actions

Sync Azure App Configuration with GitHub Actions

One questions we might ask us when we move our properties files from an application to Azure App Configuration is how we can do this with...

Sep 05, 2020

How to Secure Azure Functions App with Azure API Management

How to Secure Azure Functions App with Azure API Management

How to use an Azure Managed Identity to authenticate against an Azure Functions app that is exposed through Azure API Management. Our Fun...

Feb 02, 2021

Parameters in Farmer - IaC with Azure

Parameters in Farmer - IaC with Azure

This is part 2 of my learning adventure of Farmer for Azure resource deployments. This time, I wanted to look at parameters, variables, o...

Oct 10, 2020