Setting Up Deployment Options For Azure Web App Using Git

To complete this article, you need a Microsoft Azure account, and to get a free account, click here. If you’re new to Azure, I recommend reading Introduction to Microsoft Azure.

The following are some of the requirements, which are required to complete this article.

  • Visual Studio 2015 Update 1 (Community or Enterprise edition).
If you don’t have Visual Studio 2015 Community Edition, it is absolutely free. To download Visual Studio 2015, click here.
  • ASP.NET Core
  • Git for Windows
Create ASP.NET Core Web Application

Open up Visual Studio IDE.

Subsequently, click on File menu, select New, followed by Project.

 

To select ASP.NET Core Web app project template, click Visual C#, followed by Web. Now, provide the application's name and tick Add to source control. Subsequently, click Ok.

 

In New ASP.NET Project creation wizard, select ASP.NET Empty Project template and click OK.

 

Deploying Web App

It takes about 15 seconds to create an Application. Once app creation completes, deploy an Application locally by navigating to Debug ->Start Debugging or simply Press F5 for one click deployment.

 

Note:

Your default debug option is IIS Express. Click Dropdown, which is next to IIS Express and change that debug option to your project debug option. There, you will be able to find your Application name.

Congrats, now our Application is deployed and the output is projected in the Web Browser.


To stop debugging your Application, click stop debugging icon, which is available in Visual Studio app bar.

Creating Web App in Azure Management Portal

Login into Azure management portal.

Click New and then Web+Mobile, followed by click Web app to create a Web app account in Azure.

 

Provide all the required credentials such as name, subscription, resource group and click create.

 

Name – Provide the valid name for your Web Application, which you are going to create. Obviously, it is a URL to access the Web Application.

It takes some time to start creating a web application in Windows Azure. Once the provision is successful, you will land in the Overview page of your Web Application.

Configuring Deployment Source

Login into Azure management portal.

Open up your Web Application by clicking on Browse >> Web apps >> select your Application, which is listed on the Web app blade.

In the Web app overview page, click Settings if it is not opened, otherwise omit this step, as it is optional.

In the settings blade, scroll down and find deployment source under app development. Click it and click to choose a source. Click Local Git Repository. Once deployment Source is selected, click OK.

 

Again, open up deployment source, where you will be able to find Disconnect option, since our Application is linked with Local Git deployment source.

 

Now, it’s time to set up deployment credentials, so open up settings blade under App Deployment. Click Deployment credentials

 

In the deployment credentials, the Window provides the username and the password. This password is used for setting up Git repository. Now, click save button to save the username and the password.

In Web app settings page, scroll down Properties under Settings and click it. From the properties page, copy GIT URL and make a note of it because it will be used later.

 

Deploying Web App to Azure

In the Solution Explorer, right click on your solution name and then click Commit. Now, Team Explorer Windows will appear (or) Open Up team explorer tab by clicking Team Explorer tab, which is next to the Solution Explorer option.

 

In team explorer Window, select Home, followed by settings and click repository settings.

 
 
 

In the remote settings, scroll down and find Add under Remotes label, as shown below.

 

Now, fill out the dialog by providing Name and retrieve the URL, followed by ticking Push matches.

 

Again, select Home and then changes to navigate to change view.

 

In the changes Window, provide a commit message and then click on commit button to commit the changes. This performs commit operation locally. Now, we need to synchronize with Azure.

 
 
 

Select Home, followed by synchronizing and then actions. Open the command prompt.

 

Enter the following command to synchronization.

git push - Name of your remote git master.

 

Enter your username and password, which are already configured in Azure management deployment portal.

 

This command starts publishing Local git repository into Azure and it takes about 150 to 300 seconds to finish deployment on a remote machine.

 

Final touch

Checking the deployment

Login into Azure management portal, followed by selecting settings >> Deployment options.

From this blade, you will be able to find configured git repository as initial Push #1 and it is in an active state.

 

Navigate to overview page and click the URL of your Web Application.

 

Open the Web Browser and search Web app with the URL and the output given below is displayed.

http://Yourappname.azurewebsites.net

Output 
 

Summary

In this article, we learned about setting up deployment option, using Azure Web app. I hope, you enjoyed reading this article. Thanks for reading.

Happy coding.

Up Next
    Ebook Download
    View all
    Learn
    View all