SIMPLE GUIDE ON CREATING A WEBAPP IN AZURE USING CLI.
Published: 2023-06-23 15:07:30

**This article is designed to serve as a guide to setting up a webapp service in Azure using the Command Line Interface (CLI). It will also demonstrate how to scale-up and scale-out in Azure webapp environment**

**Tools required**
1. Install Azure CLI
2. GitHub Account
3. Install Git Bash

Below are the steps:

**STEP 1 LOG INTO AZURE USING CLI**
- 
Open **Windows PowerShell** on your desktop, wait for the **shell prompt** to display.

- Type the command `az login` and hit enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkxluhx8j4g43ax2pecj.PNG)
This will take you to a browser tab for you to choose the Azure account you wish to sign into. Select and click appropriately. 

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

- 
Go back to the **PowerShell**, you will discover a login notification with your Azure account details.

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

**STEP 2 CREATE A RESOURCE GROUP**

- Use this command `az group create --name **group name** --location **region**` to create a **resource group** that will house your applications.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ilccwo46pvusc5cfk32v.PNG)
From the above image, you can clearly see that the resource group has been successfully created.

**STEP 3 CREATE THE APP SERVICE PLAN**

- To do the, you type the following command and hit enter. 
`az appservice plan create --name **plan name** --resource-group **resource group name**` 

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


**STEP 4 CREATE THE WEBAPP**

- Type the command `az webapp create --name **name of your webapp** --resource-group **resource group name** --plan **plan name** ` hit enter. This command will create the webapp on your A
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8i9rsqsxxb75oaba4zb.PNG)zure portal.

**STEP 5 DEPLOYING YOUR WEB APPLICATION**

- Go to your GitHub account and click on the repository that contains your website files (HTML, CSS and JavaScript). 

- Click on *Code* button and copy the URL on display.


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

- Go back to the PowerShell and type the following command 
`az webapp deployment source config --name **webapp name** --resource-group **resource group name** --repo-url **the url you copied from GitHub** --branch **branch of the repo** --manual-integration`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ilcbuwenk5r2yord8rp3.PNG)
The above command will commence the deploying of your web application.

- Go to the Azure portal and view the **App Service plan** and **Web app application**.

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

- Click on the web application icon, to view the overview page.

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

In the overview page, you can see **Default domain**, which is the URL of your website. You can copy it and share it to be used to access your website.

You can also see the **App service plan**, the repository link from GitHub, which is the source of your website content.

You also click on the **Deployment center** in the left side of the **Overview** page, under **Deployment** to view the deployment information.

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

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

You can also view your website using the **Default domain**. Copy it and paste it into your browser.

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

**SCALING UP AND SCALING OUT**

In most cases, after deployment of your web application, you will need to **scale up **before going into production in order to ensure that your application has the required capacity to be highly available and fault tolerant.

On the other hand, if your application is likely to attract very high traffic, it becomes technically imperative that it most have the ability to **scale out** as the need arise.

**Scale up**
Scale-up is done by adding more resources to an existing system to reach a desired state of performance. This involves adding more RAM and storage to an existing machine.

In Azure web application services, we can achieve this by 

- Going to the **App service plan** click on your plan to open the **overview** page, then click on **Scale up (App service plan)** by the left side under **Settings** select your desired capacity from **Production** packages. Then click on the **Select** button.

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

This will take you to the page below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybsy99rcu19k7nebokcq.PNG)
Click **Upgrade** to upgrade to your chosen capacity.


**Scale out**

Scaling out, which is also known as horizontal scaling means to add more resources like servers to your system to spread out the workload across machines, which in turn increases performance and storage capacity.

In **Azure App Services**, we can do this through our **App service plan** by going to the **Overview** page.

- 
Click on **Scale out (App service plan)** 

- Select **Manual**, **Automatic** or **Rule based**

If it is automatic, you select the **Maximum burst** by dragging the ball-shaped selector, till you get your desired 
maximum.

- Click **Save** to effect your changes.

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

With these steps, we have been able to deploy our web application and scaled it to the desired capacity for optimal performance.