How To Host Static Website on Azure Blob Storage
Tags: azure, beginners, cloud, devchallenge
Published: 2024-07-09 00:28:51


## introduction
A static website is like an electronic brochure that contains fixed information and doesn't change frequently. It consists of web pages that have text, images, and other content that remains the same for everyone who gains access to the website.

An example of such websites are cloud courses like whiz lab or cantril.io

By hosting a static website on Blob Storage, you can save costs and enjoy a straight forward hosting solution that ensures your website is easily accessible and efficient.

In this tutorial, we will be hosting our static website in Azure Storage. Please ensure the following prerequisites are followed before we begin.
Prerequisites.

## Virtual Studio code
1.Install Visual Studio Code on your desktop.

2.Install the Azure Subscription, Azure Account and Azure storage account extensions on the visual studio code.

3.Create a storage account in the Azure portal

4.Create a folder that houses your static website data
Enable Static Website in Azure.

##  Enable static website hosting

a) Go to your storage account, and click on the Static website button on the left side of the search bar.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhyy63plfi0jwa2db4x0.png)

b)Click on the "Enabled" button to enable the static website

c)On the index document name type "index.html" and the Error document path type "404.html"

d) Click on the save button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qkrfht1pd3unrucxhht.png)

e)Once it's saved, It generates your primary and secondary endpoint.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gnngtwt4naxlowyhsyvp.png)

d) When you go back to your storage account, click on containers, you can see that a web container has been created to host your static website data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71gm2ago7p1jf394s9dc.png)

Open Your File On Visual Studio Code

a)The next step is to click on File at the top-left corner of your VScode.

b) Click on "Open File" and select the folder that houses your static website codes and data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/touiczr2odpol2qjyk45.png)

c)Once you open it, the file appears here as shown below.

d) Click on your file drop-down and click index.html


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0z4ljunnfjl4f5j5zjx.PNG)

e) Once you click it, your html code automatically reflects as shown below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0r7y0ejengfya6bbdrl.png)

## Connect To Azure

a) To connect to your $web container, click on the Azure extension.

b) Next click on the Resources drop-down, click on the Azure subscription drop-down.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4m2dzchkh1m2z80f7585.png)

c) Under the Azure subscription, click on the storage account drop-down

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mg2lk6io1ujd03l7tzug.png)
d)You will see the storage account you created in the Azure Portal, right-click on it.

e) Click on "Deploy to the static website via Azure Storage"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47ih317987xjtks2njs0.jpg)

f) You will be prompted to select your folder to deploy the static website.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvrr0pkqksr74kdqi1zp.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdt7v7cok1dc2yub8eod.png)

g) Wait for the deployment to be complete and click on browse static website

h) You will be redirected to your static website as shown below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ao2k3u6iej0vvo4cjes2.PNG)

i) On the Azure portal, go to the $web container in your storage account, you can see that all your static website data has been deployed in the container.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5oqwcad52qbf0js8zews.PNG)