2

I have connected Visual Studio Online to my Azure website. This is not a .NET ASP.NET MVC project, just several static HTML files. Now I want to get my files uploaded to Azure and available 'online' after my commits/pushes to the TFS. When a build definition (based on GitContinuousDeploymentTemplate.12.xaml) is executed it fails with an obvious message:

Exception Message: The process parameter ProjectsToBuild is required but no value was set.

My question: how do I setup a build definition so that it automatically copies my static files to Azure on commits? Or do I need to use a different tooling for this task (like WebMatrix).

update

I ended up with creating an empty website and deploying it manually from Visual Studio using webdeploy. Other possible options to consider to create local Git at Azure.

TarasB
  • 2,407
  • 1
  • 24
  • 32

2 Answers2

4

Alright, let me try to give you an answer:

I was having quite a similar issue. I had a static HTML, JS and CSS site which I needed to have in TFS due to the project and wanted to make my life easier using the continuous deployment. So what I did was following:

When you have a Git in TFS, you get an URL for the repository - something like:

https://yoursite.visualstudio.com/COLLECTION/PROJECT/_git/REPOSITORY

, however in order to access the repository itself, you need to authenticate, which is not currently possible, if you try to put the URL with authentication into Azure:

https://username:password@TFS_URL

It will not accept it. So what you do, in order to bind the deployment is that you just put the URL for repository there (the deployment will fail, however it will prepare the environment for us to proceed).

However, when you link it there, you can get DEPLOYMENT TRIGGER URL on the Configure tab of the Website. What it is for is that when you push a change to your repository (say to GitHub) what happens is that GitHub makes a HTTP POST request to that link and it tells Azure to deploy new code onto the site.

Now I went to Kudu which is the underlaying system of Azure Websites which handles the deployments. I figured that if you send correct contents in the HTTP POST (JSON format) to the DEPLOYMENT TRIGGER URL, you can have it deploy code from any repository and it even authenticates!

So the thing left to do is to generate the alternative authentication credentials on the TFS site and put the whole request together. I wrapped this entire process into the following PowerShell script:

# Windows Azure Website Configuration
#
# WAWS_username: The user account which has access to the website, can be obtained from https://manage.windowsazure.com portal on the Configure tab under DEPLOYMENT TRIGGER URL
# WAWS_password: The password for the account specified above
# WAWS: The Azure site name
$WAWS_username = ''
$WAWS_password = ''
$WAWS = ''

# Visual Studio Online Repository Configuration
#
# VSO_username: The user account used for basic authentication in VSO (has to be manually enabled)
# VSO_password: The password for the account specified above
# VSO_URL: The URL to the Git repository (branch is specified on the https://manage.windowsazure.com Configuration tab BRANCH TO DEPLOY
$VSO_username = ''
$VSO_password = ''
$VSO_URL = ''

# DO NOT EDIT ANY OF THE CODE BELOW
$WAWS_URL = 'https://' + $WAWS + '.scm.azurewebsites.net/deploy'
$BODY = '
{
    "format": "basic",
    "url": "https://' + $VSO_username + ':' + $VSO_password + '@' + $VSO_URL + '"
}'
$authorization = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($WAWS_username+":"+$WAWS_password ))

$bytes = [System.Text.Encoding]::ASCII.GetBytes($BODY)

$webRequest = [System.Net.WebRequest]::Create($WAWS_URL)
$webRequest.Method = "POST"
$webRequest.Headers.Add("Authorization", $authorization)
$webRequest.ContentLength = $bytes.Length
$webRequestStream = $webRequest.GetRequestStream();
$webRequestStream.Write($bytes, 0, $bytes.Length);
$webRequest.GetResponse()

I hope that what I wrote here makes sense. The last thing you would need is to bind this script to a hook in Git, so when you perform a push the script gets automatically triggered after it and the site is deployed. I haven't figured this piece yet tho.

This should also work to deploy a PHP/Node.js and similar code.

Jan Hajek
  • 633
  • 5
  • 20
  • 1
    I was able to put this PowerShell script into my Build defenition as a pre-build script. This way it deploys the new code even though my build will technically fail. It seems to work... – sirtimbly Mar 05 '15 at 20:10
0

The easiest way would be to add them to an empty ASP .NET project, set them to be copied to the output folder, and then "build" the project.

Failing that, you could modify the build process template, but that's a "last resort" option.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Daniel, thanks for your input. With 'empty project' option the end result will be also a bin folder with the dll in it, right? – TarasB May 19 '14 at 12:23
  • I have tried it with empty website, experiencing this now - http://stackoverflow.com/questions/23116420/azure-website-visual-studio-online-continuous-deployment-fails-for-website – TarasB May 19 '14 at 22:19