Friday, April 29, 2011

NuGet adds symbol server support

Microsoft has partnered with the folks at to offer a really simple way of publishing your sources and PDB’s along with your NuGet package.

Up until now, there really wasn’t a great way for package authors to let their users debug into the package’s binaries. The user would have needed to download the sources separately from wherever the project is hosted, making sure that they exactly match the state of the binary. They would also need to locate the matching PDBs. That’s pretty hard to get right, and most users would generally not bother.

Now with almost no additional effort, package authors can publish their symbols and sources, and package consumers can debug into them from Visual Studio.

For more information, check out David Ebbo’s blog.

Thursday, April 28, 2011

Windows Phone 7 and the Enterprise

During the Easter holidays I’m trying to catch up with all the great content that was announced at MIX 11. Two very interesting improvements that Windows Phone users and developers can expect with the new Marketplace and App Hub in the Mango timeframe is focused on enterprise development.

The first one is the Beta Distribution Service. This allows developers to distribute pre-certified apps to an access-controlled set of beta users. How does it work?

  • The developer selects a list of up to 100 testers.( This number will probably change).
  • Developer sends an email to the designated testers that includes a private deeplink that points to the app in the Marketplace. This allows only the testers to access and download the content since the app is not discoverable in the Marketplace via Search.
  • Only testers selected in the App Hub based on their Windows Live ID can test the app and provide feedback for 90 days.
  • The beta cannot be updated. If you have multiple updates based on testing feedback, you must resubmit them like the first beta and send updated deeplinks to testers.
  • Testers won’t have to unlock their phone in order to beta test the apps.
  • Since there’s no certification requirement, there’s no latency between when you publish a beta app and when your private list of testers can access and download your content.
  • The cost of the beta app must be free.

The second one is the Private Distribution Service. This allows developers to privately distribute certified apps to a targeted group of users. How does it work?

  • The app must be certified by Microsoft before distributing.
  • Developer sends an email to the targeted group of users that includes a private deeplink that points to the app in the Marketplace. Keep in mind that the app is not discoverable in the Marketplace via Search by the general public.
  • A private app can be updated and pushed to the targeted group of users.
  • There are no limits on the number of users or the duration of time that those users can use the app.
  • There is no access enforcement based list of targeted users. In other words, if an employee at a company shares the deeplink with a fellow coworker, that new person can download the content. By including appropriate authentication and authorization mechanisms in published apps, you can prevent unwanted users from being able to do anything with the app.
  • Private apps can be free or paid
  • These private apps can be published to the public Marketplace at any time.

It isn’t yet a real enterprise software distribution system, but it already overcomes the single-biggest blocker that companies have when creating and publishing apps for Windows Phone. They don’t want their private corporate apps publicly viewable and/or accessible by the broad general public searching for apps in the public Marketplace.

This means IT departments will be able to build undiscoverable Windows Phone apps for private internal use by the users they designate. Some of the administrative issues around software distribution can be alleviated by having a corporate IT authority publish Beta and Private apps via a single Windows Live ID. That publishing administrator can then map users, groups or roles to existing or new Windows Live IDs of employees that need to use the app. That administrator will be able maintain the application lifecycle through beta testing, publishing, updating and decommissioning.

Can’t wait until the Mango update is out there!

Wednesday, April 27, 2011

Team Foundation Server and MS Project Server integration

Are you using Team Foundation Server and MS Project Server today? Want to learn how you can make these 2 products work together? You can now try the Team Foundation Server 2010 and Project Server Integration Feature Pack yourself. Just download the new virtual machine that is now available.  It has everything you need to start working with the integration between Project Server 2010 and Team Foundation Server 2010 SP1. A lot of work by a good group of people has gone in to get this VM out and now it should be super easy to learn & play with the integration. Not only is everything setup and configured already (which is half the battle when trying out new things) but you also get:

  • Four hands on labs that walk through the main scenarios that are supported by the integration.
  • Tons of sample active directory users that are available in both Team Foundation Server and the Project Server Enterprise Resource Pool that allow you to setup lots of different scenarios.
  • Sample data, team projects, and enterprise project plans to get you started.

