Moving from the ‘ServiceHosting’ to ‘WindowsAzure’ Namespace

Sunday, 29 November 2009 17:40 by SyntaxC4

 

Being part of a Technology Focus Panel for Windows Azure was quite a rewarding experience for me. I rarely get to work with emerging technology, which is one of the main reasons why I started Guelph Coffee and Code.  We’re getting down to the wire of launching 20 applications up to the cloud, and I’ve been putting in some extra time ensuring that we reach our goal. I’m working on compiling an application as I write this post, but I thought I would share some of the knowledge I’ve gained while Debugging the ‘Windows Azure Guest Book using Tables’ application found in the November 2009 CTP Platform Kit part of the Windows Azure Get Started steps.

The solution has a reference to the Microsoft.ServiceHosting.ServiceRuntime namespace that has recently changed its name after the Microsoft PDC Conference. If you are having a hard time compiling some of the projects it will most likely have something to do with the name change. Please note that the Microsoft.ServiceHosting.ServiceRuntime has been changed to Microsoft.WindowsAzure.ServiceRuntime which is more suiting as the platform is called Windows Azure. Not only has the namespace been changed but there are a number of Classes that have been refactored as well.

The RoleManager class has been changed to RoleEnvironment along with some of the members of the class. Let’s take a look at them in Context.

RoleManager: [Note: These are Snippets from the StorageClient Project, File: StorageAccountInfo.cs]

 // settings in the csc file overload settings in Web.config
            if (RoleManager.IsRoleManagerRunning)
            {
                string cscRet = TryGetConfigurationSetting(configurationSetting);
                if (!string.IsNullOrEmpty(cscRet))
                {
                    ret = cscRet;
                }

 

RoleEnvironment:

 // settings in the csc file overload settings in Web.config
            if (RoleEnvironment.IsAvailable)
            {
                string cscRet = TryGetConfigurationSetting(configurationSetting);
                if (!string.IsNullOrEmpty(cscRet))
                {
                    ret = cscRet;
                }

 

As you can see from the snippet above (bolded text) that RoleManager.IsRoleManagerRunning as been replaced by RoleEnvironment.IsAvailable.

Another change was found when accessing the Role configuration file.  The method RoleManager.GetConfigurationSetting was replaced by RoleEnvironment.GetConfigurationSettingValue.

RoleManager:

 private static string TryGetConfigurationSetting(string configName)
        {
            string ret = null;
            try
            {
                ret = RoleManager.GetConfigurationSetting(configName);
            }
            catch (RoleManagerException)
            {
                return null;
            }
            return ret;
        }

 

RoleEnvironment:

 private static string TryGetConfigurationSetting(string configName)
        {
            string ret = null;
            try
            {
                ret = RoleEnvironment.GetConfigurationSettingValue(configName);
            }
            catch (RoleEnvironmentException)
            {
                return null;
            }
            return ret;
        }

 

Another thing to note from the snippets above is the RoleManagerException has been changed to RoleEnvironmentException, which shouldn’t come as too big of a surprise.

In order to find these code changes I used the RedGate .NET Reflector Tool, and compared the library Microsoft.ServiceHosting.ServiceRuntime.dll for similarities to the library Microsoft.WindowsAzure.ServiceRuntime.dll.

Comments

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



About SyntaxC4:

  • Cory Fowler
  • Guelph, Ontario
  • English
  • SyntaxC4

SyntaxC4 Tweets:

Posts by Date:

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Archive:

Advertisements:

Tag Cloud:

Favourite Publishers:

Apress Daily Deal
Apress Daily Deal

Blog Roll: