Configuring Git Deployment for Windows Azure Virtual Machines
Hello everybody! Today I will try to describe in detail the process of setting up Git publishing for virtual machines in Windows Azure. Many of you already know that Windows Azure provides developers with the ability to publish applications to the cloud through Git (a detailed description of this process can be found here http://habrahabr.ru/company/microsoft/blog/150086/ ), but few know that Git is published Funded by the so-called Kudu project. Kudu is a mechanism that provides the ability to deploy your applications using Git on Windows Azure. It is distributed under an open source license and is available on GitHub ( https://github.com/projectkudu/kudu) A big advantage of this mechanism is that it has the ability to run outside of Windows Azure. This means that we can freely download it to our machine and configure Git deployment in our local environment. Given this feature, it would be very nice to configure a similar mechanism for Windows Azure virtual machines. That is what we are trying to do.
So, first of all, we need a target virtual machine on which our application will be deployed. You can create it on the Windows Azure portal in the Virtual Machines section. For our purposes, you can use the option of lifting the car from the gallery, which is the fastest option.
Once the virtual machine is configured and started, we will be able to remotely access it using the RDP protocol and proceed to the next step. In the second step, we need to clone the remote Kudu repository to our virtual machine and run the setup wizard for the new application. Let's do it one by one. First of all, install the Git client for Windows. To do this, go to the website http://msysgit.github.com , download and install the software package (you can use any alternative Git client). Once the installation is complete, run git bash and clone the repository to any directory on the C: drive (to test the viability of the solution, this drive will completely suit us). The repository address can be found at https://github.com/projectkudu/kudu .
To clone Kudu, run the following command in git bash.
The result of the operation should look like this:
The next step is the project build. To do this, find the file [kudu_installation_dir] /kudu/build.cmd in our directory and run it with administrator rights. The build process of the project can last up to 1 minute, after which we will need to create a new site on the local IIS instance to launch the Kudu management console. The new site must be directed to the [kudu_installation_dir] /kudu/Kudu.Web subdirectory . Here's what it looks like on an IIS instance of a virtual machine:
We use the custom 8080 port, leaving the 80th port free for use by the main application. Since Kudu requires administrator rights to function properly, you need to run our application pool under a less restricted account. To do this, go to the Application Pools section and in the advanced settings of the pool, change its Identity. There is an Administrator user on my machine, which is quite suitable for us.
After that, without leaving the remote terminal, open the browser and check if the site is working properly by clicking on the localhost : 8080 link . If everything is successfully configured, we should see the Kudu management console.
As you can see, when you first start up there are no installed applications, so we need to create a new one. This is done very simply by selecting the Create Application menu item, and all we need to do next is select the name of the application we are creating. Let's stop at the name of GitWithKudu.
As soon as we click the “Create Application” button, 2 sites will be created on the web server local to the virtual machine: one is for launching the main application, and the second is for supporting Git deployment. Here is how the infrastructure we created will look in the end:
Kudu Enrironment is a Kudu console for managing all web server applications. The kudu_gitwithkudu site is our application deployed through Git. The site kudu_service_gitwithkudu is an auxiliary application through which publication will take place. Let's go back again for a moment to the Kudu management console. After creating a new application, we will see the following result:
As you can see, this page provides very useful information. Here we can find the address of our Git repository, the address of the application itself, as well as several auxiliary tabs that allow you to track the publication history, change the configuration, etc. By default, Kudu uses a simple random port selection mechanism for the main application and deployment service, so we see that our application will use a non-standard port 36263. To change it, you can use the usual technique of changing site bindings in IIS Manager, which we will do to transfer the site to port 80.
On this, all the work related to setting up our target virtual machine can be considered completed. All that remains for us to do is to deploy our application through the created infrastructure. Let me remind you that after completing Kudu setup, we have 3 sites:
But before you start deploying the application, you must add port 60972 to the list of allowed ports on the Windows Azure portal. Ultimately, our Endpoints section should look like this:
Once a new point with port 60972 is added, we can begin publishing. To do this, we need to perform a simple sequence of actions. First, create an empty directory on disk and run git bash for it. We use the team
Add a new file to the repository called index.html. The contents of this file are presented below:
After creating the file, execute 2 git commands in sequence:
It remains for us to deploy a new file in the cloud. To do this, run the following git command:
To check, open the website gitdeploy.cloudapp.net in the browser . We should see our changes on the server:
In addition, in the Kudu management console in the Deployments tab, you can track the entire deployment history:
As you can see, we have successfully configured Git deployment for the Windows Azure virtual machine based on the Kudu project. Despite the fact that this project is still young and has a number of shortcomings, I consider it quite promising and interesting. That's all, thanks for watching! Reasoned criticism and advice are of course welcome :)
So, first of all, we need a target virtual machine on which our application will be deployed. You can create it on the Windows Azure portal in the Virtual Machines section. For our purposes, you can use the option of lifting the car from the gallery, which is the fastest option.
Once the virtual machine is configured and started, we will be able to remotely access it using the RDP protocol and proceed to the next step. In the second step, we need to clone the remote Kudu repository to our virtual machine and run the setup wizard for the new application. Let's do it one by one. First of all, install the Git client for Windows. To do this, go to the website http://msysgit.github.com , download and install the software package (you can use any alternative Git client). Once the installation is complete, run git bash and clone the repository to any directory on the C: drive (to test the viability of the solution, this drive will completely suit us). The repository address can be found at https://github.com/projectkudu/kudu .
To clone Kudu, run the following command in git bash.
git clone https://github.com/projectkudu/kudu.git
The result of the operation should look like this:
The next step is the project build. To do this, find the file [kudu_installation_dir] /kudu/build.cmd in our directory and run it with administrator rights. The build process of the project can last up to 1 minute, after which we will need to create a new site on the local IIS instance to launch the Kudu management console. The new site must be directed to the [kudu_installation_dir] /kudu/Kudu.Web subdirectory . Here's what it looks like on an IIS instance of a virtual machine:
We use the custom 8080 port, leaving the 80th port free for use by the main application. Since Kudu requires administrator rights to function properly, you need to run our application pool under a less restricted account. To do this, go to the Application Pools section and in the advanced settings of the pool, change its Identity. There is an Administrator user on my machine, which is quite suitable for us.
After that, without leaving the remote terminal, open the browser and check if the site is working properly by clicking on the localhost : 8080 link . If everything is successfully configured, we should see the Kudu management console.
As you can see, when you first start up there are no installed applications, so we need to create a new one. This is done very simply by selecting the Create Application menu item, and all we need to do next is select the name of the application we are creating. Let's stop at the name of GitWithKudu.
As soon as we click the “Create Application” button, 2 sites will be created on the web server local to the virtual machine: one is for launching the main application, and the second is for supporting Git deployment. Here is how the infrastructure we created will look in the end:
Kudu Enrironment is a Kudu console for managing all web server applications. The kudu_gitwithkudu site is our application deployed through Git. The site kudu_service_gitwithkudu is an auxiliary application through which publication will take place. Let's go back again for a moment to the Kudu management console. After creating a new application, we will see the following result:
As you can see, this page provides very useful information. Here we can find the address of our Git repository, the address of the application itself, as well as several auxiliary tabs that allow you to track the publication history, change the configuration, etc. By default, Kudu uses a simple random port selection mechanism for the main application and deployment service, so we see that our application will use a non-standard port 36263. To change it, you can use the usual technique of changing site bindings in IIS Manager, which we will do to transfer the site to port 80.
On this, all the work related to setting up our target virtual machine can be considered completed. All that remains for us to do is to deploy our application through the created infrastructure. Let me remind you that after completing Kudu setup, we have 3 sites:
- http://gitdeploy.cloudapp.net:8080 - Kudu management console
- http://gitdeploy.cloudapp.net - test application
- http://gitdeploy.cloudapp.net:60972 - deployment service
But before you start deploying the application, you must add port 60972 to the list of allowed ports on the Windows Azure portal. Ultimately, our Endpoints section should look like this:
Once a new point with port 60972 is added, we can begin publishing. To do this, we need to perform a simple sequence of actions. First, create an empty directory on disk and run git bash for it. We use the team
git init
, to initialize a new Git repository. Add a new file to the repository called index.html. The contents of this file are presented below:
Windows Azure Kudu Engine!
Hello Windows Azure!
After creating the file, execute 2 git commands in sequence:
git add .
git commit -m "First commit"
It remains for us to deploy a new file in the cloud. To do this, run the following git command:
git push http://gitdeploy.cloudapp.net:60972/gitwithkudu.git
To check, open the website gitdeploy.cloudapp.net in the browser . We should see our changes on the server:
In addition, in the Kudu management console in the Deployments tab, you can track the entire deployment history:
As you can see, we have successfully configured Git deployment for the Windows Azure virtual machine based on the Kudu project. Despite the fact that this project is still young and has a number of shortcomings, I consider it quite promising and interesting. That's all, thanks for watching! Reasoned criticism and advice are of course welcome :)