Brian Keller has some additional information available on his blog:

Tuesday, April 26, 2011

Ordina TFS Monitor release announced

Today I’m giving a session at TechDays Belgium, were I have the pleasure to announce the first release(actually 1.1) of the Ordina TFS Monitor tool.  TFS Monitor is a free Windows Phone 7 application that I have developed together with the Ordina ALM team. With TFS Monitor all the data available inside your Team Foundation Server environment becomes available anywhere you are. Use your Windows Phone 7 device to connect to the Ordina TFS server and get always the most up to date information.
Thanks to the support of push notifications, you even get notified when important events happen inside the TFS environment.
The current version of the TFS Monitor app offers the following features:
  • Real time push notifications of TFS build, checkin and workitem events
  • Overview of your projects
  • List of work items
  • Work item Details
  • List of builds
  • Build Details
  • Events overview
clip_image002 clip_image004
clip_image006 clip_image008
Download TFS Monitor for free here or use the Windows Phone marketplace.
More information on the official site.

Monday, April 25, 2011

Enable windows authentication in an ASP.NET MVC 3 website

If you have installed the ASP.NET MVC 3 Tools Update, you’ll get a new project template called Intranet Application. The main difference between internet and intranet application templates is the way how users are authenticated. Let’s have a look at the difference compared to the default (Internet) template.

Start by creating a new ASP.NET MVC 3 web application. Select the Intranet Application as template.


You’ll see that the Intranet application is a practically empty web application with a home controller and Windows authentication in the web.config.  Now before you can start using the Windows authentication you’ll need to do some extra configuration:

If you are using IIS Express(recommended) then follow these steps:

  1. Right click on the project in Visual Studio and select Use IIS Express.
  2. Click on your project in the Solution Explorer to select the project.
  3. If the Properties pane is not open, make sure to open it (F4).
  4. In the Properties pane for your project:
    1. Set "Anonymous Authentication" to "Disabled".
    2. Set "Windows Authentication" to "Enabled".

Now try to run your application to see if you are correctly authenticated.


Saturday, April 23, 2011

.NET Framework 4 Platform Update

Last week Microsoft announced the release of Microsoft .NET Framework 4 Platform Update 1. This is a platform update that is a set of new features that provides additional functionality for top customer requests and important scenarios.

The features that are enabled in this update are:

Windows Workflow Foundation (WF)

The Microsoft .NET Platform Update 1 consists of three packages:

  • Microsoft .NET Framework 4 Platform Update 1 (KB2478063)

    • This package contains the runtime files for the platform update. This package must be deployed on systems where applications that target the platform update are deployed.

  • Multi-Targeting Pack for Microsoft .NET Framework 4 Platform Update 1 (KB2495638)

    • This package contains reference assemblies and intellisense files for the platform update. This package is installed as part of the next package.

  • Microsoft .NET Framework 4 Platform Update 1 – Design-time Package for Visual Studio 2010 SP1 (KB2495593)

    • This package installs the previous two packages and configures Visual Studio 2010 SP1 with new .NET Framework targeting profiles, intellisense, and adds the state machine activities to the toolbox.

To develop workflow applications in Visual Studio 2010 SP1 that target the new Platform Update 1 functionality, the Microsoft .NET Framework 4 Platform Update 1 – Design-time Package for Visual Studio 2010 SP1 (KB2495593) must be installed. Once it is installed, the .NET Framework 4 Platform Update 1 (KB2478063) profile can be chosen when creating a new .NET application.

There are two new profiles added to Visual Studio when the Design-time Package for Visual Studio 2010 SP1 (KB2495593) is installed.

  • .NET Framework 4 Platform Update 1 (KB2478063)

  • .NET Framework 4 Client Profile Platform Update 1 (KB2478063)

