One of the questions that is still being asked by people both within the tech industry and outside is “What is Windows Azure?” to answer this question Steve Marx a Microsoftie who works on Windows Azure has put together this great hand drawn video.
Video: What is Windows Azure?
This is a great video giving a high (ish) level overview of Azure, and goes to prove that devs can draw pretty pictures as well. All we need now is a designer to colour everything in. :p
One of the best practices when creating an application on top of the Azure Service Platform is to constantly log your applications activity. This is so that when a worker role inevitably goes down (and it will) you will be view output in your log files to view if there was an error with the code in your application (surely not :p ) or if it was a problem that occurred with the fabric itself.
To write out to the Azure logs you need to use the RoleManager and write to the log as the below code shows:
RoleManager.WriteToLog("Information", "Logging the activity of my web / worker role");
Now, not only can this start to make your code extremely ugly (yes, we all love pretty code) by you take more time deciding what to log, how much information to provide, and creating a string to pass to the WriteToLog method.
There are a number of areas where I can think that logging would be needed these are:
- Tracing In / Out of a method, making us aware of where the error occurred along with some simple performance monitors from your logs timestamps).
- Exceptions, this is vital, every time an error occurs we want to log as much information as possible.
- General Messages, you may just want to log that your application has reached a certain point in its process or the outcome of a given task.
- Variable values, if you change on of your variables throughout a process you may want to keep a log of what its value has been throughout the whole process. This would make it a lot easier to pin point where anything has gone wrong in a process.
With these four key tracing areas in mine, I sat down with a nice cup of tea and pack of digestive biscuits and set to creating my own AzureTrace library that would allow you to handle the above situations with ease. Allowing you to concentrate on getting your app up and running than the finer points of logging.
The library that I have created has the following methods:
TraceIn / TraceOut
Accepts a number of parameters of type object that will be written out to the log.
Will also identify what is the calling method so that you can see the method we are in when the tracing occurs.
TraceException
Given an exception object, the method will write out information to the log identifying the exception, the exception message and the method the exception occurred in.
TreacMessage
This is much like a standard tracing method that allows you to pass in a TraceType argument that gives the an enum of the standard Azure log types (Information, Critical, Error, Warning …) along with a format and a number of string parameters and will be written to the log as is.
Trace (Extension Method)
With the ‘Trace’ extension method you can trace any variable out to the logs. Allowing, you to record the state of a given object as it passes through the system.
All of the above methods have the option of supplying a GUID to identify the process, this makes following the process flow of a given operation over multiple roles and servers much easier. If you generate a new GUID each time a user requests an action you can have a paper trail that you can follow from start to finish. An example of this would be if a user clicks a button on the web role (generate GUID), the web role does some processing (using AzureTrace with the given GUID), passes a message to a worker role via queues (adding the GUID as a property of the message) and then continue to log with the same GUID on the worker role.
HiddenInformation Attribute
When creating these methods I realised that when logging out to these methods may end up supplying the reader of the logs with private information such as a persons national insurance number or other personal identifiable data that you don’t want just anyone looking at, so with this in mind (and another cup of tea) I created an attribute that would allow you to hide properties within an abject and therefore this data would not get written out to the log.
AzureTrace In Action
I have created a quick sample application that uses all of the methods within the library along with the Hidden Information attribute on a property.
1: namespace Azure_WebRole
2: { 3: using System;
4: using AzureTrace;
5:
6: public class TestClass
7: { 8: [HiddenInformation]
9: public string Hidden
10: { 11: get;
12: set;
13: }
14:
15: public string NotHidden
16: { 17: get;
18: set;
19: }
20: }
21:
22: public partial class _Default : System.Web.UI.Page
23: { 24: /// <summary>
25: /// Handles the Load event of the Page control.
26: /// </summary>
27: /// <param name="sender">The source of the event.</param>
28: /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
29: protected void Page_Load(object sender, EventArgs e)
30: { 31: TestClass testClass = new TestClass()
32: { 33: Hidden = "Do Not Show Me!",
34: NotHidden = "Show Me!"
35: };
36:
37: this.TraceTestMethod(testClass);
38: }
39:
40: /// <summary>
41: /// Traces the test method.
42: /// </summary>
43: /// <param name="input">The input.</param>
44: protected void TraceTestMethod(TestClass input)
45: { 46: AzureTraceManager.TraceIn(input);
47:
48: AzureTraceManager.TraceMessage(TraceType.Information, "Formatted text - args(0) {0} args(1) {1}", "first", "second"); 49:
50: input.Trace();
51:
52: try
53: { 54: throw new Exception("Something went wrong. :s"); 55: }
56: catch (Exception ex)
57: { 58: AzureTraceManager.TraceException(ex);
59: }
60:
61: AzureTraceManager.TraceOut(input);
62:
63: }
64:
65: }
66: }
From the above code sample we get the following output displayed in the logs on the dev fabric running on our local machine.
Notice that the only property that is written out to the log for the TestClass is that of the NotHidden property, with the Hidden property being safely hidden with the HiddenInformation attribute.
IsTracingEnabled?
When each of the methods are called I first check to see if the user is wanting to trace all this information out to the logs, this is done by looking at the cloud configuration files. The library looks into the config for a setting called “IsTracingEnabled” and if set to true will start logging. However, by default if tracing is set to false.
The below config shows a web role that has tracing enabled and worker which by default has not enabled tracing.
1: <?xml version="1.0"?>
2: <ServiceConfiguration serviceName="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
3: <Role name="WebRole">
4: <Instances count="1"/>
5: <ConfigurationSettings>
6: <Setting name="AccountName" value="devstoreaccount1"/>
7: <Setting name="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>
8: <Setting name="BlobStorageEndpoint" value="http://127.0.0.1:10000"/>
9: <Setting name="QueueStorageEndpoint" value="http://127.0.0.1:10001"/>
10: <Setting name="TableStorageEndpoint" value="http://127.0.0.1:10002/" />
11: <Setting name="IsTracingEnabled" value="true"/>
12: </ConfigurationSettings>
13: </Role>
14: <Role name="WorkerRole">
15: <Instances count="1"/>
16: <ConfigurationSettings>
17: <Setting name="AccountName" value="devstoreaccount1"/>
18: <Setting name="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>
19: <Setting name="BlobStorageEndpoint" value="http://127.0.0.1:10000"/>
20: <Setting name="QueueStorageEndpoint" value="http://127.0.0.1:10001"/>
21: <Setting name="TableStorageEndpoint" value="http://127.0.0.1:10002/" />
22: </ConfigurationSettings>
23: </Role>
24: </ServiceConfiguration>
I have uploaded the AzureTrace Library to my Sky Drive in case you want to give it a quick whirl / suggest any improvements that could be made.
Going shopping has just been make a lot easier by the Tesco's IE8 Accelerator, so to explain how easy this made shopping @markjo, @marcholmes and @will_coleman headed off to document the experience :p
Hopefully, more videos will be whizzing their way out of the UK DPE offices soon.
(p.s. check out @markjo ‘s cameo appearance)
On a normal Saturday I would normally end up recovering from a hangover walking around the local shops in Reading, looking at all the cool gadgets that I could buy, cameras, TVs, laptops all the standard geek gear.
However, when ever I get to the computer section a long discussion normally ensues around which netbook I would buy (if I could afford them) and my argument for not buying one has always been that I want to get a tablet pc that is a small as a netbook. Just imagine a small sleek, stylish netbook that you could write on like a pad of paper.
Now, my prayers have been answered with the Acus T91 a tablet netbook, that is also rumoured to be multi-touch. This will no doubt start a whole new wave of tablet netbooks from competitors such as Dell, HP, and Aser.
Take a look at this video I found on YouTube of the Acus T91:
More information on the T91 can be found here, here, and here.
Will have to get me one of these… add Windows 7 and we have a winner.
Over the past couple of weeks I’ve been wanting to get into playing with some
PowerShell for scripting and replacing the old trust cmd (the old DOS prompt is soo Win3.5 :p ).
It wasn't until I admitted this dirty little secret of mine to a friend and colleague
Ben Nunney, that I really started to find out the real power of PowerShell (get it power). Ben took some time out to run through some of the cool features of PowerShell and how it can be used to contact remote machines and servers, both on premise and in the cloud.
However, one of the first things that I really wanted to do as a dev, was to use PowerShell to do everything that I would normally have to load up Visual Studio Command Prompt to do, after all who wants to be switching between prompts all the time.
With a
lot little help from these blogs (
link &
link) I was able to create a method (VsVars32) that when executed would run PowerShell as VSCmd and just because I’m lazy I have added this to my PowerShell profile with a call to the method so that when PS launches it automatically loads into VSCmd mode.
The other addition that I have made is a check to see whether I’m running my shiny VS enabled PowerShell in admin mode or not, due to my continued aggravation if I fail to start VSCmd in non-admin mode and a local build wont run correctly. This method (AmIAdmin) will simply check if I'm running in admin mode, and if not display “Non-Administrator” to the title bar and turn the background a light blue colour so I can instantly see that I don’t have admin rights.
Here is the code that has been added to my PS profile (view using “notepad $profile”):
1: #### Functions Used to Load VS Command Prompt #####
2:
3: function Get-Batchfile ($file) {
4: $cmd = "`"$file`" & set"
5: cmd /c $cmd | Foreach-Object {
6: $p, $v = $_.split('=')
7: Set-Item -path env:$p -value $v
8: }
9: }
10:
11: function VsVars32()
12: {
13: $version = "9.0"
14: $key = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version
15: $VsKey = Get-ItemProperty $key
16: $VsInstallPath = [System.IO.Path]::GetDirectoryName($VsKey.InstallDir)
17: $VsToolsDir = [System.IO.Path]::GetDirectoryName($VsInstallPath)
18: $VsToolsDir = [System.IO.Path]::Combine($VsToolsDir, "Tools")
19: $vs90comntools = (Get-ChildItem env:VS90COMNTOOLS).Value
20: $batchFile = [System.IO.Path]::Combine($vs90comntools, "vsvars32.bat")
21: Get-Batchfile $batchFile
22: [System.Console]::Title = "Visual Studio " + $version + " Windows Powershell"
23: }
24:
25: ###### Functions Used to Load VS Command Prompt #####
26:
27: ###### Function Used to Set Background to Light Blue If not Admin ######
28:
29: function AmIAdmin()
30: {
31: $wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
32: $prp=new-object System.Security.Principal.WindowsPrincipal($wid)
33: $adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
34: $IsAdmin=$prp.IsInRole($adm)
35: $title = [System.Console]::Title
36: if (!$IsAdmin)
37: {
38: $title = $title + " (Non-Administrator)"
39: (Get-Host).UI.RawUI.Backgroundcolor="Blue"
40: cls
41: }
42: else
43: {
44: $title = $title + " (Administrator)"
45: }
46: [System.Console]::Title = $title
47: }
48:
49:
50: ###### Run Functions on StartuP ######
51: VsVars32
52: AmIAdmin
UPDATE
As I have been doing work with Windows Azure recently I have also added a handy way to access all the features of the Azure SDK Command Line Tool to my PowerShell by adding the following line to my profile:
$env:Path = $env:Path + "; C:\Program Files\Windows Azure SDK\v1.0\bin\"
This will add the folder containing all the Azure utilities (cspack, csrun, etc.) to the PowerShell environment.
Great Channel 9 video featuring Amitabh Srivastava the VP for Windows Azure, talking about Azure, the cloud, cloud services, developing for the cloud and some insights into what's in store for the future.
My favourite quote from this hour long dive into Azure, is when Amitabh say’s that he sees Azure and the current state of the cloud only being only:
“5 minutes into the first quarter”
With such great advances being made from many of the big players in computing to push towards cloud technologies, it will really be an interesting area in the months and years to come.
Microsoft Academy for Collage Hires is Microsoft’s global graduate scheme designed to take the best University graduates from around the world and fast track them into the world of Microsoft’s sales, marketing and service organisations.
The EMEA graduates are a diverse group range from all over Europe from different universities, degrees and backgrounds, all with a common potential (how did I get in?) and passion for technology.

During the first week of March, the graduates from all over EMEA converged on the city of Istanbul, Turkey to take part in on of our first European training sessions, Winter School.
Winter School is a two week (only one if in Services as we get to go to Corp :) ) training program based around personal development and soft skills, not to mention the brilliant night life of drinking, belly dancers, drinking, boat trips, sightseeing and drinking (shhhh) along with the networking opportunities.
The first week provided a couple of days to first familiarise ourselves with Istanbul, getting to know everyone from around the continent and settled into a great (but expensive) hotel.
Winter School kicked off at the newly kitted out Microsoft Turkey office, with a number of presentations from some really great VP’s from around the business. Sharing their experience and stories of being at a company like Microsoft and what we can expect over the coming months and years as we develop our carer's from graduates to the VP of tomorrow. One thing that is surprising as a graduate is how really
approachable these guys are being able to just chat with someone helps seal multi million dollar deals and get insight into how they built their positions to what they are. Along with this the amount of time and respect that these important people give new graduates into the company is truly amazing.
After the kick off event, we spent a day going through personality types and finding what our “true colours” are, as it turns out I appear to be a red (Task oriented, driven, leader etc.). Along, with how we can get each of the different colours, red, orange, blue and green to work best together.
This then really came to light in some group work we carried out in the latter part of the week, where we separated into a number of groups and were challenged to complete the Silver Bullet Runway, a challenging exercise where we needed to maximise profit from a given set of materials by running as many ball bearings through a tube in 30 seconds.
A number of presentations were given by the guys from Duke Education, whereby we discussed how to give the perfect presentation, group skills and got the chance to present on our individual stories of how we got to be working for one of the best companies, Microsoft. The best of these presenters then went forward to present in front of a group of around 200 graduates and professional presenters.
The final day of the first week culminated with us utilizing all of the skill we had learned during the week, from presenting to group skills and selling techniques as we all split into groups and put on a trade show.
During this week, I managed to make many new friends, that I will be meeting up with in a couple of months when we all converge on the Tech Ready later in the year.
This was a truly great week, and just one of the reasons for graduates to apply for a career at Microsoft.
Over the past couple of weeks I’ve been doing some WCF development and have been using WCF KnownTypes and ServiceKnownTypes to support inheritance and the use of interfaces when creating web services.
Using the KnownType and ServiceKnownTypes attribute you can have a operation contract with a signature that either returns or accepts a base class such as the one below:
1: [ServiceContract]
2: public interface IService1
3: {
4: [OperationContract]
5: IPerson GetPerson();
6: }
This allows the web service to pass back any sub class that inherits from the IPerson interface, such as a person class or even an employee class that inherits from person.
This can be done using the KnownType attribute on the sub class associating the interface with the concrete implementation. The sub class adds the attribute [KnownType(typeof(baseclass)] passing in the generalised object or interface.
1: public interface IPerson
2: {
3: string FirstName { get; set; }
4:
5: string LastName { get; set; }
6: }
7:
8: [DataContract(Name = "Person")]
9: [KnownType(typeof(IPerson))]
10: public class Person : IPerson
11: {
12:
13: #region IPerson Members
14: [DataMember(Name = "FirstName")]
15: public string FirstName { get; set; }
16:
17: [DataMember(Name = "LastName")]
18: public string LastName { get; set; }
19: #endregion
20: }
This will now allow the web service to pass back the Person sub class where the interface IPerson is used in the operation contract. However, I prefer using the ServiceKnownType attribute on the method signature, rather than using the KnownType attribute on the whole class.
1: [OperationContract]
2: [ServiceKnownType(typeof(Person))]
3: IPerson GetPerson();
ServiceKnownTypes can also be used to a number of different classes inheriting from a single base class by adding multiple attributes to the method.
1: [OperationContract]
2: [ServiceKnownType(typeof(Person))]
3: [ServiceKnownType(typeof(Employee))]
4: IPerson GetPerson();
The web method can now pass back either the Person or Employee object from the service.
Enjoy… :)
Rob Bagby has started out a multipart series of Azure web casts on channel 9, which will hopefully give some real insight into the world of Windows Azure from setting up your machine right through to creating scalable applications using the Azure storage model.
In this first webcast Rob goes through what is needed for your local dev environment and how to set it up. Giving the low down on the SDK’s and tools needed for working with Azure within Visual Studio.
He then goes through the simple steps to create your first “Hello World” Azure application, which really is just as easy as making an ASP.net web page and then deploying it out to the cloud, using the Azure online portal (including how to set this up).
More detailed steps for this video can be found on via Rob’s blog, especially this post.
Can’t wait for the next instalment, hopefully this will become a regular slot on Channel 9.
Technorati Tags:
Azure,
Video
Just been announced that Windows Azure will be making a leap from using Pacific Standard Time and using Co-Ordinated Universal Time (UTC).
This change is being done so that it poses less problems for global dev’s and users, however the exact date of the change over has not yet been announced.
The change could affect a number of applications that are already out in the wild, for more information check out the official post here.
Above the Clouds: A Berkeley View of Cloud Computing is a whitepaper giving a deep insight into cloud computing.
A big thank to Steve Clayton and his post about about Above the Clouds, this paper looks like it will be a great read.
It sets out to look into a number of things such as “What is Cloud Computing”, what has lead to the rise of cloud computing now rather than 10 or so years ago. Utility computing and the surrounding economics which should be considered. As well as a number of obstacles and opportunities that we are currently faced with where cloud computing is involved.
It definitely looks as thought the academics are considering Cloud computing, SaaS and S+S as a real paradigm shift that we should all embrace.
A video overview with some of the authors of the whitepaper available here.
Download the white paper here.
This is a great link for anyone just getting started or new to developing on the Azure Services Platform. Giving a whole bunch of web casts and tutorial videos that will walk you through the basics of Windows Azure, Live Services and .NET Services as well as a section of PDC / more academic based videos from channel 9.
With these videos you will be a cloud guru in no time at all.
Check out all the content here:
http://msdn.microsoft.com/en-us/azure/dd439432.aspx
This cool video gives a nice simplified explanation of cloud computing in “plain English”. Covering the basics of scalability, XaaS, and Utility computing.
More videos on cloud computing can be found at:
http://videos.techielife.com/tag/cloud
http://channel9.msdn.com/tags/Azure/
Bill Lodin over at IT Mentors has put together a really nice tool that allows you to view your Windows Azure logs in a WPF log viewer
The application replicates the functionality of the development fabric’s UI that lets you monitor any messages that are written to the Azure logs from the Worker and Web Roles that are currently up and running. Messages can easily be written to this area using the RoleManager class and RoleManager.WriteToLog() method passing in the type of event you are logging (Critical, Error, Information, etc.) along with a message that you are wishing to write.
Logging errors in Azure is an important process just as it is in any application, however when our application runs into trouble after it has been deployed we will be able to use the log files to locate and fix any errors that have occurred.
Currently the live fabric in the cloud does not have convenient real time log viewer, that the dev fabric does. Instead the logs are recorded into the cloud and stored so that you can view them locally at a later date. All you would have to do is copy your logs to the storage system of Azure.
Now with Bill’s Log Viewer, after your logs have been copied to the blob storage you can just load up the app, enter your projects details and easily view any logs that have been registered by the application.
The looks a great tool that I will definitely be putting into practice with my Azure apps, for more information check out Bill’s blog post.
I’ve been wanting to create a WPF or Console application that could communicate with Azure by passing a Message to the Fabric. However, I did not want to have to pass WCF messages to a worker role as I had seen people doing in previous examples, instead I wanted to use the REST API to send messages straight from the application to the Azure Worker Role.
The easiest way of doing this, is by referencing the currently available StorageClient.dll library that is supplied with the Windows Azure SDK. Then add a App.config file to the WPF project that you want to communicate with the cloud.
Within the App.Config’s appSettings element include an add element for each of the pieces of data that would normally be supplied within the configuration file (cscfg) of the cloud application.
1: <?xml version="1.0" encoding="utf-8" ?>
2: <configuration>
3: <appSettings>
4: <add key="AccountName" value="devstoreaccount1" />
5: <add key="AccountSharedKey" value="..." />
6: <add key="BlobStorageEndpoint" value="http://127.0.0.1:10000" />
7: <add key="QueueStorageEndpoint" value="http://127.0.0.1:10001" />
8: <add key="TableStorageEndpoint" value="http://127.0.0.1:10002" />
9: <add key="ContainerName" value="domgreenmessage" />
10: </appSettings>
11: </configuration>
Now with these settings added we can use the StorageClient library just as we were doing from the web and worker roles within the online app’s.
1: namespace WpfAzureApp
2: {
3: using System.Windows;
4: using Microsoft.Samples.ServiceHosting.StorageClient;
5:
6: public partial class Window1 : Window
7: {
8: public Window1()
9: {
10: InitializeComponent();
11: }
12:
13: private void Button_Click(object sender, RoutedEventArgs e)
14: {
15: StorageAccountInfo account = StorageAccountInfo.GetDefaultQueueStorageAccountFromConfiguration();
16: QueueStorage queueService = QueueStorage.Create(account);
17:
18: MessageQueue q = queueService.GetQueue(StorageAccountInfo.GetConfigurationSetting("ContainerName", null, true));
19: if (!q.DoesQueueExist())
20: {
21: q.CreateQueue();
22: }
23:
24: q.PutMessage(new Message(this.txtInput.Text.ToString()));
25:
26: this.txtInput.Text = string.Empty;
27: }
28: }
29: }
(I know this may be fairly trivial for expert devs, but for the less experienced developer this could save a lot of time and trouble.)