How to Host a Website in Azure

In today's digital age, having an online presence is crucial. Whether you're a developer, business owner, or hobbyist, deploying a website is a great way to showcase your work or ideas. Microsoft Azure offers a robust and flexible platform for hosting websites, making it an ideal choice for many. In this complete tutorial guide, we'll walk you through the steps to host and deploy a website on Azure.

Prerequisites:

Before we get started, ensure you have the following:

  • Microsoft Azure Account
  • Website Files

Steps:

To host a website on Azure, you need to follow these steps. Every step is very important, so be careful.

Create a Virtual Machine

A Virtual Machine (VM) in Azure is an on-demand, scalable computing resource offered by Microsoft Azure. It allows you to run applications and workloads without the need to purchase and maintain physical hardware. In simple terms, it is a computer located in a remote location that we can control. All of our website files will be in this computer so that everyone on the internet can access our website.

Host Website in Azure
Host Website in Azure

  1. Open Azure portal
  2. Go to the search bar and type "Virtual Machines".
  3. Click Create.
  4. Choose "Azure Virtual Machine".

Now you have to specify the configuration of the virtual machine:

  1. Choose a billing subscription from the dropdown.
  2. Resource group: create a new resource group (with a unique name).
  3. Add Virtual Machine Name.
  4. Choose any region that is close to you.
  5. Availability Options: No Infrastructure Redundancy required.
  6. Security type: Standard.
  7. Image: It is the Operating System. For this tutorial, we are using Ubuntu 20.04 LTS.
  8. VM Architecture: Any.
  9. Size: This is the CPU and RAM specification of the computer. Microsoft provides lots of different sizes of VMs. To know more about the Virtual Machine Size, read this. Keep it as default.
  10. Authentication type: Choose Password.
  11. Now create a username and password. Remember it, as it will be used later.
  12. Select inbound rules: Tick every rule (SSH, HTTP, HTTPS).
  13. Now click on Review + Create.
  14. Click on Create. It will take some time to start the Virtual Machine, usually 3-5 minutes.

Again, search for Virtual Machine in the search bar. Now you will find a virtual machine listed. Select it. In the Overview tab, you will find the public address. But if you just put this in a browser, it will not work, because it is just a remote computer. To host or deploy a website, we must need a server. In this tutorial, we are using Nginx.

Now to install the server in the Ubuntu Virtual Machine, first we need to connect our machine with the VM. As we created the username during the creation of the VM, we will use it now.

Open PowerShell or any other terminal.

Write this command:

ssh username@public-address

Login with the password.

Now you are connected to your VM. As we just ran the VM, run this command to update your VM.

sudo apt update

Install Nginx:

sudo apt install nginx

After installing Nginx, open the public IP address in the browser, and you will see a sample default webpage being displayed.

nginx default page

Now go to the /var/www/html/ directory. This is the directory where server files are located. In order to host your site, you need website files. I am using Git to download the files to my VM. For an example, I am using a simple HTML, CSS, and JS site. You can use this repository for learning and practice purposes.

Go to the html directory of Nginx.

Run the command:

sudo git clone https://github.com/subhadipbhowmik/chandigarh-university-calculator.git

Video Tutorial:

If you need Detailed Video Documentation then my Video on the same can help you during hosting your website.

It will download all the files of the website that you want to host. Now to access your site, use ip-address/chandigarh-university-calculator. This is how the site will look like.

CU Calculator
Chandigarh University Calculator website

In this way, you can host any kind of website on Microsoft Azure. Congratulations for successfully hosting your website on Microsoft Azure.

Shubhadip Bhowmik

I am a B.C.A student at Chandigarh University, with a passion for technology. I am an Android and Frontend Web Developer. I write blogs, design UI/Mockups, and Contributing to open-source projects. youtube github linkedin emailm

Post a Comment (0)
Previous Post Next Post