When a new project is created with the platform update profile selected, the .NET Framework 4 Client Profile Platform Update 1 (KB2478063) is used. The .NET Framework 4 Platform Update 1 (KB2478063) profile builds on the .NET Framework 4 profile, and the .NET Framework 4 Client Profile Platform Update 1 (KB2478063) profile builds on the .NET Framework 4 Client Profile. The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. For more information, see .NET Framework Client Profile.

To configure .NET Framework 4 Platform Update 1 on computers with Visual Studio 2010 SP1 that are going to be used to develop applications that target the functionality in the platform update, install Microsoft .NET Framework 4 Platform Update 1 – Design-time Package for Visual Studio 2010 SP1 (KB2495593).

To configure a computer on which applications that target the .NET Framework 4 Platform Update 1 are to be deployed, deploy Microsoft .NET Framework 4 Platform Update 1 (KB2478063) and the appropriate version of the .NET Framework 4.

Friday, April 22, 2011

ArchitecT contains the T of Team

As a consultant I’m mostly assigned on jobs in the architect role. So I’m actually talking against my own function here. Nevertheless I want to share my opinion.

During an intake I had a discussion with the interviewer(never a good idea) about the role of an architect. In their organisation an (application) architect only creates the software architecture and then throws his solution over the wall to the development team. What’s even worse is that the original architect takes only a cursory glimpse at the progress from time to time. This made me wonder how they knew that their software architecture was working as expected. Apparently that wasn’t important, it is up to the development team to implement the architecture ‘correctly’.

A successful software project requires the initial vision to be understood, communicated and potentially evolved throughout the entirety of the software development lifecycle. For this reason alone, it doesn't make sense for one person to create that vision and for another team to (try to) deliver it. One of the consequences is that you see a lot of developers struggling and cursing the architecture because they’ve never been told what the vision behind the architecture is.

I tend to approach this problem in a completely different fashion. With the idea of  self-organising teams, I involve the whole team in (almost) all design decisions. By doing this they understand and support the vision, we get a shared ownership of the architecture and a much better result in the end.  

My role extends from putting together a high-level design that is sensitive to the context and environmental factors at the beginning of a project to a continuously adjustment and steering of the team vision and architecture.

Thursday, April 21, 2011

Mix 2011: Windows Phone 7 updates

At the MIX 2011 a lot of announcements were made. So it’s my duty to highlight some of the stuff that is coming to us in the near future.

No long explanation, just everything you need to know about ‘Mango’:


  • update is schedule for the fall
  • all existing phones and new phones will get the update
  • 16 additional languages will be supported
  • more countries where we can create apps (from 30 to 38)
  • more countries where we can buy apps (from 16 to 35)

Marketplace / Search

  • better apps list: filter by letters (like with the contacts)
  • new search button to search for a particular app
  • better marketplace
    • more information with less confusion (music and apps are no longer mixed)
    • search for podcasts
    • new “related” pivot item when seeing an app for related app
  • we can integrate an app with the search feature of the phone

Web Experience

  • the update include IE9
  • the core engine is the same code base that the one we found desktop : including HW acceleration
  • address bar is moved to the bottom
  • support background audio for HTML5: you can leave IE and keep listening to the music !
  • tabbed UI for navigating between tabs
  • support for H264 video


  • improved panorama and pivot control
  • improvements for live tiles
  • access to the ring tones settings (set a music files as ring tone programmatically)
  • TCP/IP sockets
  • SQL database
  • more launchers and choosers
  • data access to the contacts and calendars on the phone
  • better integration with the sensors on the phone (like RAW camera access)
  • Skype coming to the platform this fall (leveraging many of those new features)
  • pin live tiles with deep link to our apps (which would launch the app and give the link as parameter)
  • Silverlight 4 features support
  • applications can now contains both Silverlight and XNA content


  • Spotify coming to WP7 using new multitasking capabilities
  • fast-app switching
  • use “live agents” to prevent battery life


  • new version of tools will be available next month !
  • new capabilities in the emulator: simulate accelerometer and location sensors right from the emulator
  • new profiling support


  • scrolling: totally smooth scrolling without any changes in our applications !
  • image decoding
  • garbage collection
  • memory usage

