How to Deploy React App using Azure Static Web Apps ?
Last Updated :
04 Jan, 2025
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.
Prerequisites:
Approach
To deploy a React app using Azure Static Web Apps, build your app, push the code to GitHub, and create a new Static Web App in Azure. Configure deployment settings, connect GitHub, and Azure will handle automatic builds and deployments.
Steps to Deploy React App using Azure Static Web Apps
Step 1: Install Nodejs and Verify
Install Node.js. You can skip this step, if already installed.
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
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.
- "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.
- 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 localhostStep 4: Set Up GitHub
Create a GitHub repository to store the react application
Step 5: Update Project to GitHub Repo
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
Note: Make sure you have installed and authorized it on your PC.
Step 6: Login to Azure
Open Microsoft Azure Static Web App. Sign in with your login credential.
- Search for " static web app " in the search bar of the azure home page.
Step 7: Create a Static Web App
Project Details
- Select subscription.
- Create a new or select an existing resource group.
- Enter the name of your application.
- Select plan and region.
Deployment Details
- Select the repository source. In this case, GitHub is a source.
- Sign in with your GitHub account
- Select the Organization, Repository, and Branch of your React app.
Build details
- Select React for Build Presets.
- Leave the rest of the things default.
Click Review + create
- Verify the summary and click create.
- Wait for the app to be deployed.
Step 8: Navigate to GitHub repository Actions
- Click Actions.
- Wait until the progress completion.
Step 9: Deploy to Azure
- Come back to the Azure Static Web App Deployment page.
- Click Go to resource on the deployment page.
Step 10: Verify the Output
Click on the URL and check the working condition.
How to Deploy React App using Azure Static Web Apps ?
Similar Reads
Microsoft Azure - Deploy a Static Web App This is a new offer in the app service family called static web apps. Static web apps is a tailored offer designed for static web apps full stack javascript web apps with static front-ends and optional dynamic back-ends powered by serverless APIs in our case implemented with azure functions. Static
3 min read
Deploying Your Web App using Azure App Service Pre-requisite: Introduction to Microsoft Azure | A cloud computing service The majority of Computer Science students start with Web Development or Machine Learning. Now after learning how to create a website, we should learn to deploy it online. By deploying our website, we can share it with others,
4 min read
Deploying Your Web App using Azure App Service Pre-requisite: Introduction to Microsoft Azure | A cloud computing service The majority of Computer Science students start with Web Development or Machine Learning. Now after learning how to create a website, we should learn to deploy it online. By deploying our website, we can share it with others,
4 min read
How to Add Express to React App using Gulp ? When building a web application with ReactJS, you may need to include a backend server for handling server-side logic and API requests. Express is a popular choice for creating backend servers in Node.js. In this tutorial, we'll explore how to integrate Express with a React app using Gulp as the bui
3 min read
How to Add Express to React App using Gulp ? When building a web application with ReactJS, you may need to include a backend server for handling server-side logic and API requests. Express is a popular choice for creating backend servers in Node.js. In this tutorial, we'll explore how to integrate Express with a React app using Gulp as the bui
3 min read
Microsoft Azure - Cloning Web Apps using Azure App Services In this article, we will look into the process of cloning web apps in Azure App Services. If you have an existing application in Azure App Services that you like to have copied over into another region, one option you have is to simply clone it. Follow the below steps to clone and Azure App to anoth
2 min read