Quick start Node.js web app in Microsoft Azure

Create a Node.js web app using Azure App Service Free tier1 min


We will have a basic Node.js web application that will be downloaded from Github. We will use Azure CLI in this example.

We need to download the application from Github to our computer: https://github.com/Azure-Samples/nodejs-docs-hello-world/archive/master.zip

To start open Azure Portal. Then open Azure Cloud Shell.

If you have not yet set your cloud shell storage, please do. On the Cloud Shell window click “Show advanced settings” then choose “West Europe” then click Create storage

Enter the below to create your resource group named myResourceGroup

> az group create –name myResourceGroup –location “West Europe”

Then we create App Service name myAppServicePlan as Free-tier

> az appservice plan create –name myAppServicePlan –resource-group myResourceGroup –sku FREE

After it finished you should an output like this:

{
“freeOfferExpirationTime”: null,
“geoRegion”: “West Europe”,
“hostingEnvironmentProfile”: null,
“hyperV”: false,
“id”: “/subscriptions/586d9af8-f15a-4e8a-bb9f-de3368a18fc4/resourceGroups/myResourceGroup/providers/Microsoft.Web/serverfarms/myAppServicePlan”,
“isSpot”: false,
“isXenon”: false,
“kind”: “app”,
“location”: “West Europe”,
“maximumElasticWorkerCount”: 1,
“maximumNumberOfWorkers”: 1,
“name”: “myAppServicePlan”,
“numberOfSites”: 0,
“perSiteScaling”: false,
“provisioningState”: “Succeeded”,
“reserved”: false,
“resourceGroup”: “myResourceGroup”,
“sku”: {
“capabilities”: null,
“capacity”: 0,
“family”: “F”,
“locations”: null,
“name”: “F1”,
“size”: “F1”,
“skuCapacity”: null,
“tier”: “Free”
},
“spotExpirationTime”: null,
“status”: “Ready”,
“subscription”: “586d9af8-f15a-4e8a-bb9f-de3368a18fc4”,
“tags”: null,
“targetWorkerCount”: 0,
“targetWorkerSizeId”: 0,
“type”: “Microsoft.Web/serverfarms”,
“workerTierName”: null
}

Create a web app

We will create a new app, this should be unique globally, so replace [app_name] with a your unique app name (valid characters are a-z, 0-9, and -)

> az webapp create –resource-group myResourceGroup –plan myAppServicePlan –name [app_name]

A similar json output should appear

{
“availabilityState”: “Normal”,
“clientAffinityEnabled”: true,
“clientCertEnabled”: false,
“clientCertExclusionPaths”: null,
“cloningInfo”: null,
“containerSize”: 0,
“dailyMemoryTimeQuota”: 0,
“defaultHostName”: “hivenewnodejswebapp.azurewebsites.net”,
“enabled”: true,
.
.
.

Run the below command to list supported runtimes for Nodejs. In out example it was “node|10.6”.

> az webapp list-runtimes

Now run the below command to set the runtime, replace with the one you have chosen before

> az webapp config appsettings set –resource-group myResourceGroup –name [app_name] –settings WEBSITE_NODE_DEFAULT_VERSION=10.6

Open your browser and go to, replace with your chosen name

http://[app_name].azurewebsites.net

You should see a web page saying your app service is up and running

Now open the below link then upload by dragging the downloaded Github zip file of the web app

https://[app_name].scm.azurewebsites.net/ZipDeployUI

After the a successulf deployment, refresh the previous page

http://[app_name].azurewebsites.net

Now you have your Node.js web app running.

Clean up resources

> az group delete –name myResourceGroup

Like it? Share with your friends!

Hasan

0 Comments

Your email address will not be published. Required fields are marked *

Choose A Format
Story
Formatted Text with Embeds and Visuals