Automate deployment using Git, GitHub and Azure

In this tutorial, I am going to show the simple GUI based steps that how we can deploy our code to Microsoft Azure, but we can deploy using git, azure-cli.

Prerequisites:

  1. Microsoft Azure subscription here
  2. Git, you can download from here and complete installation
  3. GitHub account, create here
  4. Sample project, download from here or simply follow the steps

Let’s create simple ASP.NET Core project

Step # 1:

Make a new folder
asp.net core https://todaypoints.azurewebsites.net/wp-admin/profile.phpdeployment git github, azure

Step # 2:

Navigate to the newly created folder.
asp.net core deployment git github, azure

 

Step # 3:

Set up and restore new ASP.NET Core MVC project.
asp.net core deployment git github, azure

Step # 4:

Run the project on your local machine to check it is working or not
asp.net core deployment git github, azure

Step # 1 – 4 Summary:

asp.net core step 1-4

Step # 5:

Now, we have working sample project, and it’s time to push our code to GitHub account
Create new repository with any name you like, and description is optional then hit create button
asp.net core deployment git github, azure
asp.net core deployment git github, azure

Step# 6:

Initialize git repository from the current one to add a .git folder and makes it possible to start your revision history.
asp.net core deployment git github, azure

Step # 7:

The add all the existing files and folder to the index
asp.net core deployment git github, azure

Step # 8:

Record the state as your first commit in the history to the master branch of your project
asp.net core deployment git github, azure

Step # 9:

Now create a new remote called origin and then locate URL
asp.net core deployment git github, azure

Step # 10:

Push the local commit to the remote master branch
asp.net core deployment git github, azure
Now refresh your repository in browser to see the code

Step # 11:

Now it’s time to play with Azure
Follow the steps to create new Web app instance

  1. login to you Azure portal account
  2. At top left click + (New)
  3. Click the Web + Mobile
  4. Choose first option (Web app)
  5. Provide the App name (can be different from GitHub repository name)
  6. Create logical resource group
  7. Choose the location
  8. Press the create button

asp.net core deployment git github, azure

After successful creation and deployment, notification will appear shown in blow image

asp.net core deployment git github, azure

Step # 12:

  1. Click on newly created web app, go to the APP DEPLOYMENT section and select Deployment options
  2. Choose source > Choose GitHub

asp.net core deployment git github, azure

Step # 13:

  1. Provide GitHub Authorization
  2. Select the project from the list
  3. Select the master branch. Note: make sure that you are deploying the master branch.
  4. Click Ok

asp.net core deployment git github, azure

Wait a moment so that Azure can make a connection with our GitHub repository. After that Azure will start the process of build and deployment. You can see the progress by going deployment options.

asp.net core deployment git github, azure

After successful deployment, you can see the green active icon
Now browse the URL, Overview > URL

asp.net core deployment git github, azure

Your website is live on the internet.
But wait, the important point is to make sure that our deployment is automatic, for this we will make some changes in our project then commit and push these changes to our GitHub repository if the changes occurred in the live website then have achieved our goal otherwise, there is some problem.
So, open the project in Visual Studio Code

Step # 14:

Open the Views > Home > index.cshtml file

asp.net core deployment git github, azure

 

change some code and add these changes to the git index
Commit and push to the remote master branch
asp.net core deployment git github, azure

 

Open Azure portal
Go to APP DEPLOYMENT > Deployment options wait for the green active icon.
asp.net core deployment git github, azure
Now refresh your live website and see the change
asp.net core deployment git github, azure
Congratulation, That’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected by WP Anti Spam