How I built and deployed Azure static web app with GitHub
Tags: vscode, azure, staticwebapps, tutorial
Published: 2023-04-21 13:21:20

## Azure Static Web App

![Azure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ayastkpsq30gda7lwus.png)
Azure Static Web Apps is a service that automatically builds and deploys full stack web apps to Azure from a code repository.
### Most popular features 
- Web hosting for static content like HTML, CSS, JavaScript, and images.
- First-class GitHub and Azure DevOps integration that allows repository changes to trigger builds and deployments.
- Generated staging versions powered by pull requests enabling preview versions of your site before publishing.




---
### Prerequisites
- GitHub account
- Install Git
- Azure account
- Visual Studio Code
- Azure Static Web Apps extension for Visual Studio Code

### Create a repository
1. On GitHub.com, navigate to the [static-web-app](https://github.com/Mokhutso-dev/Static-Web-App) repository.
2. In the top-right corner of the page, click Fork.
3. Under "Owner," select the dropdown menu and click an owner for the forked repository.
![fork](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1vqn16o9452z61xqqc5.png)
4. Click Create fork.
![create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90oy673ng2emjuglclsk.png)

### Clone the repository
_With the repository created in your GitHub account, clone the project to your local machine using the following command._

1. Open Command Line or terminal
2. Type `git clone https://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/Static-Web-App.git`     **replace** `<YOUR_GITHUB_ACCOUNT_NAME>`  **with your GitHub username**             
3. Next, open Visual Studio Code and go to File > Open Folder to open the cloned repository in the editor.
![vscode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/djxtyy6w67h37yi9j4bg.png)

---

### Install Azure Static Web Apps extension

1. Select View > Extensions.
2. In the Search Extensions in Marketplace, type Azure Static Web Apps.
3. Select Install for Azure Static Web Apps.
4. The extension installs into Visual Studio Code.
![extension](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12qkignyvzb8bq0lcwgp.png)

---

### Create a static web app

1. Inside Visual Studio Code, select the Azure logo in the Activity Bar to open the Azure extensions window.             
                                                              
     **_The extension will prompts you to sign in to Azure and GitHub in Visual Studio Code to continue. If you are not already authenticated._**
2. Press F1 to open the Visual Studio Code command palette.
3. Enter Create static web app in the command box.
![pallete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swcz53oag74wxy6ptk2i.png)
4. Select Azure Static Web Apps: Create static web app and select Enter. 
![f1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2886873jvtoqe04578ra.png) 
![values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id2ton2qlu2jk5ezapyv.png)
![5_5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7y3sqd0q5e4jaajnzovz.png)
5. Once the app is created, a confirmation notification is shown in Visual Studio Code.
![success](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjt6y5l5ory66n5onmg1.png)      _Once the deployment is complete, you can navigate directly to your website._
6. To view the website in the browser, right-click the project in the Static Web Apps extension, and select Browse Site.
![production](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fgwtsgjwqn8dr2np8je.png)

---

### Azure Portal overview
To view full details about your static web app you just deployed: 
- Go to [Azure portal](https://portal.azure.com/#home)
- Select Static Web Apps
- Select Overview
![overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dyfhsc3m4qwjbhcibgaw.png)

#### Clean up resources
If you're not going to continue to use this application, you can delete the Azure Static Web Apps instance through the extension.

In the Visual Studio Code Explorer window, return to the Resources section and under Static Web Apps, right-click Static-Web-App and select Delete.

![delete_web](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2o7xar68rxj2339fgzg.png)

_Congratulations you have built and deployed your first Azure Static Web App._



Thank you for reading🤝. Feel free to leave your questions and/or comments (if any). [LinkedIn](https://www.linkedin.com/in/mokhutso-manaswe-381623219/)           [Dev.to](https://dev.to/mokhutso-dev)