Wednesday, April 20, 2011

Mix 2011: Azure Updates continued

At the MIX 2011 a lot of announcements were made. So it’s my duty to highlight some of the stuff that is coming to us in the near future.

Next to all the new functionality I’ve blogged about before, there is also some very interesting news in terms of licensing and offering:

  • The extension of the expiration date and increases to the amount of free storage, storage transactions and data transfers in the Windows Azure Introductory Special offer. This promotional offer now includes 750 hours of extra-small instances and 25 hours of small instances of the Windows Azure service, 20GB of storage, 50K of storage transactions, and 40GB of data transfers provided each month at no charge until September 30, 2011. More information can be found here.
    • An existing customer who signed up for the original Windows Azure Introductory Special offer will get a free upgrade as of today. An existing customer who signed up for a different offer (other than the Windows Azure Introductory Special) would need to sign up for the updated Windows Azure Introductory Special Offer separately.
  • MSDN Ultimate and Premium subscribers will benefit from increased compute, storage and bandwidth benefits for Windows Azure. More information can be found here.
  • The Cloud Essentials Pack for Microsoft partners now includes 750 hours of extra-small instances and 25 hours of small instances of the Windows Azure service, 20GB of storage and 50GB of data transfers provided each month at no charge. In addition, the Cloud Essentials Pack also contains other Microsoft cloud services including SQL Azure, Windows Azure AppFabric, Microsoft Office 365, Windows Intune and Microsoft Dynamics CRM Online. More information can be found here.

Tuesday, April 19, 2011

Mix 2011: Azure updates

At the MIX 2011 a lot of announcements were made. So it’s my duty to highlight some of the stuff that is coming to us in the near future.

New & Updated Windows Azure Features
  • An update to the Windows Azure SDK that includes a Web Deployment Tool to simplify the migration, management and deployment of IIS Web servers, Web applications and Web sites. This new tool integrates with Visual Studio 2010 and the Web Platform Installer. Get the tools from Download Windows Azure SDK.
  • A community technology preview (CTP) of Windows Azure Traffic Manager, a new service that allows Windows Azure customers to more easily balance application performance across multiple geographies. To get the CTP, see the Windows Azure Traffic Manager section of Windows Azure Virtual Network.
  • A preview of the Windows Azure Content Delivery Network (CDN) for Internet Information Services (IIS) Smooth Streaming capabilities, which allows developers to upload IIS Smooth Streaming-encoded video to a Windows Azure Storage account and deliver that video to Silverlight, iOS and Android Honeycomb clients.
  • Updates to the Windows Azure AppFabric Access Control service, which provides a single-sign-on experience to Windows Azure applications by integrating with enterprise directories and Web identities.
  • Release of the Windows Azure AppFabric Caching service in the next 30 days, which will accelerate the performance of Windows Azure and SQL Azure applications.

I’m especially excited about the Smooth Streaming capabilities because a lot of my customers wanted to host streaming media on Azure. Now we can finally target not only Silverlight but also other devices and platforms like iPhone, iPad and Android.

Monday, April 18, 2011

TFS Project Server Integration Pack Licensing

Together with Visual Studio 2010 SP1 and Team Foundation Server 2010 SP1 Microsoft also released the TFS Project Server Integration Feature Pack(what a name!). You can download the feature pack from the MSDN subscribers site.

This feature pack enables teams to work together more effectively by:

  • Providing up to date insight into portfolio execution, alignment with strategic objectives, and resource utilization of software development projects by leveraging the quantitative data stored in different systems.
  • Automating the exchange and sharing of project information across teams and improving coordination between teams using disparate methodologies, like waterfall and agile, via common data and agreed upon metrics.
  • Enabling development and project management teams to use familiar tools to collaborate and communicate project timeline and progress such as Microsoft Visual Studio, Project, and SharePoint.

