DEV Community

Cover image for Deploying A Web App Using Azure CLI
Wisdom Iyayinosa Bezaleel
Wisdom Iyayinosa Bezaleel

Posted on

Deploying A Web App Using Azure CLI

On this blog, i will show you how to deploy a web app using Azure CLI. I am also going to create deployment slots for our Web Application within the Azure App Service. I will be doing most of my creations on the powershell rather than Azure portal

Prerequisite

  • Have powershell installed on your computer
  • Have your web app repository in your GitHub

Lets get started... Join me
We are going to login to Azure portal, first open powershell on your pc, the image below shows the icon.
Image description

And input this command: az login and click enter

Image description
You should get a prompt to login to azure portal, correctly input your details and sign in

Image description
If your login was successful, you would get as message telling you that you have logged into microsoft Azure.

Image description

Go back to powershell, and you should also get a command proving you have logged in
Image description

The next step is to create your resource group that will house your web service plan and your web app.
Input this code to create your RG

az group create --name (name your resource) --location (input the location you want your resource to be)

Do well to not make mistakes in inputting of your code, press enter.
Image description

The next step is to create our service plan, the service plan will serve as an operating system for the web app. So input this command

az appservice plan create --name --resource-group

and click enter
Image description
Now that our app service plan has been successfully created, we will now go ahead to create our web app. input this command and click enter
az webapp create --name --resource-group --plan

Image description

Now we are going to import our HTTPS URL of our web app repository from GitHub. If you have not created your web app repository, locate my article on web app repository
Now lets head to our GitHub account to get the URL
Navigate to the right on your Web App repository page and right click on the green Code button. Copy the HTTPS link as shown in the image below

Image description
Ensure your repository is accessible by putting it in public and not private. Now that you have copied your URL, input the following command

az webapp deployment source config --name --resource-group --repo-url --branch master --manual-integration

Image description
We have successfully deployed our web app. You can go-to Azure portal, and from the app-service section, you will be able to view the deployed resource.
Image description
Click on your web app to see the overview, and from the overview, you will be able to access your domain.
Image description
Click on your default-domain to view the html.index file
Image description
To view our Deployment, click on the "Deployment Center", we can also the link to our repository and the master branch.

Image description
You can also view your commit message on the Logs

Image description
Now lets go ahead to create deployment slot. A deployment slot is a test version of your web app to see if it qualifies for deployment. In a situation where a version of your web app is already running, you can release a new version without users experiencing a down time.
To create a deployment slot, go to your web app, navigate to 'deployment slot', you will notice our deployment is in deployment state, and running traffic is 100%. To add slot, click "add slot'

Image description
Give your slot a name, and select add

Image description

Input the percentage of traffic you want to give your deployment slot, save it.
You can also have an overview of the deployment slot by clicking the name
Image description
If you click the overview, you will notice the new deployment has a new environment where you can configure it, without it affecting the already running resource.

Image description
Now we are going to return traffic back to production. Follow the steps on the images below
Click on "SWAP"

Image description
Go ahead and swap.
Image description
Image description

So our web App has been updated without tampering with the production environment.

Top comments (0)