This is to walk you through the steps to deploy a Node.js sample Forge App to Azure App Service as a Web App with the Azure Web Portal and Git.
For this tutorial, we will be using our ViewHubModels sample as described in previous chapters. You may retrieve the full sample from our Github repo. The same steps should also work for View Models tutorial code.
Before you start, sign in or sign up for Microsoft Azure Computing Platform & Services and create a trial account, it includes $200 credit and free for 12 months
Most steps can be done via Web Portal, but Azure CLI is required.
There are 2 ways to create an app: using the Web Portal and with CLI.
1. Create an app with Web Portal
-
Create a
Resource Groupand aWeb App -
Set the
Runtime StacktoNodeJsand clickCreate -
It may take a while for the app to be created, once all done, navigate to the app to review its settings
2. Create an App with Azure CLI
- Create a
Resource Group(or use existing) and aWeb Appwith commands below:
# login with credentials explicitly or simply use 'azure login' to log in with a browser session or authorisation code
az login -u <username> -p <password>
# Create a Resource Group
az group create --location westus --name myResourceGroup
# Create an App Service Plan in free tier
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE
# Create a Web App
az webapp create --name <nameofyourapp> --plan myAppServicePlan --resource-group myResourceGroupFor this tutorial, we are going with Local Git to deploy our code. This can done using the Web Portal and with CLI
1. Deploy using Web Portal
-
Navigate to the
Deployment Centerto set up deployment settings
-
Click the highlighted button on right top to open the Azure CLI, run
az webapp deployment user set --user-name $username --password $passwordto configure deployment credentials and record the resulting Git url
-
Set up the environment variables with your Forge App credentials (
FORGE_CLIENT_IDandFORGE_CLIENT_SECRET) and the callback url (following patternhttp://<nameofyourapp>.azurewebsites.net/api/forge/callback/oauth)
2. Deploy using CLI
# Set the account-level deployment credentials
az webapp deployment user set --user-name $username --password $password
# Configure local Git and get deployment URL
echo $(az webapp deployment source config-local-git --name <nameofyourapp> --resource-group <nameofyourresourcegroup> --query url --output tsv)
# Set up the environment variables
az webapp config appsettings set -g MyResourceGroup -n <nameofyourapp> --settings FORGE_CLIENT_ID=<yourForgeAppClientID> FORGE_CLIENT_SECRET=<yourForgeAppSecret> FORGE_CLIENT_SECRET=<yourForgeAppSecret> FORGE_CALLBACK_URL=<yourCallbackURL>- Push your local repo to your Azure Web App with Git CLI or your favorite Git client
# Add the Azure remote to your local Git respository and push your code
cd /path/to/local/repo
git remote add azure <giturlofyourapp>
git push azure master # use 'git push azure <nameofyourbranch>:master' if you would like to push other local branches than masterThe app dashboard should look like:
Done! Open the app url to see our app in action.
3. Other Deployment Options
Watch this screencast demonstrating the above steps on the Azure Portal and CLI (the screencast is based on Bash but the commands involved would have been identical on Windows CLI and Powershell. And you can run Bash on Windows! See this or this as part of Git or even try the Linux Subsystem)
- Post deployment automation and testing with Azure Pipelines
- Try out Application Insights, Cost Management, Security Center and many more Azure Cloud tools and features
- What are Resource Groups, Service Plans,Azure Templates and Staging Environment?
- Building Cloud-Native Applications with Node.js and Azure
- Monitor Azure App Service performance
- Using Azure Web Site Logging and Diagnostics
- Pricing - App Service




