Friday, May 29, 2009
Vista, Visual Studio 2008, SharedView and Azure
My dev environment for Azure is Vista and Visual Studio 2008 (along with a dozen other tools and SDKs). SharedView is just plain handy for quick collaboration, almost a necessity as well.
There is a simple trick to get them all to work together as expected. Visual Studio on Vista needs to 'Run As Administrator' for the dev fabric to work. Turns out that's the critical detail for SharedView, too. When I started ShareView with 'Run As Administrator', Visual Studio appeared for sharing and I was back to business as usual.
Tuesday, May 26, 2009
Jumping In To Windows Azure Storage Services

The community tech preview release of Windows Azure offers three different means of storing information “in the cloud.” These include Blob Storage, Queues, and Table Storage APIs. Each of these are often accessed through REST APIs, using the HttpWebRequest object. They can also be accessed through ADO Client Services.
At first glance, this seems quite tedious: you have to create a request, add headers, parse the response, possibly sign the request, and so on. However, there is a much easier way to access the storage services using a DLL shipped with the Windows Azure SDK.
Here are the steps to use the Storage Client DLL in your own Azure project. These steps assume you already have a working Windows Azure project and the necessary key for accessing the Storage Services. The example below will access queues. Similar techniques can be used for the other types of storage services. Note that much of this code can be found within the StorageClient project. This blog posting is meant to shorten the amount of time needed for someone new to Azure to start using these services. After jumping in, it would be very beneficial to go back to the StorageClient project and see exactly how this library wraps the HTTP calls.
1) Right-click on your web role project (or worker role) and add StorageClient.dll to your references. It should be located under {install path}\StorageClient\Lib\Bin\Debug\StorageClient.dll. If it is not, follow the instructions under the \StorageClient\readme.txt to build the application.
2) Add an <appsettings></appsettings> in your project, under the <configuration> tag. You will need to make sure that there are tags present for your AccountName, AccountSharedKey, and for each Storage endpoint you will be using. It will look something like this:
<add key = "AccountName" value="jtkirk"/>
<add key = "AccountSharedKey" value="rL+XAccN6J/Ie7AaiZoiC20JF8kwVedQyaCHYK/9b7x/Vw7VgkkVw7I3B3aQrIU7grMcpCuWnQpSsd9yfv3Ujw=="/>
<add key="QueueStorageEndpoint" value="http://jtkirk.queue.core.windows.net"/>
3) Be sure to include the StorageClient namespace in your code file with the using (C#) / imports (VB.NET) statement.
using Microsoft.Samples.ServiceHosting.StorageClient;
4) Whenever you want to access the REST APIs for the queues, you will do so though classes in the StorageClient namespace. To do this, you will need to access a created queue service using your storage account credentials. This is a sample for adding a Queue with queuename being a variable holding the name of a queue.
StorageAccountInfo account = null;
QueueStorage queueService = null;
account = StorageAccountInfo.GetDefaultQueueStorageAccountFromConfiguration();
queueService = QueueStorage.Create(account);
queueService.RetryPolicy = RetryPolicies.RetryN(2, TimeSpan.FromMilliseconds(100));
MessageQueue q = queueService.GetQueue(queuename);
bool result = q.CreateQueue(out exists);
if (!exists && result)
{
lblQueueStatus.Text = "Queue " + queuename + " has been created.";
}
else
{
lblQueueStatus.Text = "Queue " + queuename + " has NOT been created.";}
5) For other functions, take the same reference to the queueService and make direct calls against it. For example:
foreach (MessageQueue queue in queueService.ListQueues())
{
lbxQueues.Items.Add(queue.Name);
}
Similarly, you can search for Queues with certain prefixes, clear queues out, delete queues, peek at values in each queue and so on.
And that’s a quick way to jump into Azure Storage Services. You can find out more about about Windows Azure, and other Architectural Guidance topics from RDA through this blog and through Twitter.
RDA Architecture Twitter: rdaarchitecture
Personal Twitter: ipockrda
Saturday, May 23, 2009
NoVa Code Camp Presentation Materials
- Download and build the libraries from http://www.codeplex.com/compositewpf
- Start a new WPF application project
- Add references to either the built CompositeWPF libraries or the actual project files (it's probably more efficient to just reference the built libraries, in a common place)
- Delete Window1.xaml and create a new WPF Window called Shell.xaml
- Add the http://www.codeplex.com/CompositeWPF namespace to the namespaces in Shell.xaml
- Create one or more named regions in Shell.xaml.
- In App.Xaml, remove StartupUri (remember, we'll be loading the appropriate window with the bootstrapper).
- Create a new class, called Bootstrapper. Derive from UnityBootstrapper.
- In Bootstrapper, override CreateShell(): instantiate, show, and return the Shell window.
- In App.Xaml.cs, override OnStartup(). Create a new Bootstrapper object and call its Run() method.
- Add a module to your solution. This is a regular class library. Name it
Module. Make sure the class implements IModule, which requires the Initialize() method. - Create a view by adding a WPF user control to your new module. Start off simple, and just add something like a TextBlock so you can see your view later.
- Add an IRegionManager parameter to the constructor (which will be filled in by the Unity Container). Save it off in a member variable.
- Have the Initialize() method call RegisterViewsAndServices() (a private method on your module). In RegisterViewsAndServices(), register your module's view with the RegionManager, and assign it to one of your named regions.
- Now that your module exists, go back to your main app's project (ours was the Demo project). Add a reference to your new module. Then, in Bootstrapper.cs, override GetModuleCatalog(), and create a new catalog with your new module.
Friday, May 22, 2009
Cloud Computing with a Silver Lining
Unable to load Silverlight xap
The first issue was the inability to load the Silverlight application’s xap file when hosting from the WebRole project. Hosting the Silverlight application within the WebRole is essential to prevent the additional work of cross domain service calls. Cross domain calls are possible, but unnecessary when you’re developing and hosting both the Silverlight application and the Azure services.
As it turns out, I didn’t have the correct mime type configured for loading Silverlight apps. A simple addition to IIS did the trick: map the .xap extension to application/x-silverlight-app.
Unable to debug Silverlight app
I finally got the Silverlight app loaded. But for some reason, I couldn’t debug when running the WebRole project as the start up project.
The solution was buried in the project properties for the WebRole project. On the Web settings tab, there are a set of checkboxes that specify which debuggers are enabled. Once I selected Silverlight, all was well and I could debug my app.
This information is explained in more detail in Jim Nakashima’s MSDN blog post:
http://blogs.msdn.com/jnak/archive/2009/01/16/debugging-silverlight-in-a-web-role-on-the-development-fabric.aspx
Wednesday, May 20, 2009
ARCast.TV: Architecting the UI to Improve Testability
"In this interview,David Makogon, senior consultant of RDA, discusses how to architect user interface code to improve testability. A common issue associated with testing code that is tightly tied to user interface (UI) such as a button click event is that when a user interface is modified, the underlying code has to be re-tested. By decoupling the UI code from core programming logic and behavior through use of supervising controllers and views -- a modified Model View Controller (MVC) design pattern that is well explained by Martin Fowler, the need to re-testing the code of the programming logic and behavior is greatly reduced and even eliminated."