As I got some questions about the licensing aspect, here is what you need to know if you want to introduce this pack in your environment:

TheFeature Pack will only be available to Visual Studio 2010 Ultimate with MSDN subscribers (go to your MSDN download center, you should find the Visual Studio Team Foundation Server 2010 and Project Server Integration Feature Pack as an available download). An organization must own at least one license of Visual Studio 2010 Ultimate with MSDN. With that one license, the software can be downloaded and installed and then all users with access to either the Project Server or the Team Foundation Server products that are integrated can benefit.

So buy one VS2010 Ultimate license with MSDN and you are good to go!

Saturday, April 16, 2011

Windows Phone Programming in C#

Interested in developing for the Windows Phone but you don’t know where to start?

I found this material, created by Rob Miles, it’s an introduction to Windows Phone development for anyone learning to program. It contains 8 sections with labs, PowerPoint presentations, demos and detailed notes.

So if you really want to start from scratch, a must read!

Friday, April 15, 2011

Debugging JSON results

With the renewed interest in jQuery and AJAX,  we sooner or later need to check some JSON results. Just opening the browser and typing the url will not result in some JSON  directly in the browser(with the exception of Chrome).

Enter JSONView which allows you to simply display JSON results directly in the browser.

Normally when encountering a JSON document content type "application/json", Firefox simply prompts you to download the file. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.

Note that this is a Firefox add in. To get a similar experience in IE to you can add a Mime type mapping in the registry:

Create a new application/json key in:

  • HKEY_CLASSES_ROOT\MIME\Database\ContentType\application/json

  • Add a string value of CLSID with a value of {25336920-03F9-11cf-8FD0-00AA00686F13}

  • Add a DWORD value of Encoding with a value of 80000

Thursday, April 14, 2011

Combining ASP.NET WebForms and ASP.NET MVC

I created a page route to integrate my MVC application with a WebForms page that exist in my project:

