Azure Blob Storage and Hosting Cross-Domain Silverlight Applications

Recently I ran into a situation where I wanted to host an ASP.NET MVC web application
and Silverlight application in Windows Azure. The ASP.NET application provides all
of the backend services for the Silverlight application. This was all well and good
until I decided to move the Silverlight XAP file from the ClientBin directory of the
web application over to Blob Storage so that I could update the XAP file without the
need to redeploy the entire site.

That’s when it broke.

When moving a XAP file to a different “site of origin” than the website, there are
a number of cross domain issues that are potentially introduced. Tim Heuer has and
excellent blog post “Hosting
cross-domain Silverlight Applications”
in which he details the main concerns and
how to address the issues. In my case, it was the “XAP MIME Type” issue causing the
problem. When Windows Azure Blob Storage was serving up the XAP file, it was not correctly
indicating the “application/x-silverlight-app” MIME type. For security reasons Silverlight
checks to see that the content is a valid Silverlight type, in my case not allowing
the XAP file to run.

I had tried using a couple of utilities to copy my content into blog storage, which
had seemed to work fine for image and video files, but not the XAP file and did not
allow me to set the content types manually. [UPDATE: Azure Explorer will allow you
to update MIME Types: http://azurestorageexplorer.codeplex.com/ ]
To resolve the problem, I needed to upload a file to storage and set it’s mime type
to “application/x-silverlight-app”. In the end, this is pretty simple to do so I crafted
a little utility to properly deploy my XAP file using the following code.

var account = new CloudStorageAccount(storageKeys, true);
var container = account.CreateCloudBlobClient().GetContainerReference("clientbin");
container.CreateIfNotExist(); container.SetPermissions(new BlobContainerPermissions
{ PublicAccess = BlobContainerPublicAccessType.Blob }); var blob = container.GetBlobReference(System.IO.Path.GetFileName(fileName));
blob.Properties.ContentType = "application/x-silverlight-app";
blob.UploadFile(fileName);

Windows Azure Training–A Great FREE Gift for the Holidays!

If you’re looking at getting up to speed with some Windows Azure training , here are
some webcast dates for you to mark down and register for, including the upcoming Firestarter
event!

12/09: MSDN Simulcast Event: Windows
Azure Firestarter

11/29: MSDN
Webcast: Azure Boot Camp: Introduction to Cloud Computing and Windows Azure


12/06: MSDN
Webcast: Azure Boot Camp: Windows Azure and Web Roles


12/13: MSDN
Webcast: Azure Boot Camp: Worker Roles


01/03: MSDN
Webcast: Azure Boot Camp: Working with Messaging and Queues


01/10: MSDN
Webcast: Azure Boot Camp: Using Windows Azure Table


01/17: MSDN
Webcast: Azure Boot Camp: Diving into BLOB Storage


01/24: MSDN
Webcast: Azure Boot Camp: Diagnostics and Service Management


01/31: MSDN
Webcast: Azure Boot Camp: SQL Azure


02/07: MSDN
Webcast: Azure Boot Camp: Connecting with AppFabric


02/14: MSDN
Webcast: Azure Boot Camp: Cloud Computing Scenarios

Silverlight 5–Future Features Unwrapped

At the Silverlight
Firestarter
event today in Redmond (And broadcast live around the world) Scott
Guthrie kicked off the show with a very exciting look ahead at some of the planned
features for Silverlight 5. There were two strong themes to these new features “Premium
Media Experiences” and “Business Application Development”.

The enhancements to media include Hardware Decode and presentation of H.264 using
GPU support improving performance for lower power devices as well as “Trick Play”
capabilities to play videos at different speeds (Up to 2x) with pitch correction.
Improved power awareness will keep the screensaver from appearing while video is playing,
but also allows the system to sleep when video is paused. Remote control support will
also be added to media.

On the “Application” front, features improving text clarity and layout performance
and “Fluid” layout capabilities. OpenType support has been enhanced and tracking/leading
have been added. Enhancements have also been added for MVVM support and Databinding
enhancements.I swear I could here Josh Smith’s excitement all the way in here in NC
when he heard that Markup Extensions were being added as well. I think one of the
coolest demos of the day was John Papa setting breakpoints in XAML (Yes, in XAML)
and having the debugger stop when bindings were hit, providing the ability to step
through the binding process and make solving problems easier. A GPU accelerated API
was also shown, providing rich 3d visualization capabilities.

If you’re interested, a complete list of future
features is available here
as well as be sure to check out Scott’s
Blog
, Pete’s
Blog
, and Tim’s
Blog
for the latest info. (For info on the latest release of the WCF
Ria Services Toolkit, check out Jeff’s Blog!
) The information shared today was
a strong indication of the continued commitment Microsoft has to Silverlight, and
the exciting opportunities that exist for developers on the web, on devices, and on
the desktop with Silverlight!