I finally got around yesterday evening to updating my Windows Azure Application from the 1.2 SDK to the 1.3 SDK. Wow, what a fun strange trip that was. Yes Virginia, it is possible to upgrade. I ran across the following two issues:
- Don't try to use beta features if you aren't signed up for them. Ok, this one should have been obvious, unfortunately, it wasn't. What was my first thought when I started my upgrade? Of course, it was to try out the ExtraSmall VM. So, I plugged that into my .csdef file..........and my deployment promptly died with no info as to what had happened beyond some cryptic messages. Finally, I dug through and figure out that the "Windows.Azure.......PassWord.Encryption.........IDonCareWhatYouTriedToDoException" meant that my app did not have the ExtraSmall VM beta allowed on Azure. I went back to the Small VM Size to deploy my app with, and the app deployed. Problem #1 solved.
- Did I test my app after I deployed it? Of course not. Its my test app. There are a few users, but nothing huge. I logged in this morning, and bomb, the app died. WTF had I done? WTF was broken due to moving from 1.2 to 1.3? I was getting this error
“SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used”
I looked at the error, set some break points and ran locally. Boom, it didn't work here either. Great, what was wrong. Finally, I found the answer. The change to using the Full IIS7 instead of the Web Core had introduced a breaking change in the app. So, I copied some code from my WebRole.cs to my Global.asax and things worked. Sweetness. Here is the code, it will look a little familiar to someone developing in Azure.
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
CloudStorageAccount.SetConfigurationSettingPublisher(
(configName, configSettingPublisher) =>
{
var connectionString = RoleEnvironment.IsAvailable
? RoleEnvironment.GetConfigurationSettingValue(configName)
: ConfigurationManager.AppSettings[configName];
connectionString = RoleEnvironment
.GetConfigurationSettingValue(configName);
configSettingPublisher(connectionString);
});
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
RoleEnvironment.Changing += RoleEnvironmentChanging;
}
private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{
// If a configuration setting is changing
if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
{
// Set e.Cancel to true to restart this role instance
e.Cancel = true;
}
}
Now, my Azure app is back running and chugging along. Hopefully, this helps you out some.