Thursday, July 12, 2012

Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Have you seen the following error recently while trying to use the new Windows Azure Media Services features:

Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I received the above error while attempting to use the Windows Azure Media Services SDK v1.0 CloudMediaContext class:

return new CloudMediaContext("myAccount", "myAccountKey");

After looking at the pre-binding probe log, I found this:

=== Pre-bind state information ===
LOG: User = \
LOG: DisplayName = Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase =
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.WindowsAzure.MediaServices.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Workspaces\Windows Azure Media Services SDK Samples Project\C#\bin\Debug\MediaServicesSDKSamples.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client.DLL.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client/Microsoft.Data.Services.Client.DLL.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client.EXE.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client/Microsoft.Data.Services.Client.EXE.


It seems the Media Services DLL is dependent on the out-of-band WCF Data Services OData assembly v5.0.

There is a lot of talk on the web that these issues is due to the fact that Windows Azure Media Servers v1.0 only works with the Windows Azure SDK v1.6 and will not work with Windows Azure SDK v1.7 installed as well, for a thread on this, see here: http://social.msdn.microsoft.com/Forums/en-US/MediaServices/thread/d02e268e-e30a-481d-acb7-138646a0c4fb

But..I didn't read the pre-requisite documentation correctly and once I installed WCF Data Services v5.0 all was ok:

Figure 1: WCF Data Services 5 installer
You can find the pre-requisites here: http://msdn.microsoft.com/en-us/library/jj129588


Monday, June 11, 2012

Microsoft server software support for Windows Azure Virtual Machines

I keep getting asked questions as to what and what will not run on the new Windows Azure Virtual Machine services. This is in regards to Micosoft server, features and roles on Microsoft platforms.

This Microsoft support article will hopefully clear up this confusion (note this is suject to change): http://support.microsoft.com/kb/2721672

Tuesday, May 01, 2012

SQL Azure vs Microsoft SQL Server

I've been working on a response to an RFI recently and I needed to list the limitations of SQL Azure over SQL Server.

There are limitations, but there is one major advantage of SQL Azure over SQL Server and that is clustering. SQL Azure out of the box gives me a three node active cluster without doing a single thing. This is because for every write operation on SQL Azure, you get the same data written to two other databases within the same data centre.

As we are on the subject of advantages, there is actually one-other major advantage, and that is it makes it easier to synchronise your SQL Azure database to provide synchronisation with another data centre for resilience using the DataSync component which is based on the SyncFramework which is very easy to use and setup. Synchronising SQL Server is a little more complex as you have more choice albeit, you could use the SyncFramework also, in a clustered environment you'd normally use mirroring or in BizTalk server log shipping. Now you'd use AlwaysOn Availability Groups provided by SQL Server 2012 - not yet released BTW.

I found this really good technet resource that compares SQL Azure features with SQL Server: http://social.technet.microsoft.com/wiki/contents/articles/996.compare-sql-server-with-sql-azure.aspx#Scalability

But for convenience, I provided the table here on my blog (for my benefit in the future too!):

Feature
SQL Server (On-premise)
SQL Azure
Mitigation
Data Storage
No size limits as such
* The Web Edition Database is best suited for small Web applications and workgroup or departmental applications. This edition supports a database with a maximum size of 1 or 5 GB of data.
* The Business Edition Database is best suited for independent software vendors (ISVs), line-of-business (LOB) applications, and enterprise applications. This edition supports a database of up to 150 GB of data, in increments of 10 GB.
Exact size and pricing information can be obtained at Pricing Overview
· An archival process can be created where older data can be migrated to another database in SQL Azure or on premise.
· Because of above size constraints, one of the recommendations is to partition the data across databases. Creating multiple databases will allow you take maximum advantage of the computing power of multiple nodes. The biggest value in the Azure model is the elasticity of being able to create as many databases as you need, when your demand peaks and delete/drop the databases as your demand subsides. The biggest challenge is writing the application to scale across multiple databases. Once this is achieved, the logic can be extended to scale across N number of databases.
Edition
· Express
· Workgroup
· Standard
· Enterprise
* Web Edition
* Business Edition
For more information, see Accounts and Billing in SQL Azure

Connectivity
· SQL Server Management Studio
· SQLCMD
* The SQL Server Management Studio from SQL Server 2008 R2 and SQL Server 2008 R2 Express can be used to access, configure, manage and administer SQL Azure. Previous versions of SQL Server Management Studio are not supported.
* SQLCMD

For more information, seeTools and Utilities Support Description: http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png .
Data Migration

For more information, seeMigrating Databases to SQL Azure

Authentication
* SQL Authentication
* Windows Authentication
SQL Server Authentication only
Use SQL Server authentication
Schema
No such limitation
SQL Azure does not support heaps. ALL tables must have a clustered index before data can be inserted.
Check all scripts to make sure all table creation scripts include a clustered index. If a table is created without a clustered constraint, a clustered index must be created before an insert operation is allowed on the table.
TSQL Supportability
Certain Transact-SQL commands are fully supported; some are partially supported while others are unsupported.
* Partially Supported Transact-SQL: http://msdn.microsoft.com/en-us/library/ee336267.aspx
“USE” command
Supported
In Microsoft SQL Azure Database, the USE statement does not switch between databases. To change databases, you must directly connect to the database.
In SQL Azure, each of the databases created by the user may not be on the same physical server. So the application has to retrieve data separately from multiple databases and consolidate at the application level.
Transactional Replication
Supported
Not supported
You can use BCP or SSIS to get the data out on-demand into an on premise SQL Server. When this article is being updated, the Customer Technology Preview of SQL Azure Data Sync is also available. You can use it to keep on-premise SQL Server and SQL Azure in sync, as well as two or more SQL Azure servers.
For more information on available migration options, seeMigrating Databases to SQL Azure Description: http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png .
Log Shipping
Supported
Not supported
Database Mirroring
Supported
Not supported
SQL Agent
Supported
Cannot run SQL agent or jobs on SQL Azure
You can run SQL Server Agent on your on-premise SQL Server and connect to SQL Azure Database.
Server options
Supported
Some system views are supported
For more information, see System Views (SQL Azure Database) on MSDN.
The idea is most system level metadata is disabled as it does not make sense in a cloud model to expose server level information
Connection Limitations
N/A
In order to provide a good experience to all SQL Azure customers, your connection to the service may be closed. For more information, see General Guidelines and Limitations on MSDN and SQL Azure Connection Management.
SQL Server Integration Services (SSIS)
Can run SSIS on-premise
SSIS service not available on Azure platform
Run SSIS on site and connect to SQL Azure with ADO.NET provider


Saturday, April 28, 2012

My first week at Microsoft

***non-techie - personal post***

For those who don't know, I recently joined Microsoft and work on the World Wide Windows Azure Centre of Excellence team - a small team of highly skilled technical people, many of which have been at Microsoft for a number of years in different organisations. We are known internally as "Azure COE".

The team is based out of Redmond, WA but I live in the UK and my responsibility is the EMEA region but no doubt, I will get involved in other regions as well once I get settled in. This is no doubt the best job I have ever had, I know it is early days but that is my feeling right now. I am no longer billable, so my responsibilities are to help customers, internal employees and partners be successful in deploying Windows Azure as a technology solution from an architectural and technology perspective.

It is up to me to define what I will take ownership of, this truly excites me. I will take a few weeks to determine gaps, strategic direction and areas where I can focus more of my time and this is what I find the best thing about this role.