public static void RegisterRoutes(RouteCollection routes)
// register the report route    
routes.MapRoute("Default","{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

This works when browsing to the specific url’s. However, I noticed this route created a problem whenever I use an  Html.ActionLink in my Views:

<%: Html.ActionLink("Home", "Index", "Home") %>

When I load the page in the browser the link appears like:


Unfortunately I can't place the route at the bottom, since the webform route has more specific parameters than the MVC route. I was able to solve this problem by introducing a new constraint.

I created a new constraint called IncomingRequestConstraint. This constraint  simply return false for outgoing Urls(so that all Html helpers will work as expected).

public class IncomingRequestConstraint : IRouteConstraint
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
return routeDirection==RouteDirection.IncomingRequest;

In the global.asax, I added this constraint to the WebForms route:

// register the report routes    
routes.MapPageRoute("Reports","Reports","~/Pages/ReportViewer.aspx", false, null, new RouteValueDictionary(new { controller = new IncomingRequestConstraint() }));    

Wednesday, April 13, 2011

Build Explorer Tool

Last week I noticed the release of a nice Team Explorer extension, the Build Explorer. This tool allows you to organize your build definitions in a very simple way. By following a specific naming convention for build definitions parts of the name are presented as folders.

So, for instance, a build definition called ALM.TFS.Gated would be rendered as:

The “.” is a separator character (and is configurable, of course). The source code are published at

Tuesday, April 12, 2011

TF214007: No build was found with the URI

For one Team Project in Team Foundation Server, we noticed that every build definition we created failed with the following error:

“TF215097: An error occurred while initializing a build for build definition \TestTeamProject\New Build Definition 1: TF214007: No build was found with the URI vstfs:///Build/Build/56720. Either the URI does not exist, or domain\tfsserviceuser does not have permission to access it.”

If you read the description, there are 2 reasons why this can happen:

  1. The build URI does not exists. (Every build gets a unique URI assigned.) 
  2. The user does not have the permission to access the build definition»

We solved the issue by adding the tfs build user to the TeamProject’s [Build Services] group. Still a little bit weird because I didn’t had to do this for other projects…

Monday, April 11, 2011

WP7: Pivot bug

In a WP7 application we are building we have a databound pivot control:

<controls:Pivot x:Name="Pivoter" Title="{Binding Title}"
TitleTemplate="{StaticResource PivotTitleTemplate}"
HeaderTemplate="{StaticResource PivotHeaderTemplate}"
ItemsSource="{Binding Items}"      
ItemTemplate="{StaticResource DisplayItemDataTemplate}">
</controls:Pivot >

The Items property we are binding to is an observablecollection. When the page is displayed it creates all of the pivot items but the first item does not get created unless I scroll forward and back to it. It has an entry in the scroll list but no PivotItem control.

I couldn’t find a good reason what causes this, but I have a workaround. By setting the pivot-controls SelectedIndex to 1 in the page-loaded-event, it magically started working.

Its not an ideal solution, but it works.

Saturday, April 9, 2011

Try F#

Try F#Interested in learning F#?  This will become your first learning source: the Try F# website!

TryF# is a new tool from Microsoft Research Connections that enables the learning of the F# programming language in an interactive browser-based environment. TryF# makes F# accessible to users with Windows and Macs when using common browsers, and the team are actively working on Linux support as well.

TryF# also has an online training tool to introduce users to F# and it provides a portal for information about the language and its growing community, linking them through Facebook and Twitter.

Go to

Thursday, April 7, 2011

WP7: Capturing screenshots

One of the criteria to publish your application to the MarketPlace is that you include a screenshot in PNG format with dimensions 480x800 pixels. And yes, it must be exactly this size.


So I used the free snipping tool inside Windows 7 to take a “Window snip” from inside the emulator. Unfortunately this snip wasn’t the correct size.

Don’t open Photoshop or Paint.NET and start resizing your image. Instead hover over the emulator and click the zoom icon that appears on the right. Change the zoom level to 100%  and capture the image again. This gives you a pixel-perfect image to upload to MarketPlace.


Note: An even simpler solution is downloading the WP7 screenshot tool.

Wednesday, April 6, 2011

WP7: Application Deployment Error - This operation returned because the timeout period expired

When trying to deploy a WP7 app  inside Visual Studio to the device, it suddenly started to fail with the following error:

“Error - This operation returned because the timeout period expired.”

Same problem when using the deployment tool. Restarting my phone, restarting my pc,… nothing worked. So I started to think what was different then before.

I realized that my Wi-Fi connection was enabled on the Phone. Could that be the problem? So I disabled Wi-Fi again, tried to deploy and indeed this time it worked!

Tuesday, April 5, 2011

WP7: An error occurred while accessing IsolatedStorage.

While debugging my Windows Phone 7 app in the emulator, each time the application was tombstoned or closed, the following exception was raised:

An error occurred while accessing IsolatedStorage.

at System.IO.IsolatedStorage.IsolatedStorageSecurityState.EnsureState() at System.IO.IsolatedStorage.IsolatedStorageFile.get_AvailableFreeSpace() at System.IO.IsolatedStorage.IsolatedStorageSettings.Save() at System.IO.IsolatedStorage.IsolatedStorageSettings.TrySave() at System.IO.IsolatedStorage.IsolatedStorageSettings.SaveAllSettings() at MS.Internal.FrameworkCallbacks.ShutdownAllPeers()

The error is clear, there is a problem with accessing the IsolatedStorage. But why?

If I didn’t debug the application or when I deployed to a real phone, I never noticed the issue. So I hope it’s related to a bug in the emulator. ..

Anyone out there who is having the same problem?

Monday, April 4, 2011

Useful Visio Shapes

As an application architect, Visio is just one other tool in my toolbox to express application designs and architectures. After re-installing Visio I noticed that some shapes I was using before were gone. I knew that I downloaded them from somewhere but no idea where I got them.

Visio shapes are stored in what is called Microsoft Office Visio stencils. (If you search on Visio stencils, you’ll find a lot of free shapes). The one I was interested in was part of the Microsoft Exchange stencil, available for free here.

After downloading, execute the file. A folder is created with 2 files(MicrosoftExchangeServer2007_Icons.vst and MicrosoftExchangeServer2007_Icons.vss). Copy these 2 files in your local My Documents\My Shapes folder.

In Visio, click File, click Open, and then go to your My Shapes folder. Open the MicrosoftExchangeServer2007_Icons.vst file. The shapes will appear in the Microsoft Exchange Server 2007 stencil in the Shapes pane.

Saturday, April 2, 2011

Visual Studio 2010 Training Kit March 2011 update

With the large amount of updates and new tools that Microsoft keeps throwing at us, you sometimes miss one.

One recent updated that I just noticed, was an update of the Visual Studio 2010 Training Kit.

You can download the Training Kit by going here:

Or if you want to view it online, you can go here:

All content has been tested to work with Visual Studio 2010 SP1. The setup scripts for all hands-on labs and demo scripts have also been updated so that the content can easily be used on a machine running Windows 7 SP1.

And finally a list of the new content:

Silverlight 4
  • Hands-on Lab - Migrating a Windows Forms Application to Silverlight
  • Hands-on Lab - Migrating an ASP.NET Web Forms Application to Silverlight
  • Hands-on Lab - Working with Panels, XAML and Controls
  • Hands-on Lab - Silverlight Data Binding
  • Hands-on Lab - Migrating Existing Applications to Out-of-Browser
  • Hands-on Lab - Great UX with Blend
  • Hands-on Lab - Web Services and Silverlight
  • Hands-on Lab - Using WCF RIA Services
  • Hands-on Lab - Deep Dive into Out of Browser
  • Hands-on Lab - Using the MVVM Pattern in Silverlight Applications
Windows Azure
  • Hands-on Lab – Introduction to Windows Azure
  • Hands-on Lab – Debugging Applications in Windows Azure
  • Demo Script – Hello Windows Azure
  • Demo Script – Deploying Windows Azure Services
  • Presentation – Windows Azure Platform Overview
  • Video – What is Windows Azure?

WP7 Tips

Building WP7 apps is fun and challenging. Every tip that can help improving the application experience is welcome!

Jeff Wilcox, the creator of the 4th & Major app, published a checklist with some great tips focussing on the Windows Phone user interface.


Friday, April 1, 2011

Windows Azure Drives

The Azure Drive feature gives you access to data contained in an an NTFS-formatted virtual hard disk (VHD) persisted as a page blob in Azure Storage. Important to notice is that although you can access the drive using normal IO code, it is NOT a shared disk between all your Windows Azure instances. Only a single Azure instance can mount a page blob for read/write access as an Azure Drive. However, multiple Azure instances can mount a snapshot of a page blob for read-only access as an Azure Drive.

Mounting a VHD as an Azure drive

The VHD for an Azure Drive must be a fixed hard disk image formatted as a single NTFS volume. It must be between 16MB and 1TB in size. A VHD is a single file comprising a data portion followed by a 512 byte footer.  When uploading a VHD it is consequently important to remember to upload the footer. Furthermore, since pages of a page blob are initialized to 0 it is not necessary to upload pages in which all the bytes are 0. This could save a significant amount of time when uploading a large VHD.

The Disk Management component of the Windows Server Manager can be used to create and format a VHD by performing the following steps:

  • Right click on Disk Management and select Create VHD
  • Specify a fixed size VHD and provide a location and the size in MB
  • Right click on the disk icon and select Initialize Disk
  • Specify MBR (Master Boot Record)
  • Right click on the unallocated space and select New Simple Volume
  • Follow the Wizard choosing the defaults - specifically including the quick format with NTFS

The VHD is now created and accessible as a new drive using Windows Explorer. It can be used just like any other drive. The Detach VHD entry on the Disk Management right-click menu can be used to detach the VHD making it no longer accessible as a drive. This does not delete the VHD file. Similarly, the Attach VHD menu item can be used to once again make the VHD accessible as a file system.

Once created and detached, this VHD can be uploaded as a page blob to Azure Storage. Not all tools support uploading page blobs, but the Azure storage explorer should do the trick.

Using the Azure drive on an instance

To access the drive, we need a CloudDrive object. This object can be created using either the constructor or the CreateCloudDrive extension method to CloudStorageAccount.

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
CloudDrive cloudDrive = cloudStorageAccount.CreateCloudDrive(cloudDriveUri.AbsoluteUri);

These assume that the CloudStorageAccount.SetConfigurationSettingPublisher() as has been invoked previously. Note that these only create an in-memory representation of the Azure Drive which still needs to be mounted before it can be used.

Some important considerations:

  • A VHD page blob can be mounted on only one instance at a time.
  • A VHD snapshot can be mounted readonly to an unlimited number of instances.

Before a VHD page blob can be mounted it is necessary to allocate some cache space in the local storage of the instance. This is necessary even if caching is not going to be used. This caching is a read cache. Local storage must be defined in the Azure Service Definition file as explained in this post and should be configured with cleanOnRoleRecycle set to false.

<LocalStorage name="CloudDrives" cleanOnRoleRecycle="false" sizeInMB="50" />

InitializeCache() must be invoked to initialize the cache with a specific size and location.

public static void InitializeCache()
LocalResource localCache = RoleEnvironment.GetLocalResource("CloudDrives");

An instance mounts a writeable Azure Drive by invoking Mount() on a VHD page blob. The Azure Storage Service uses the page blob leasing functionality to guarantee exclusive access to the VHD page blob. An instance mounts a read-only Azure Drive by invoking mount() on a VHD snapshot. Since it is read-only it is possible for multiple instances to mount the VHD snapshot simultaneously. An instance invokes the Unmount() method to release the Azure Drive and for VHD page blobs allow other instances to mount the blob for write access.

The cacheSize parameter to Mount() specifies how much of the cache is dedicated to this Azure Drive. The cacheSize should be set to 0 if caching is not desired for the drive. Different Azure Drives mounted on the same instance can specify different cache sizes and care must be taken that the total cache size allocated for the drives does not exceed the amount of cache available in local storage. The options parameter takes an DriveMountOptions flag enumeration that can be used to force the mounting of a drive – for example, when an instance has crashed while holding the lease to a VHD page blob – or to fix the file system. Mount() returns the drive letter, or LocalPath, to the Azure Drive - for example, "d:" - which can be used to access any path on the drive.

public void WriteToDrive( Uri cloudDriveUri )
CloudStorageAccount cloudStorageAccount =
cloudDrive = cloudStorageAccount.CreateCloudDrive(cloudDriveUri.AbsoluteUri); 

String driveLetter = cloudDrive.Mount(CacheSizeInMegabytes, DriveMountOptions.None); 

String path = String.Format("{0}\\hellodrives.txt", driveLetter);
FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);
StreamWriter streamWriter = new StreamWriter(fileStream);
streamWriter.Write("that you have but slumbered here");


GetMountedDrives() provides access to a list of drive letters for all Azure Drives mounted in the instance. It is used as follows:

public static void EnumerateDrives()
IDictionary<String,Uri> listDrives = CloudDrive.GetMountedDrives();
foreach (KeyValuePair<String,Uri> drive in listDrives)
String driveInformation = String.Format("drive: {0} - uri: {1}", drive.Key, drive.Value.AbsoluteUri);
Trace.WriteLine(driveInformation, "Information");