Skip to main content

Command Palette

Search for a command to run...

How to Deploy React application on Azure virtual machine?

A Step-By-Step Guide

Updated
β€’3 min read
How to Deploy React application on Azure virtual machine?
Y

Welcome to Yatri Cloud Family! 🀝

Let's learn about cloud computing and DevOps.

We break down difficult concepts into understandable language so you can learn them easily and apply them to your projects.

Subscribe now to our YouTube channel. πŸ””

We will provide you with hands-on tutorials for popular cloud platforms like AWS, Azure, GCP and we will cover DevOps tools.

Thanks for be a part of us.❀️

πŸ‘‰ Created by Nensi Ravaliya: Connect Now

Prerequisites:

  • Azure Subscription: Redeem $100 from here: Azure for Students

  • NOTE: There is no need to add Credit/Debit card details here.

  • GitHub Account

Now, we need to connect our virtual machine from our ubuntu/linux operating system via "SSH". So, I am using Ubuntu here.

  1. Make sure that you have your .pem file on the ubuntu machine. example,

2. Now, just open that folder in "Open in Terminal".

3. Secure your .pem file and connect through "ssh".

sudo chmod 400 nodejs-app-key.pem
ssh -i nodejs-app-key.pem azureuser@13.82.3.84

4. Type the commands to update our Virtual Machine.

sudo apt update
sudo apt upgrade -y

5. Now, to run our Node.js web application we need to install Node.js and npm.

sudo apt update
sudo apt install nodejs
node -v
sudo apt install npm
npm -v
sudo apt update
sudo apt upgrade
sudo snap refresh

6. As we know, the React web application is always running on nodejs version greater than 12.22.9 but as of now, we have version 12.22.9. So we need to update it.

sudo npm cache clean -f
sudo npm install -g n
sudo n latest

If you are facing any issues here, then just close the EC2 connections and re-connect it again. Then check the versions.

7. Now, just reconnect the instance again and check the versions.

node -v
npm -v

8. Now, We have our basic React Web application on the GitHub Repository: Click Here

We will clone it from the GitHub repository by using "git clone".

ls
git clone https://github.com/Nency-Ravaliya/my-react-app
cd my-react-app
ls

sudo npm install
sudo npm start

After executing "sudo npm install" you will see "node_modules".

After executing "sudo npm start" you will see this kind of interface.

9. Now, Our Application is not running currently because we didn't provide any Port configuration to allow traffic to port "3000". So let's do it fast.

Click on "Network setting" and then select "inbound port rule" and add "3000".

10. Your React web application is running now.

πŸ‘‰ Subscribe Now❀️

πŸ‘‰ Connect with the Creators

πŸ‘‰ Join Our Exclusive Community

πŸ‘‰ Follow us on Social Media

Thank You for Reading!❀️