Microsoft Azure and Visual Studio Online Server Builds – Tips & Tricks

April 22 2014

I’m all about deploying web sites and cloud services via server builds. Say goodbye to deployments from a developer’s box that can’t be reproduced on another box. Say goodbye to deploying code that isn’t checked in. Say goodbye to deployments that aren’t fully tested.  It is indeed super cool.

So how to get it set up? There are some good tutorials out there, but it can get a little tricky. Here’s how I did it.

First, make sure that you’ve linked your Azure account to your Visual Studio Online repository as explained in Step 3 here: http://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso/

Then, if you open VS from the Azure website, it will generate a build template for you that is the name of your Azure deployment with an _CD at the end. You’ll have to tweak some things to get it happy though.

First, go the Build section of Team Explorer window:

0

Then, right click on the Build definition file and click Edit Build Definition.

There’s a bunch of things you will need to change.

In the general tab, make sure you enable the build definition. By default it is disabled:

11

In the source settings tab, make sure it is pointing to the right repository:

1

In the Trigger tab, you may want to tweak when the deployments happen:

111

And, in the Process tab, make sure you point the Project it to the right .sln to build as well as the Configuration you want aka Release | Any CPU.

And, in the deployment settings, make sure that the the Path To Deployment Settings points to your .pubxml file and the Windows Azure Deployment Environment points to the name of the Cloud Service in Windows Azure. 

4

With that all set, you can now build and deploy using server builds!

Windows Azure Table Storage Emulator UpdateObject Error

January 21 2013

Was getting this:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>InvalidInput</code>
  <message xml:lang="en-US">One of the request inputs is not valid.</message>
</error>

When calling UpdateObject from the Azure SDK when using the table storage emulator. Turns out the emulator doesn’t exactly emulate as per MSDN documentation: http://msdn.microsoft.com/en-us/library/gg433135.aspx “The storage emulator does not support Insert-Or-Replace Entity or Insert-Or-Merge Entity, known as upsert features.”

So, to work around, I changed the code to delete then reinsert.  Or not. Turned out I had lots of concurrancy problems with doing a delete/insert which were resolved with the more transactional upsert. 

Visual Studio Achievements For Windows Azure Buzz

May 1 2012

Here’s some links to posts and stories about the 15 new Windows Azure achievements added to Visual Studio Achievements:

Visual Studio Adds Windows Azure Achievements
Neowin

Azure Gamified - More Badges!
I Programmer

Visual Studio Achievements Brings Gamification to Windows Azure Development
MSFT post

Announcing Windows Azure Achievements For Visual Studio
Windows Azure Post

Cloud Cover Video
Channel9

Announcing Visual Studio Achievements For Windows Azure
Channel9

MVC3 and Windows Azure Tools 1.4 -- Better But Still Messed Up

August 24 2011

Getting MV3 on to Azure used to be really painful. The new Windows Azure Tools 1.4 make things better, but they are still a bit bungled up.  The tools fix the missing assemblies problem (although I still maintain that this shouldn't even be an issue and IT should have them installed on the servers, but that's another issue) in that if you create a new Azure project and choose ASP.NET MVC 3 Web Role, it will set all the assemblies you need to 'copy local.' Thanks guys. 

But, you're still going to have problems deploying to Azure, even you pick the empty template.  Your web.config will be full of things that can trip you up, the most egregious being a default session provider, which points to SQL Express, which no instance of Azure will ever have.  So, if you deploy without fixing that, you're screwed. Additionally, if you use the other providers that are in the web.config, you'll need to tweak them, as they rely on providers that Azure doesn't support.  

I'm calling out the folks who built these tools: this is sloppy. If you really want the gory details on this, you can read more Nathan Trotten's post.

While I'm ranting, if I choose an 'empty web template', why are 20 javascripts included with the project? This happens both with Azure MVC3 projects as well as non-Azure MV3 projects.  Empty means empty.

Oh, one other thing: if you create an MVC3 project not from the Azure Tools and then attempt to deploy it to Azure, you'll run into the missing assemblies problem.  Your life gets a little better if you have SP1 installed because you can invoke the Add Deployable Assemblies feature (explained here), but if you don't have SP1 installed, you'll have to do it manually.

Screencast: How To Deploy PHP Websites To Azure -- Without Visual Studio

