Upload Code to Azure WebApp using local Git Repo

Microsoft Azure provides a couple of option on how to upload your Code to a running WebApp.
Per default, only FTP / FTPS is configured. But there are also options to use Visual Studio, OneDrive, Git, Bitbucket or Dropbox as sources for your Code.
In this example, I’m going to configure a Local Git Repository. That means, it is hosted locally at the WebApp instead at GitHub (which is another option).

If you go to your WebApps Overview Blade, it shows you the FTP URL and the used credentials.

If you want to use something else than FTP(S), in the left menu naviagate to:
Deployment Options –> Choose Source –> Local Git Repository

Hit OK on all Blades (you can ignore the Performance Test option).
Next we have to configure credentials we want to use. To do so, again in the left menu go to “Deployment Credentials” and enter credentials you want to use.

Now, you can go back to the Overview section of your WebApp.
The Information here have slightly changed. Its showing us now the “Git/Deployment username” and our “Git clone url“.

If you already have a directory of files you want to upload, you only need to add this URL as a remote repo to your local git installation.
In my example, I’ve a predefined index.html file sitting in C:\git\cloudborn\
Initialising Git Repo, adding all files in the directory, and commiting them.

PS C:\git\cloudborn> git init 
Initialized empty Git repository in 
C:/git/.git/ PS C:\git\cloudborn> git add . 
PS C:\git\cloudborn> git commit -a -m "Initial Commit" 
[master (root-commit) 49a29b6] Initial Commit 1 file changed, 8 insertions(+) create mode 100644 index.html 
PS C:\git\cloudborn>

Adding remote Git Repo, living on my WebApp

PS C:\git\cloudborn> git remote add azure https://cloudborn@cloudborn.scm.azurewebsites.net:443/cloudborn.git 
PS C:\git\cloudborn>

Pushing changes to my WebApp

PS C:\git\cloudborn> git push azure master 
Counting objects: 3, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (2/2), done. 
Writing objects: 100% (3/3), 302 bytes | 0 bytes/s, done. 
Total 3 (delta 0), reused 0 (delta 0) remote: Updating branch 'master'. 
remote: Updating submodules. remote: Preparing deployment for commit id '49a29b68a9'. 
remote: Generating deployment script. 
remote: Generating deployment script for Web Site 
remote: Generated deployment script files 
remote: Running deployment command... 
remote: Handling Basic Web Site deployment. 
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot' 
remote: Deleting file: 'hostingstart.html' 
remote: Copying file: 'index.html' 
remote: Finished successfully. 
remote: Running post deployment command(s)... 
remote: Deployment successful. To https://cloudborn.scm.azurewebsites.net:443/cloudborn.git * [new branch] master ->> master PS C:\git\cloudborn>

The cool thing about this is, that after you pushed your changes, they will be applied immediately.
To take a look at your website, just follow the URL provided in the overview section.

Leave a Reply

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