It is also a very exciting time for anyone in our industry to be involved in cloud computing. Everyone that is, ISV's, SI's (System Integrator's), CIO's, CTO's should at least consider a cloud platform as a tool to be used in the vast tool set for any business problem that can be solved using technology today. It might not be the correct technology to use in all cases but it should be considered like any other.

My first day, I arrived in Reading, Thames Valley Park, UK (known as Microsoft UK). I was quite tired when I arrived after a 3.5 hr drive due to the M25 London orbital motorway (known here as the car-park) being congested as ever. I actually found myself watching BBC News 24 on my Samsung Galaxy S2 device while parked up on the motorway! It saved me from extreme boredom.

After checking-in, I met up with Tim Furnell who was acting as "host manager" to bed me into Microsoft nicely. Tim did a good job of getting all the things I needed and getting connected to corp net.

The next day I worked from home and did a lot of NDA stuff that I can't talk about but you will eventually hear about in the future. This is another cool thing about the job. I get to hear about, work-on technology before it's even announced publicly. This enables me to make better decisions for our customers and to be more well informed in what's coming. I also get to address what is known as "whitespace" areas which are gaps in Microsoft products.

That's another thing they love here - home-working, office-working, coffee-shop wherever, it doesn't matter where you work so long as you get your work done. Not a 9-5 person? - doesn't matter! They promote the use of on-line conference calls all the time. I have calls pretty much every day over Lync (internal VoIP).

Then the next two days I spent time with my colleague Dennis Mulder from the Netherlands. After these two days my head was rather full of information. You don't realize just how big and how much information is at your finger-tips until you work here.

Think of the biggest library you have ever set foot-in, multiply it by about 1000 then you might come close to the vast quantity of information available here at Microsoft.

Microsoft are very supportive in pretty much every area you can think of. But the most important to me is learning, they totally promote it. You'd think this would be the same for all companies, but many other companies are interested in your billable time first and foremost and not you as an individual and your aspirations and career goals.

I'm also finding everything highly efficient and smooth running. It's because everything is automated - where it can be. Example, applying for a AMEX corp card, I applied using //... (DNS) is used for everything there is a name for everything i.e. //training //sqlsvr etc... then after applying, the next day the card turned up!

Booking travel, hotels, cars is automated and billed to your cost centre to reduce admin expense claims. So far the next 3 months will be fairly busy and a bit of international travel for some really interesting events.

Dennis and I will be running the Tech Ed 2012 EMEA Pre-Conference Azure bootcamp workshop in June, so if you're going we'll see you there!

And finally, if you're from Microsoft reading this and need the Azure CoE's help within EMEA, ping me internally (note we are free - non-UBI).

Saturday, April 14, 2012

SQL Server setup does not support the language of the OS or does not have ENU localized files

I encountered a very strange error this morning when attempting to install Microsoft SQL Server R2 EN Standard Edition from my file server which I have successfully done many times before - mainly from VM's. 

Today, when I attempted to run the SQL installer on a fairly new Windows 7 EN OS physical machine, I got the following error:



I tried some of the workarounds mentioned on Connect above, none worked. So as my machine is a dev machine, I'm happy to put the developer edition on which doesn't appear to be localized?!?

But before doing this I really wanted to figure out why I was getting this problem. I am running an English version of Windows that is set to the United Kingdom as the locale. Why is this not working for me!?

So then as I was attempting to install from a network file server, I thought I'd burn to disc and then try it from a DVD. So I fired up Windows 7 USB/DVD Download Tool (get the code from here: http://wudt.codeplex.com/). Ran it and I got this error:



So this is really weird as I have installed SQL Server from that ISO before (at least I think I have).

So in the end I downloaded a new fresh copy of SQL Server, ran it from the network server and it worked! So this error for me was a red hearing.

Tuesday, April 03, 2012

Windows Azure Traffic Manager to handle your public cloud DR strategy

I did a talk last month at the Windows Azure User Group in London. To be honest I had too much content to get through and part of my talk was to talk about drastic recovery otherwise known as disaster recovery (DR). I ran out of time and didn't get a chance to talk about it unfortunately.

What is Drastic (Disaster) Recovery
Some people say DR is not possible or difficult to implement in a Cloud Platform such as the PaaS model. This is in contrast to Cloud Platform IaaS as you have more control over hardware/configuration in a IaaS environment than you do in PaaS. But hopefully after you have read this article, you'll soon realise it is very easy now in Windows Azure.

For people not aware of DR, I'll explain it using a picture that illustrates the problem when using Windows Azure, consider figure 1 below:
Figure 1: Basic drastic recovery fail over configuration
In the above diagram we have some roles running in a Windows Azure data centre in both Europe and North Central US and a consumer that is consuming from 1 data centre, Europe.

The configuration depicted above is known as a failover or active/passive configuration which is very commonly found in drastic recovery configurations in the enterprise today. If the above were a private data centre whether this is private cloud or a traditional data centre, it would look almost identical.

When you deploy an application in an Azure data centre, you can't spread it across multiple data centres for resiliance or to implement DR. Well you can but you'll get a different URL for each data centre you deploy your application into. For example for the Europe data centre above, our full URL could be: http://myamazingapp-europe.cloudapp.net/

Then for the North Central US data centre, the URL has to be something different like: http://myamazingapp-us.cloudapp.net/

Because we have two different URL's this leads us to a problem because if the Europe data centre goes down, which in the above case is our active configuration, the users will not be able to use the application which affects availability unless the active configuration becomes the DR environment which is the USA data centre.

This means the Europe data centre is currently serving up the users requests all the time and the USA data centre is in passive/sleep state - in other words not being used unless of a failure in the Europe data centre. When/if this failure occurs, we need to switch from Europe to the USA data centre. This is not easy with the current configuration because the users/actors will have to switch URLs from Europe to the USA data centre - this is far from ideal as often the user/actor probably wouldn't know when to try the other URL, it really needs to be seamless.

So we really want to use a single URL that has the ability to reference both data centres when we need to without the users actually knowing.

A simple way to implement DR in Windows Azure
This is where DNS (Domain Name Service) play a very important role in hardware infrastructure and helps us solve this problem relatively easilly.

Now consider an amendment to the above diagram (figure 1) to now abstract the user from the *.cloudapp.net domain name using a internet DNS registrar and a CNAME record that resolves to the Azure data centre required. Remember, each cloudapp sub domain represents a single data centre region. When you design for a drastic recovery solution, you wouldn't normally use the same data centre as it kind of defeats the purpose of having a DR strategy.

Figure 2: Basic drastic recovery fail over configuration with DNS
With the amendment above, we can give url: http://myamazingapp.com to end users/actors. They are now completely unaware of where their application is being served up - which is how it should be.

Of course they could run a trace (TRACERT) on http://myamazingapp.com and see where it resolves to. In fact, I have made the above configuration on a application I have deployed in Azure right now. If I run TRACERT on my sub domain: http://remotemedia.simonrhart.com I get the following:

Figure 3: Running TRACERT on my sample app hosted in Azure
You can see from the above trace, my subdomain resolves to Microsoft's data centre DNS http://remotemedia.cloudapp.net IP address: 94.245.89.251.

We know that IP address is a real Azure data centre as it is registered to Microsoft. Here is the result from running a whois on the resolved IP address:
WHOIS information for 94.245.89.251:

  
[Querying whois.arin.net]
[Redirected to whois.ripe.net:43]
[Querying whois.ripe.net]
[whois.ripe.net]
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
%       To receive output for a database update, use the "-B" flag.
% Information related to '94.245.64.0 - 94.245.127.255'
inetnum:         94.245.64.0 - 94.245.127.255
descr:           Microsoft Limited
org:             ORG-MA42-RIPE
netname:         UK-MICROSOFT-20081107
country:         GB
admin-c:         AS9763-RIPE
tech-c:          EN603-RIPE
tech-c:          BR329-ARIN
status:          ALLOCATED PA
mnt-by:          RIPE-NCC-HM-MNT
mnt-lower:       MICROSOFT-MAINT
mnt-domains:     MICROSOFT-MAINT
mnt-routes:      MICROSOFT-MAINT
source:          RIPE # Filtered
organisation:   ORG-MA42-RIPE
org-name:       Microsoft Limited
org-type:       LIR
address:        Microsoft
                Darren Norman
                One Microsoft Way
                WA 98052 Redmond
                UNITED STATES
phone:          +1 (425) 703 6647
fax-no:         +1 425 936 7329
e-mail:         danorm@microsoft.com
admin-c:        NORM1-RIPE
admin-c:        NORM1-RIPE
admin-c:        NORM1-RIPE
mnt-ref:        MICROSOFT-MAINT
mnt-ref:        RIPE-NCC-HM-MNT
mnt-by:         RIPE-NCC-HM-MNT
source:         RIPE # Filtered
person:         Allie Settlemyre
address:        Microsoft Limited
address:        One Microsoft Way,
address:        Redmond, WA 98052
address:        USA
phone:          +1 (425) 705 0516
phone:          +1 (425) 936 7329
e-mail:         iprrms@microsoft.com
nic-hdl:        AS9763-RIPE
source:         RIPE # Filtered
person:         Bharat Ranjan
address:        Microsoft Corporation
address:        Redmond, WA, 98102
address:        One Microsoft Way
address:        USA
phone:          +1 (425) 706 3230
fax-no:         +1 (425) 936 7329
nic-hdl:        BR329-ARIN
source:         RIPE # Filtered
e-mail:         bharatr@microsoft.com
person:         Edet Nkposong
address:        Microsoft, One Microsoft Way,Redmond, WA 98052
address:        USA
e-mail:         edetn@microsoft.com
phone:          +14257071045
nic-hdl:        EN603-RIPE
mnt-by:         MICROSOFT-MAINT
source:         RIPE # Filtered

So that is wonderful isn't it? DR and failover problem sorted. Well kindof. It's not perfect as it's very manual. If the European data centre where my application is deployed goes down, I need to know about it so I can tell my DNS registrar to change the CNAME record to point to the application that is deployed in the DR data centre - North Central US.

This means I will have to log into my DNS registrar and change the CNAME when a failure occurs like so:
Figure 4: Setting up a CNAME record
I don't really want my IT admins having to deal with this as it's expensive and adds complexity. I could automate it but then I'd have to put a load of process in place and write some custom code not to mention I'll need some infrastructure running on-premise (most probably).

Surely there is a better way?

Windows Azure Traffic Manager
Although what I have talked about above will work, it's fairly simple and I have done this for some time. But thankfully there is a better way. Microsoft has made available in Community Technical Preview (CTP) a feature called Windows Azure Traffic Manager.

Unlike the way the beta programmes work in Azure, you can start using the Traffic Manager right away. There is no request to make in order to start using it - as per the beta programme

Windows Azure Traffic Manager can solve you're failover DR strategy without having to touch any DNS server/registrar once it's setup and more. It supports the following:
  1. Performance – traffic is forwarded to the closest hosted service in terms of network latency
  2. Round Robin – traffic is distributed equally across all hosted services
  3. Failover – traffic is sent to a primary service and, if this service goes offline, to the next available service in a list
As we are talking about failover, the feature we need from Traffic Manager is number 3: Failover.
So Traffic Manager will solve our problem of having to manually update the DNS registrar with the new Azure data centre DNS cloudapp domain name. Great, how do I do it?

Enabling Traffic Manager
To start using Traffic Manager you need to use the Windows Azure Management Portal to create a policy.

To do this navigate to the Windows Azure Management Portal and sign-in: http://windows.azure.com. Then click Virtual Network > Get Started With Traffic Manager.


See figure 5 below:

Figure 5: Getting started with Windows Azure Traffic Manager
Notice how this is different from using the beta programmes in Windows Azure. With Traffic Manager you can start using it straight away and right now there is no cost to using it.

Once you click the Get Started with Traffic Manager button, you'll see a dialog box similar to the following popup:

Figure 6: Creating a Traffic Manager Policy

Notice, there is a lab that you can do that covers all this setup of Traffic Manager here: http://msdn.microsoft.com/en-us/gg197529 but I have included here for the bigger picture of what specifically Traffic Manager is designed to solve and how you would solve these problems without it.

I have filled in the policy above as per the original high-level architecture diagram in figure 1 above. Note: DNS names are different from my diagram but the concept and design is the same.

In the above, as mentioned we select Failover as a load-balancing method. We specify Europe (remotemedia) as our primary active configuration and the North Central US (remotemedia-dr) namespace as the failover data centre. This one is our passive configuration, the application is there, deployed and waiting to be used should a failure occur.

Some data here is important, one piece is the DNS time to live (TTL). This is the maximum time users will have to wait until the DNS server gets updated with the new URL should a failure occur. The default is 5 minutes (300 seconds). The other important peice of information is the Traffic Manager DNS Prefix field.

Well, the Traffic Manager DNS Prefix field can be anything we want (so long as it hasn't been used already) as the users will never see it. Later we will reconfigure our DNS registrar to point to this DNS address.

Once I click OK, the policy is then created and it is active in Traffic Manager:

Figure 7: Our policy in traffic manager
Figure 7 above shows how these policies look in Traffic Manager. There is 1 thing left to do though, and that is to configure our DNS registrar to point our custom DNS to our specified traffic manager policy URL we chose.

Figure 8: That's it, our DNS configured and never needs to change again!
Figure 8 above shows our final DNS configuration. So what happened here?

We are simply handing the problem of failover over to Windows Azure. So in the above case, Azure will handle changing the DNS CNAME configuration should a failure occur.

Making Sure Traffic Manager is Working
What we now need to do is test that the Traffic Manager failover feature is working correctly.

If we now run a trace route on our new traffic manager URL it should resolve to the Europe data centre (in my case http://remotemedia.cloudapp.net) - remember I have two data centres 1 in Europe (active) and 1 in North Central US (passive):

Figure 9: Tracing traffic manager configuration
So I'm happy with that, Traffic Manager's DNS configuration looks correct to me.

Now I want to force a failure so I can test the failover. This is easy, all I need to do is shutdown the Europe data centre services like so:

Figure 10: Shutting down active node in Windows Azure
Now that my Europe data centre services are not running as per figure 10 above, I'll need to wait the 5 minutes (which is what I configured) before I test the failover.

Once 5 minutes has elapsed, I'll run the same trace route command via a command-prompt like so:

Figure 11: Tracing now that Europe services are down
I think this is a success, notice the trace now resolves to our North Central US data centre (my URL: http://remotemedia-dr.cloudapp.net)

Also, if I run the trace one layer out from my custom domain: http://remotemedia.simonrhart.com, I get the expected failover data centre as above [remotemedia-dr.cloudapp.net]:

Figure 12: Running a trace route from my custom domain
So now you can see how the actual Traffic Manager DNS that you pick can be anything you want, it doesn't really matter what it is.

How does all this look, consider the new amended high-level architecture diagram in figure 13 below:

Figure 13: Complete high-level architecture diagram using Traffic Manager for DR

Conclusion
So I think the Windows Azure Traffic Manager is a good solution at solving your Windows Azure failover needs. Checkout the Traffic Manager training lab for a hands-on exercise on how to use it in more detail.

In this article, I have also used a public DNS registrar, but if your users are within a corporate LAN but you want to make use of a public cloud platform like Windows Azure, the same concepts apply to an internal DNS server farm.

In this blog post, I wanted to show how DR can be done in a PaaS model like Windows Azure - hopefully you can see how easy it is with Windows Azure Traffic Manager.

Thursday, March 29, 2012

Buxton Sketch font for use with the patterns & practices style Visio stencil

I wrote a blog post recently that included a link where you can download a Microsoft Visio 2010 stencil that resembles the stencils the Microsoft patterns & practices team use here: http://www.simonrhart.com/2012/03/how-to-create-architecture-diagrams.html

You can download this stencil here: https://bitbucket.org/azurebook/windows-media-remote-control/src/2ec03aa26249/Artefacts/Diagramming/Templates/AzureBook.vss

I created it on a machine that runs the Windows 8 Consumer Preview build and used a font called Buxton Sketch as it looks like a handwritten font and looks quite good for a diagramming white board effect. It seems Windows 8 CP already has the needed Buxton Sketch font installed as part of the standard OS install. So if you haven't got that font installed on your machine when you fire up the stencil (and Windows 7 doesn't), Visio will just default to its default font which doesn't look very good.

So you need to download the Buxton Sketch font and install it from here: http://fontsforweb.com/font/generatezip/?id=1049 I will upload this to bitbucket in due course.

Saturday, March 24, 2012

Git and remote branches

If you use Git as a source control system, and if you're anything like me, you might forget the commands to push a local branch to create a new remote branch on origin or to just create a remote branch from master or to delete remote branches etc..

There are a couple posts that I read periodically whenever I need to do those things as I simply don't use them enough in order to remember them unless I write scripts to do so (which I try to avoid as this obfuscates Git for other Git users).

The first one is here:
http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html

and this one is very good:
http://www.zorched.net/2008/04/14/start-a-new-branch-on-your-remote-git-repository/

Friday, March 23, 2012

Today is my last day at Smart421


Today is my last day at Smart421. It's been fairly short (1.5 yrs) but it's been a very memorable varied experience!

I blogged about joining Smart in November 2010 here: http://www.simonrhart.com/2010/11/smart421.html

As mentioned in that blog post I had hoped to become a TOGAF practitioner, I am not TOGAF certified (not taken the course or exams) but I have gained a much broader level of architecture experience and not just application architecture.

Being a Smartie (permie at Smart421) has been very different from most companies I have worked at. They have a very flat hierarchy and a very family feel to the place. For instance, the Managing Director - Neil Miles periodically buys everyone fish and chips from a fish and chip van that parks up outside the office on a Friday! how cool is that :) The CTO Robin Meehan often attends techie developer user group sessions in London in response to someone sending a message to one of the practises distribution lists! I can have a beer with the management team as if they were on my team on a project.

When you're out on a customers site and having to stay in a hotel, every few months, most of the management team will come down and take the whole team out for supper and drinks which last well into the night.

So why I am leaving? well I was contacted by Microsoft head hunter - Alina Burnus back in November regarding a World Wide Windows Azure CoE (Centre of Excellence) Solution Architect role (wow, what a mouthful). After reading the job specification for this role I jumped at the opportunity. Windows Azure, Solution Architecture and helping customers and the community to deliver business benefits using technology are what I want to do every day. I love writing code, but there is a time when you no longer code in your day job. I also love Technical Architecture and no doubt there will be an element of this in my new role. I will still stay current with language features, trends and patterns, I just won't be knee deep in code every day.

3 months, 9 interviews and n hours later, I was offered a job on this great team headed up by Steve Fox.

Having been a Microsoft Device Application Development MVP in the past, I have a fairly good idea what it is like at Microsoft. It's also not that my interests have changed in that I don't focus purely on mobility anymore, my job has lead me to be much broader in terms of Solution Architecture and less focused on the detail. I will always have a passion for mobile as I think it's one the most challenging and rewarding forms of software development today.

The team will be doing a full day pre-conference bootcamp at both TechEd EMEA and TechEd North America this year: TechEd EMEA: http://europe.msteched.com/PreCons TechEd USA: http://northamerica.msteched.com/preconferenceseminars#fbid=s9KpbHxjNTg

I start at Microsoft on the 10 April and no doubt you will hear about many cool and exciting things coming out of the cloud space in the form of Azure...stay tuned...

Wednesday, March 21, 2012

Windows 8 - not able to install Windows Identity Foundation

If you try to install Windows Identity Foundation (WIF) runtime system (pre-req for the WIF SDK) on Windows 8 Consumer Preview, you will get the error "The update is not applicable to your computer" in figure 1:

Figure 1: Error when trying to install WIF on Windows 8
To fix this, the WIF runtime system is now part of Windows 8 and can be installed as a Windows feature like IIS, so the WIF runtime system doesn't need to be downloaded. To do this run Control Panel > Programs and Features > Turn Windows Features on or off. 

Then check the Windows Identity Foundation 3.5 check box in the Windows Features dialogue box and click OK:

Figure 2: Installing WIF on Windows 8

Once you have done that then you'll be able to install the WIF SDK.

Figure 3: Now able to install WIF SDK on Windows 8

Once the WIF SDK installer is complete, you'll be able to reference the WIF API's from Visual Studio and use WIF on Windows 8 for your federated identity needs.

Monday, March 19, 2012

How to create architecture diagrams like the Microsoft p&p team using Visio 2010

Have you ever wanted to create the same type of diagrams the patterns & practices team do at Microsoft in terms of the shapes and themes they use?

Well, as I am co-authoring a Windows Azure book, it is important we all use the same stencil for our architecture diagrams. So I decided to create a Microsoft Visio 2010 stencil that looks much like the one the p&p team uses.

Here is an example of a simple diagram from the chapter I am writing on Service Bus. This is the very first diagram in the book to explain the Windows Azure Service Bus Relay feature:


Figure 1: Example p&p like diagram in Visio 2010

It would be great to hear some feedback on this stencil.

You can get this stencil here: https://bitbucket.org/azurebook/windows-media-remote-control/src/2ec03aa26249/Artefacts/Diagramming/Templates/AzureBook.vss

Tuesday, March 13, 2012

Apache Hadoop on Windows Azure - Now in CTP

This is a huge subject - Big Data so I'm not going to attempt to explain what it is here. But what I will say is the Apache Hadoop project is now available in Azure as a CTP offering (which is one way to implement Big Data). You also have the opportunity to get on the Technical Adoption Programme (TAP) and work directly with the Microsoft Azure product group.

Being on the TAP enables you to give feedback on what you think of early drops of Microsoft software which in turn allows you to help shape Microsoft products.

Here is a snip from the Apache Hadoop project website on what it is:

The Apache™ Hadoop™ project develops open-source software for reliable, scalable, distributed computing. 
The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using a simple programming model. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-avaiability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-availabile service on top of a cluster of computers, each of which may be prone to failures.

To learn more about the Apache Hadoop project, see here: http://hadoop.apache.org/

For more information on Hadoop for Windows Azure, see here: https://www.hadooponazure.com/ and to register to be considered for this CTP, please see here: https://connect.microsoft.com/SQLServer/Survey/Survey.aspx?SurveyID=13697

Friday, March 09, 2012

Smart421 - UK Azure User Group Reference Architecture using Service Bus for pub/sub

UPDATE 12/03/12: Source code for my presentation is now available here: https://bitbucket.org/azurebook/windows-media-remote-control/overview You will need to edit various config files to include your X.509 certs, Service Bus and ACS namespaces and ACS Simple Web Token (SWT) symmetric keys. I will write a blog post on how to do all these things and get it running in due course.

I presented at the recent UK Windows Azure User Group on Tuesday 6th March. You can view my Prezi presentation here: http://t.co/FH4S03gL

My colleague  Mark Want has written a post regarding this event on the Smart421 blog here: http://smart421.wordpress.com/2012/03/09/uk-windows-axure-user-group/

I'm really starting to like this group and getting to know the folks from this group is great fun. They are now starting to run events in Manchester as well as London.

I talked about a reference architecture that I have been working on in my spare time over the last few weeks. The code will be available soon and I will blog and tweet when made available.

The solution uses quite a few features of Azure such as: MVC 4 Web Role, ACS, SAML 2.0 and SWT tokens, Google as an identity provider, Service Bus Relay services, Topics and subscriptions, Castle Windsor with the Service Bus and Topics/Subscriptions for pub/sub, a DR strategy and global DNS to enable DR and hide the cloudapp.net domain.

Next I want to show ADFS as an STS over ACS, Idempotent messaging when using WCF with the Service Bus and load testing using VM Roles.


Thursday, March 01, 2012

Getting the RSS feed from an iTunes podcast

Have you ever wanted to get the RSS feed URI from a iTunes podcast page because you don't want iTunes installed on your machine?

I found this website (http://itunes.so-nik.com/) that gives you the RSS XML URI from the passed iTunes URL:

Figure 1: Enter iTunes URL into the text box and hit submit
Simply enter the iTunes podcast URL into the text box in the page and hit Submit. In my example I wanted the RSS feed to this podcast: http://itunes.apple.com/podcast/judge-jules-presents-judgement/id302973072

Figure 2: Result of the tool that greps the RSS URI
The tool (as if by magic) figures out what the RSS feed is so you can use it in other non-proprietary tools. I wanted the above for my Zune HD. Nice eh!?

Tuesday, February 28, 2012

Where is the "New Virtual Machine Role" menu option in Visual Studio 2010?

A while back I wrote about the new-ish VM Role feature in Windows Azure (still in beta right now). You can read that post here.

If you're not sure what the VM Role is, then this MSDN post should clear that up for you.

Once you have joined the VM Role beta programme, the status should have changed in the Azure Portal to Active, and you should have received an email with links to .reg files which alter relevant Azure Visual Studio registry keys which in turn enables this menu option in Visual Studio.

Figure 1: Active VM Role feature
Unfortunately for me, I received no such email. So I searched the Internet for them and found the location where they can be downloaded.

For 64-bit operating systems see here: http://go.microsoft.com/fwlink/?LinkID=206860
For 32-bit operating systems see here: http://go.microsoft.com/fwlink/?LinkID=205313

Alternatively, you can simply use this key for 64-bit:

[HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Windows Azure Tools for Microsoft Visual Studio 2010\1.0]
"VirtualMachineRoleEnabled"=dword:00000001


For 32-bit:

[HKEY_CURRENT_USER\Software\Microsoft\Windows Azure Tools for Microsoft Visual Studio 2010\1.0]
"VirtualMachineRoleEnabled"=dword:00000001

Once you have run either of those commands, or edited your registry manually, restart Visual Studio and you should now see the new menu option that will enable you to create a VM role to deploy to Windows Azure:

Figure 2: The new "New Virtual Machine Role" menu option

Enjoy!

Thursday, February 16, 2012

Testing a Custom Filter Provider in ASP.NET MVC 3

There are many good articles published on how to write a custom Filter Provider in MVC 3 in order to make dependency injection possible on the web. So I'm not going to talk about that, but there doesn't seem to be many articles on how to test those custom filter providers.

The role of the filter provider is to simply return filters for a given controller, but this post assumes you know what a filter provider does so I'm going to skip the explaination. I've provided an MSDN link to the FilterProvider technical page for more information.

The FilterAttributeFilterProvider as provided by the ASP.NET MVC framework looks like the following: (I have the ASP.NET MVC source code on my machine, will show how to install and access this code in another post...)

    public class FilterAttributeFilterProvider : IFilterProvider 
    { 
        private readonly bool _cacheAttributeInstances; 

        public FilterAttributeFilterProvider() 
            : this(true) {
        }

        public FilterAttributeFilterProvider(bool cacheAttributeInstances) { 
            _cacheAttributeInstances = cacheAttributeInstances;
        } 
 
        protected virtual IEnumerable<filterattribute> GetActionAttributes(ControllerContext
                      controllerContext, ActionDescriptor actionDescriptor) {
            return actionDescriptor.GetFilterAttributes(_cacheAttributeInstances); 
        }

        protected virtual IEnumerable<filterattribute> GetControllerAttributes(ControllerContext
                     controllerContext, ActionDescriptor actionDescriptor) {
            return actionDescriptor.ControllerDescriptor.GetFilterAttributes(_cacheAttributeInstances); 
        }
 
        public virtual IEnumerable<filter> GetFilters(ControllerContext controllerContext,
                     ActionDescriptor actionDescriptor) { 
            ControllerBase controller = controllerContext.Controller;
            if (controller == null) { 
                return Enumerable.Empty<filter>();
            }

            var typeFilters = GetControllerAttributes(controllerContext, actionDescriptor) 
                             .Select(attr => new Filter(attr, FilterScope.Controller, null));
            var methodFilters = GetActionAttributes(controllerContext, actionDescriptor) 
                               .Select(attr => new Filter(attr, FilterScope.Action, null)); 

            return typeFilters.Concat(methodFilters).ToList(); 
        }
    }
It is the GetFilters method we are interested in as this is the method we override in our custom filter provider to provide things like dependency injection support.

So your custom filter provider might look something like the following (IoC container StructureMap specific):
   
    public class StructureMapFilterProvider : FilterAttributeFilterProvider
    {
        private readonly IContainer container;

        public StructureMapFilterProvider(IContainer container)
        {
            container = container;
        }

        public override IEnumerable<Filter> GetFilters(ControllerContext controllerContext,
                  ActionDescriptor actionDescriptor)
        {
            var filters = base.GetFilters(controllerContext, actionDescriptor);

            if (filters != null)
            {
                foreach (var filter in filters)
                {
                    container.BuildUp(filter.Instance);
                }

                return filters;
            }

            return default(IEnumerable<Filter>);
        }
    }

In the above filter provider, we are getting a list of filters for the passed controller context, and then calling BuildUp on those instances using StructureMap IoC container. This is a neat feature of StructureMap that allows you to support property injection without having to use decorators in the filter classes. If you'd like to learn more about StructureMaps BuildUp feature, please see this link: http://codebetter.com/jeremymiller/2009/01/16/quot-buildup-quot-existing-objects-with-structuremap/

You probably know already that ideally you'd want to call the base.GetFilters(ControllerContext, ActionDescriptor) to be on an interface so it can be easilly stubbed out in out unit tests, but it's not, its part of the superclass that we are deriving from.

So we are going to have to construct a ControllerContext and ActionDescriptor in order to pass into our filter provider during testing. All we are really aiming to test here is that the container BuildUp method is called against the filter instance. Your requirement might be slightly different depending on what you are trying to achieve and perhaps the IoC container you might or might not be using. But the principles should be the same.

Before I show how to test the above we need some supporting code. The first being a mocked controller that is decorated with a filter:

public class FilterProviderControllerMock : Controller
{
    [CustomErrorHandler]
    public void MockAction()
    {
    }
}

So here we simply have a controller with an action named MockAction that includes a custom action and does nothing. Notice how the action is decorated with a CustomErorHandler attribute - which is a custom filter. It's this attribute that we want to inject our dependencies into. I've not shown the code for this as it's not important, what is important is to realise that this filter has dependencies that cannot be injected via the constructor due to limitations in .NET (i.e. it being an attribute).

First consider the actual test code (note: I'm using Moq as my mocking tool of choice - just because it's a change to Rhino):

[TestFixture]
public class StructureMapFilterProviderTests
{
     private Mock<IContainer> containerMock;
     private StructureMapFilterProvider filterProvider;
     private Filter customFilter;
     private List<Filter> customFilterCollection;
     private CustomErrorHandlerAttribute customActionFilter;
     private Mock<HttpContextBase> httpContextMock;

     [TestFixtureSetUp]
     public void Setup()
     {
         customActionFilter = new CustomErrorHandlerAttribute();
         customFilter = new Filter(customActionFilter, FilterScope.Action, 1);
         customFilterCollection = new List<filter>();
         customFilterCollection.Add(customFilter);
         containerMock = new Mock();
         filterProvider = new StructureMapFilterProvider(this.containerMock.Object);
         httpContextMock = new Mock<HttpContextBase>();
     }

     [Test]
     public void CanInterceptCreationOfFilters()
     {
         // Arrange
         containerMock.Setup(x => x.BuildUp(customActionFilter));
          
         var controllerMock = new FilterProviderControllerMock();
         var routeData = new RouteData();

         var controllerContext = new ControllerContext(this.httpContextMock.Object, routeData, controllerMock);

         ControllerDescriptor controllerDescriptor = new 
                     ReflectedControllerDescriptor(typeof(FilterProviderControllerMock));

         var mockActionMethodInfo = controllerMock.GetType()
             .GetMethods(BindingFlags.Public | BindingFlags.Instance)
             .Where(x => x.Name.Equals("MockAction")).FirstOrDefault();
         ActionDescriptor actionDescriptor = new 
                 ReflectedActionDescriptor(mockActionMethodInfo, "MockAction", controllerDescriptor);
       
         // Act
         var filters = filterProvider.GetFilters(controllerContext, actionDescriptor);

         // Assert
         containerMock.Verify(x => x.BuildUp(this.customActionFilter), Times.Once());
    }
}
So what's going on here, there seems to be a lot of code. There is because the superclass filter provider is hard to test due to how it was designed (using inheritance). So the test above is simply creating a ControllerContext and an ActionDescriptor which is required in order to call the filter provider. Doing these things requires a bit of .NET reflection that would normally be done by the MVC framework at runtime. Once reflection has been used and the correct action method has been identified, the provider can easily select the correct filter then our custom filter can build it up (inject all required dependencies into the filter). We then finally assert that the build up happens on our custom filter at least once otherwise the test will fail.

I'm sure in later releases of ASP.NET MVC this will improve, but for now this is a work around to test your custom filter providers.

This sample code is up on BitBucket here if you want it: http://code.simonrhart.com/mvc-3-examples/src/5b122b445c86/Testing%20StructureMap%20Filter%20Provider

Enjoy!