April 18 2011

Here's a screencast that elucidates my step-by-step post on how to deploy PHP to Windows Azure:

Swingify: Photoshopping Music

June 7 2010

Check out this sample by Steve Marx called Swingify.  It uses the Echonest API and builds off a sample called Swinger that came from the Music Hack Day that took place recently in San Francisco. These two came out particularly well:

Sweet Child O' Mine (Swing Version) by plamere

White Rabbit - The Swing Version by plamere

Steve's post explains how he built Swingify on Azure -- nice!

Azure Development Tip: Toggle Where You Get Config in Application_Start()

May 2 2010

The Azure Development Fabric is quite useful as far as simulating Azure on your dev box, It is especially nice how it simulates mulitple web roles and worker roles, so you can find web farm problems and what not before deploying. But, one hassle when working in the dev fabric is that once you start debugging, it creates a package and "deploys" the files, so that you can't make any changes to the site and hit refresh. So, no changes to CSS, static html pages or .aspx pages. This is kind of a drag.

I thought the solution would be as simple as just creating a different .sln that wasn't an Azure project and then adding the .csproj file to that .sln.  But, I tried that and got the following error:

"SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used."

Basically, what was happening was that any code that tried to call CloudStorageAccount.FromConfigurationSetting was failing because it couldn't get to the Azure config, which is where I have stored the connection string to my blob storage.

At first, I was going to just get rid of using the CloudStorageAccount and move my config elsewhere, but I briefly searched my code and found I was using it a lot. And, if I removed it out of there, I could no longer make any changes to config after I deployed. I found a more elegant solution (tip o' the hat to Fernando Tubio and this thread in the Azure forums.)  Basically, I duplicate the settings in web.config and then call the following code in Application_Start() of global.asax.cs:

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
  {
    string connectionString;

    if (RoleEnvironment.IsAvailable)
    {
      connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
    }
    else
    {
      connectionString = ConfigurationManager.AppSettings[configName];
    }

    configSetter(connectionString);
  });

Works great! And makes for a much better development experience!

Oh, the one other thing I had to do was rem out the diagnostics trace listener in web.config. If I wanted to be more elegant, I could have removed this from web.config programmatically in the conditional statement above...

Beware of Using Memory Storage With The ASP.NET Chart Control In Windows Azure With Multiple Instances of Your WebRole

April 12 2010

In the documentation here: http://blogs.msdn.com/deliant/archive/2008/12/02/managing-chart-generated-images-with-chart-image-handler.aspx on the ASP.NET Chart Controls, it states:

Do not use this [the memory storage] option in a server cluster or a multiple-process site.

Well, if you have multiple instances of your web role in Windows Azure, this is gonna get you.  It got me. But hats off to the Windows Azure for actually simulating multiple instance in my development fabric -- didn't realize they did that.

 

Putting Files at the Root of Blog Storage in Windows Azure

February 3 2010

Just learned today that by default you can't store files at the root in Windows Azure storage. So, what if you have http://foo.blob.core.windows.net which you've mapped to http://blob.foo.com and you want to put a file so that it resolves to to http://blob.foo.com/bar.png? Well you can create a special container called $root, which will map to the root.  If you do that, anything in the $root container will resolve as expected, so that http://blob.foo.com/bar.png would work.

If you are using Cloud Storage Studio, their UI supports this with the New Root Container option when creating containers.

 

Critical Hot Fix for Using Silverlight, WCF and Windows Azure

February 1 2010

I innocently added a Silverlight-enable WCF Service to my Azure application and then innocently generated a Service Reference for my Silverlight client. Everything worked fine on my machine; nothing worked once I uploaded it to Azure.  After going down a lot of wrong turns in figuring out what was wrong, I was able to use Fiddler to discover the following response from the service:

The message with To 'http://.../Service.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.

This led me to the following hot fix: http://code.msdn.microsoft.com/KB971842.  After installing the hot fix, in order to get things working, I had to both add the following to my serviceBehaviors behavior:

          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="http" port="81" />
              <add scheme="https" port="444" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>

And then I also had to add the following attribute to my service:

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]

I then regenerated my proxy and, hooray, everything worked. More on this and other issues when using WCF with Windows Azure is explained here: http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues