DEV Community

joseph4real
joseph4real

Posted on

HOW TO CREATE DEPLOTMENT SLOT AND MAKE A SWAP IN AZURE

Deployment slot is a process where you deploy apps in slots (1,2 and 3) i.e in a different version of the app, in order to test, make changes before deploying the app.
This help to prevent downtime or interruption on the running app when rolling out an update on the app. When you want to carry out an update/upgrade on an app already running, or available to users, which is always in production slot1, in order to prevent downtime or interruption of that app in slot1. The already running app will need to be cloned, edit and updated, deploy to azure and tested, then do a swapped for it to be available to users.

a. Create a deployment slot: go to your web app page, click on deployment slot, you will need to upgrade to standard or premium if your free dev/test is used up,

Image description

b. To upgrade, click on scale up (app service plan) and upgrade to standard under production workload, then click select and upgrade pricing plan. With this you can be able to create slot.

Image description
c. Go back and click deployment slot again, you would see the web app running in production mode, production slot is default slot where your app is running, for users to see and use. So we will need to create another slot for testing and deployment of an update of your web app before being deployed for user to use.

Image description

d. Creating 2nd slot, an instance of the your webapp), click add slot, give a new name (as Staging), choose “clone setting from” i.e. clone your original web app (project10webapp) from production slot1 to the slot2 that we added. From the right the domain URL will change from project10webapp.azurewebsites.net (slot1) to project10webapp-staging.azurewebsites.net (slot2. You then click add.

Image description
e. Below pic showing the staging deployment slot2 just created, has been added). Project10webapp in production slot, the slot users are using,
Project10webapp-staging (newly created slot) the app we need to test before deploying.

Image description
f. URL for the project10webapp in production slot is project10webapp.azurewebsites.net

Image description
URL for the Project10webapp-staging in staging slot project10webapp-staging.azurewebsites.net

Image description
Openning the URLs, show your web app is running, but its waiting for content to be added, as shown

Image description

Adding web content to Azure web apps
g. Use Visual Studio to add Web app code into your azure web apps.. By using publish tool, i.e. deploying code to the azure app service. 1st load web code into Visual Studio by selecting file menu, open, Websites, file system and then Project10WebApp web code.

Image description

Image description

h. Web code from the project file loaded into Visual studio

Image description
i. Right click project10webapp and select publish to the azure web, select Azure and click next, then select select Azure app service and click next.

Image description

Image description

j. Expand the resource-group “AppServiceRG”, and select Project10AppWeb, then click finish,
Publish in progress comes up, after click close.

Image description

Image description

k. Web app being deployed to Azure, after successful deployment, displayed below is the URL, the web app resource group and web app name gotten from the azure web services.

Image description

Image description

l. Click on the URL, and the web app appears as below, this is the web app running in the production skot1.

Image description

m. We then deploy the clone code of production slot1 into staging slot2 by publishing it in the Visual Studio, by edit only the name above to differentiate and save it.

Image description
n. Redeploy (republish in VS) again into azure by selecting staging slot2 as shown below. Click new profile to republish, select azure, azure web service and click next, same as what we did above.
o. Expand the web app service group and select staging slot2, then click finish.

Image description

p. After successful deployment, click on site URL, in the web app, the name would have been modified as shown below.

Image description

q. Click on the URL, and the web app appears as below, this is the web app running in the staging slot2, the bold name we edited from joseph oyewale to jesse miracle has change to Jesse Testimony. NOTE: it shows the test was successful and can be deployed

Image description

SWAP FROM STAGING SLOT2 TO PRODUCTION SLOT1
Swaping the web app (tested app) from staging slot2 (source URL: project10webapp-staging.azurewebsites.net) to production slot1 ( target URL: project10webapp.azurewebsites.net) by using swap tool in deployments tool.

a. Below are URL pictures: showing “Im Joseph Oyewale” is in production slot ( web app running for users to see). Showing “Im Jessy Miracle” is in the staging slot (the web app we are testing, need to be deployed and swapped).

Image description

Image description
b. Click swap button ande then select the source as (project10webapp-staging) staging slot2 the new version of the app that will be swapped into the target as ( project10webapp) production slot1. After click swap.

Image description
c. After success swap, close the window, click on the URL in the production slot1, i.e. https://project10webapp.azurewebsites.net/
Based on the pictures below, the URL of the web app “Project10WebApp” in the production slot1, has successfully swapped the web content project10webapp-staging of staging slot to production slot. The name “JOSEPH OYEWALE” has changed to the name “JESSE TESTIMONY”.
NOTE: same URL but content has change using the swapping tool of deployment slot

Image description

Image description

With the blog post, I have successfully deployed and swapped my tested and upgraded web content into the slot where users can have access to.

Top comments (0)