• Pratik Golchha

Deploy to Cloud in 5 mins!

Updated: Jun 28

Deploy your Node.js application in cloud



In this article we will see how we can deploy basic Node.js application in the Cloud. We have used Azure as our Cloud service provider.


Prerequisites

1) Need Azure Subscription. To create free account click here.

2) Node.js

3) Visual Studio Code

4) Git


Steps to create a Node.js website


1) Open VSCode and open the terminal.

2) Run below command in the terminal.

 	Git clone https://github.com/DevCompost/Azure.git

3) Move to the Azure folder.

4) Run npm start, Website is now available on 8080 port.


Once we are able to run the application locally. Lets deploy the changes to Azure portal. For this we need an Azure subscription. You can use the free account. Login on Azure portal and Follow the below steps:


1) We need to create an Azure Web app from the Azure Portal. First Click on Create a resource, then search for web app. Then fill the details in web app form Like Resource Group, WebApp Name and Plan.

Resource Group -> Its a logical group of resources. WebApp is an Azure resource. We can add multiple azure resources in the resource group.

Plan -> Its Azure Service plan on which Azure resource runs. Plan rates differs as per the machine configuration.





2) One the Azure Web app resource is created. Navigate to the web app created.

3) Click on Cloud Shell icon. Its present in the header.


4) You can use Bash/Powershell terminal. In this article we have used PowerShell terminal.

5) For deploying our website, we need a deployment user name and password. Run below command to create the deployment user.

az webapp deployment user set --user-name <<username>> --password <<password>>

6) Once user is create, then create the deployment url for the web app. Run the below command to get the deployment url. Provide the appname and resource group. Command return the deployment url. Keep this url handy.

az webapp deployment source config-local-git --name <<app-name>> --resource-group <<group-name>>

7) Now go to your VSCode and open the terminal again. Run the below command. Provide the dpeloyment url got from the previous command.

git remote add azure <deployment-url>

8) Now push your changes to master branch. It will ask for the deployment credentials. Provide the same credentials used in Step 5.




9) It will push the changes and deploy the changes to Azure Web App.


#cloud #azure #100daysofcode #azureappservice #nodejs #webapp #vscode

228 views
SIGN UP AND STAY UPDATED!
  • th_grey
  • Grey Twitter Icon
  • Grey LinkedIn Icon
  • Grey Facebook Icon

© 2020 by DevCompost.

  • th
  • Twitter Social Icon
  • LinkedIn Social Icon
  • Facebook Social Icon