Thursday, November 28, 2024
Google search engine
HomeLanguagesHow to Deploy React App using Azure Static Web Apps ?

How to Deploy React App using Azure Static Web Apps ?

Microsoft Azure is a public cloud computing platform. It provides a lot of cloud services to access, manage, and deploy applications. Where as Azure Static Web App is one of the services of Microsoft Azure. It automatically builds and deploys full-stack web apps from the code repository to azure.

In this article, we will learn how to deploy React app in Azure Static Web Apps.

Steps to Deploy React App using Azure Static Web Apps

Requirements:

  1. GitHub Account
  2. Microsoft Azure account
  3. Node.js
  4. create-react-app package

Step 1: Install Node.js. You can skip this step, if already installed.

node --version
Node version

 

Step 2: Install create-react-app. Run the following command to install the create-react-app package globally on your PC. You can skip this step, if already installed.

npm install -g create-react-app
install create-react-app

 

Step 3: Create React application

  • Open the terminal in the folder where you want to create React app.
  • Run the following commands one by one to create react app.
create-react-app react-app-static-web-app
cd react-app-static-web-app
npm start
  • Here “react-app-static-web-app” is the name of our react application.
create react application

 

  • cd react-app-static-web-app” will navigate the terminal to the newly created “react-app-static-web-app” folder.
  • The “npm start” command will start the local server.
Start localhost

 

  • Now, the React app is running at http://localhost:3000/
  • Copy and paste the link in the browser to open the React app.

Running on localhost

Step 4: Create a GitHub repository to store the react application

Create GitHub repository

 

Step 5: Commit local files to the GitHub repository

  • Run the following commands to commit files to your GitHub repository.
  • Note: Replace <replace with repo> with your repository.
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/<replace with repo>.git
git push -u origin main
Upload to GitHub

 

Note: Make sure you have installed and authorized it on your PC.

Step 6: Open Microsoft Azure Static Web App. Sign in with your login credential.

Microsoft Azure home page

 

  • Search for ” static web app ” in the search bar of the azure home page.
Search static web app

 

Create Static Web App

 

Step 7: Create a Static Web App

  • Project Details
  1. Select subscription.
  2. Create a new or select an existing resource group.
  3. Enter the name of your application.
  4. Select plan and region.
Project Details

 

  • Deployment Details
  1. Select the repository source. In this case, GitHub is a source.
  2. Sign in with your GitHub account
  3. Select the Organization, Repository, and Branch of your React app.
Deployment details

 

  • Build details
  1. Select React for Build Presets.
  2. Leave the rest of the things default.
Build details

 

  • Click Review + create.
  1. Verify the summary and click create.
  2. Wait for the app to be deployed.
Static Web App deployment

 

Step 8: Navigate to the GitHub repository

  • Click Actions.
  • Wait until the progress completion.
GitHub Actions

 

Step 9: Return back to azure

  • Come back to the Azure Static Web App Deployment page.
  • Click Go to resource on the deployment page.
Static Web App Resource

 

Step 10: Explore the URL (output)

Click on the URL and check the working condition.

Output

 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments