In this article, you’re going to learn how to host your web app using Azure and how to update it using staging slot and GitHub as external repository.

Prerequisites

Create Azure web app

STEP 1

Once you’re on the Azure portal, locate the sandwich menu (three horizontal lines) at the left side corner. Clicking on it, a "New" blade will open where you have multiple options. Click Web+ Mobile.

Azure webApps

In the next blade, you will find the Web App option. Click on it to create a new web app.

Azure webApps

STEP 2

Now, you have multiple options, like Name, Subscription, Resource group etc.

Azure webApps

Create New App Service Plan

Azure webApps

Select "Create" to deploy the app.

Azure webApps

When the web app is created, you will get a notification in the Notification Panel.

Azure webApps

STEP 3


Azure webApps

In the overview of your web app, you can see various options such as Browse, Stop, Swap, Get Public Profile, Reset Public Profile etc. Click on "Get public profile" to download your web app profile.

Step 4

Azure webApps

Open the downloaded profile in notepad where you can find your FTP URL. Paste it in the "File Explorer" as shown in the above screenshot.

Now, you will be prompted to enter your username and password. Copy the Username and Password from the downloaded Public Profile to login to your Application File System.

Azure webApps

Azure webApps

We will create a basic HTML page and save it as index.html using Notepad.

Copy the created index.html and paste it in the root folder.

Azure webApps

To check if your web app has been published, go to your Web App Overview in the Azure portal and click on "Browse". This will take you to your website.

Azure webApps
Now, our web app has been hosted successfully. Let’s create a Deployment Slot for updating our website.

To create Deployment Slot, we will head over to our web app. In the Web App blade, you can find the Deployment Slot option, click on it. In the new window, click on "Add Slot" to create a new slot.

Deployment Slot

Azure webApps

Slot Name

In the new window, you will find some details to be filled out to create a new Deployment Slot.

Once you click OK, your Deployment Slot will be created.

To find your newly created deployment slot, go to Resource Group and find your specific resource group that you created for your web app. Here, you can find your new web app.

Azure webApps

Go to the Deployment option in your staging slot web app (kishorekumar in my case) to add your website content through GitHub. For swapping process.

Azure webApps

In the below screenshot, you can see there are different sources to add your website content. This time, we will use GitHub as primary source to add our Deployment Slot website content.

Azure webApps

Before choosing GitHub as primary source, let’s create a GitHub account if you don’t have one. Once your account is created, click on the new repository as shown in the below screenshot. While creating a new repository, you will find a checkbox next to initialize Read me.md. This is a mandatory step while creating a repository so that you will get UI based repository.

Azure webApps

Once the repository has been created, click on the "Upload Files" button or drag & drop edited index.html file from the local machine. Once the file is uploaded, click "Commit Changes".

Azure webApps

Go back to Azure portal, click GitHub from the previous screenshot. After choosing GitHub as your source, authorize your GitHub account to be used by your Azure web app. Choose your project as the repository name which was created in GitHub.

Azure webApps

Click OK to configure your GitHub account with your web app. Go to Overview >> Browse to check if your website is hosted.

Azure webApps
In the main Web App Overview, click on Swap button.

Azure webApps

In Swap option, choose Swap type source as your Staging Slot name and destination as production. Then, click OK.

Azure webApps

Once the web app is swapped, you will be notified and your Staging Slot website content would be moved to the primary website. And the primary website content would move to your Staging Slot.

Azure webApps
Conclusion

So, we simply created a primary website and hosted our website through FTP login. Then, we used Staging Slot to create a secondary website and used GitHub as the prime source for this websites' content.

Finally, we used the Swap option to update our primary website. Staging Slots let us update a "currently in use" website to be updated without any downtime. And the use of deployment options for the website lets us add different content to our website without the need of sharing Azure credentials or logging into Azure to update the website content.

We will learn more in upcoming articles. Till then, keep learning!