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.
And input this command: az login and click enter
You should get a prompt to login to azure portal, correctly input your details and sign in
If your login was successful, you would get as message telling you that you have logged into microsoft Azure.
Go back to powershell, and you should also get a command proving you have logged in
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.
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
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
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
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
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.
Click on your web app to see the overview, and from the overview, you will be able to access your domain.
Click on your default-domain to view the html.index file
To view our Deployment, click on the "Deployment Center", we can also the link to our repository and the master branch.
You can also view your commit message on the Logs
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'
Give your slot a name, and select add
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
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.
Now we are going to return traffic back to production. Follow the steps on the images below
Click on "SWAP"
So our web App has been updated without tampering with the production environment.
Top comments (0)