“CommunicationObjectFaultedException was unhandled” Error when working on Windows Azure Project with Source Safe

If you encounter the following error message, you can guess that the most probably problem lies on WCF configuration since it mentions something about System.ServiceModel which is actually the class library for WCF. You can definitely troubleshoot the error from WCF point of view. But what if it doesn’t solve the problem no matter what you’ve tried. You are sure that your WCF configuration is exactly correct.


Then, I am telling you another possibility of this error message, which I see it as a bug in Visual Studio or more appropriately maybe VS Tools for Windows Azure. If you face the problem when developing your Windows Azure project with source control such as SourceSafe, Team Foundation Server, or Subversion SVN, you most probably encounter the issue that I am talking about.

Visual Studio Modify your web.config file when the project is running

If you notice carefully, each time you run your Windows Azure project, Visual Studio actually does something on your web.config file. This can be seen if your web.config file is opened, an dialog will prompt you that your web.config file is modified, do you want to reload it.


What’s does VS actually add?

<machineKey> element


What is that?

MachineKey element is actually used by ASP.NET website to configure algorithms and keys to use for encryption, decryption,and validation of forms-authentication data and view-state data,and for out-of-process session state identification.

What’s the reason of adding those?

Understanding Windows Azure Roles

As you know that any VM instances hosted on Windows Azure will be load-balanced automatically. Since they are load-balanced, nobody can guarantee the same instance will be responsible on particular request. While we need to ensure that any session / view-state data that are sent to browser could be encrypted / decrypted properly, we need to ensure that the machine key of each instance is consistent. That’s the reason why Visual Studio will modify / add your machine key.


The easy way to go is to check-out your web.config file. Thus, it will give your Visual Studio write access to the web.config, to add / modify the machine key element.

Huh… Would it a better solution? As far as I know, there’s no solution for that at this moment. However, Microsoft has captured this “bug” and I do hope it would be fixed for the upcoming released of Azure SDK.

Update 10 March 2011: To solve this problem, install Windows Azure SDK 1.4 Smile

Share This:

Combining Web and Worker Role by Utilizing Worker Role Concept

I am very much excited to write this post as I believe not many people realized about it and I can tell that it would be very helpful in many scenario. Steve actually mentioned this in MIX 2010 in the session entitled 10 Things You Didn’t Know You Could Do with Windows Azure.

Always Start with an Introduction

Let refresh our mind that, Windows Azure Service Roles (Web Role and Worker Role) are is actually a provisioned VM, runs on Windows Azure.

  • The web role provides out-of-the-box IIS 7 environment which allows us to host our application.
  • While worker role is an “almost” empty VM which enables us to do whatever we like to do, specifically in the while loop within Run method.
public override void Run()
    // This is a sample worker implementation. Replace with your logic.
    Trace.WriteLine("WorkerRole1 entry point called", "Information");

    while (true)
        //put our code and logic here...

        Trace.WriteLine("Working", "Information");

What We Can Do with Worker Role

Worker role is indeed very flexible as we can do many things. Some common pattern that we can utilize worker roles are:

  • Performing background or batch processing
  • Hosting non-http service hosting (example: WCF)
  • Running other web / application server (eg: Ruby, Java, Mongoose)

For those compute-intensive task, it’s definitely fine to use spend dedicated worker role to perform the task. However, in many scenario, we only need to perform simple and non-compute intensive task. These could be:

Cost effective

It would be somehow too wasteful to create 2 instance of worker role just to run those task. (Remember in compute SLA, you are required to have at least 2 instance to meet the 99.95% uptime).

Considering the cost for small size VM,it could simply cost you about:

$ 0.12 X 24 hours X 30.5 days / month X 2 instance = USD 175.68

So,how can we do to save those cost?

Combining Web and Worker Role

I refer to the introduction that we’ve discussed above to refresh your mind on Web and Worker Role. For both Web and Worker Role, we generally have either WebRole.cs and WorkerRole.cs file within the project. The class in these two files inherit from RoleEntryPoint, which we can override some methods.

public abstract class RoleEntryPoint
    protected RoleEntryPoint();

    public virtual bool OnStart();

    public virtual void OnStop();

    public virtual void Run();

These methods are meant to be overridden when either on the role is starting (OnStart), the role is stopping (OnStop), and the role has done OnStart and ready to run (Run). This is pretty interesting since most people don’t realize that the entire role instance lifecycle is available in web roles just as it is in worker roles.

The idea is actually override the Run method in the WebRole, which generally provided in the WorkerRole.cs, but not in the WebRole.cs. However, you could simply override it, and would become something like this:

public class WebRole : RoleEntryPoint
    public override void Run()
        while (true)
            var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
            var context = new TaskDataServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            context.AddTask(new Random().Next(100).ToString());
    public override bool OnStart()
        return base.OnStart();

In the example above, I override the Run method to perform a simple task, just to add a record in the table storage on every 3 seconds. Of course, you can add anything you want, typically just like what you’ve written in the worker role.

What’s actually happening on the Cloud is it will create a separate executable process that keep perform the Run method, while the IIS is still listening to the web traffic.

Is it an ideal solution?

Well, isn’t it an ideal solution? Well, the answer is pretty much depends!

If you are sure that your batch-processing jobs (inside Run) method won’t consume too much VM’s resource (e.g.: CPU / memory) AND you don’t mind to share the web resource with it, then that’s fine!

However, if you want to have separate VM that perform the particular task without affecting the web role, then you are encouraged to go with WorkerRole.

That’s all for this post. I hope it is useful to you!

Share This:

AzureUG.SG First Meeting Wrap-up

Due to various reason, finally I’ve got a chance to write this post which is suppose to be written 3 weeks ago. Yes, as mentioned in the invitation, we’d our great first user group meeting of AzureUG.SG (Singapore Windows Azure User Group) at 26th January 2011. It was attended by 30 participants. For the first meeting, it’s considered a good result Smile.

Welcome Note by David Tang, Microsoft Singapore

The meeting was welcomed by David Tang, Product Marketing Manager from Microsoft Singapore. In the welcome note, David mentioned about the opportunity and potential of cloud computing in Singapore ecosystem. And also the commitment from Microsoft to embrace seriously in Windows Azure. We would like to thanks to David for the support toward AzureUG.SG!

DSCN1302_thumb_4FE26AD5 DSCN1303_thumb_1B79BC29

Developing, Deploying, and Managing Windows Azure Application by Wely (Windows Azure MVP)

The first session was done by me, talked about Developing, Deploying,and Managing Windows Azure Application. This talk was actually derived from what Jim’s session in PDC2010. I stared my session with explaining overview of Windows Azure and complete the rest of the session with more demo. Starting with creating an application with Visual Studio,deploying it on Windows Azure Developer portal, and finally managing the deployed application via remote desktop.

DSC03258_thumb_6EA090E8 DSC03257_thumb_33F51FAD

You can download my slides and sample code over here.

Exploring Windows Azure Storage – Mohammed Faizal

The second session was done by my colleague in NCS, Faizal. Faizal discussed about Windows Azure Storage in overview first, subsequently explore more on Windows Azure Table Storage. In the subsequent user group meeting, I am sure he will talk more about Blob and Queue, let’s wait and see the future user group meeting Smile.


We would like to thanks all for the participation and support. See you on the next user group meeting!

Share This:

Applying Custom Domain Names to Windows Azure Blob Storage


If you register a Windows Azure storage service account, you will be prompted to enter a valid account name. This account name by default will be used as your blob URI. The default address would be applicable for the following format:


In example:


In many cases, we don’t want the “blob.core.windows.net” default domain. Instead, we want to implement our own domain (or sub-domain name), for example: “storage.wely-lau.net”. So that you could have your:


I am happy to inform you that, it’s possible for you to do it on Windows Azure Blob Storage.

How To


In order to perform the custom domain, I assume you have the following items:

  1. Your own Windows Azure Subscription (associated with your Windows Live Id)
  2. Your own domain registered to certain registrar such as http://godaddy.com or http://dynadot.com.

Creating Windows Azure Storage Account

1. Firstly, Login to Windows Azure Developer Portal,  and select the “Hosted Service, Storage Account & CDN” tab at the right hand side and subsequently select the “Storage Accounts”.


2. As such, the list of Subscriptions that are associated to the Windows Live Id will be shown. Click on New Storage Account button on the ribbon bar.


3. As the Create New Account dialog show up, select the intended subscription and enter your account name. Note that the account name must be globally unique. This will be form your default URL such as http://account-name.blob.core.windows.net/.

Subsequently, select your preferred region or affinity group (if you have any) and click the Create button.


If everything goes well, you will see that the status of the new created storage becomes “Created”.

Adding Your Custom Domain

4. Click on the newly created storage, and then click on Add Domain button on the ribbon bar.


5. Immediately, a dialog box shows up. You will need to enter your custom domain name there and click Configure.


Verifying Your Domain Name

6. You are not done yet, you will see the instruction to create a CNAME record at your domain registrar portal and point to verify.azure.com. The reason is, Windows Azure requires you to verify you are the owner of that custom domain.


7. Since my domain (wely-lau.net) was registered via http://dynadot.com, I’ll need to perform those action there. I believe it’s more or less the same although you are registering to other domain registrar.


Do note that, it may take a few minutes to propagate.

8. Go back to Azure Developer Portal, click on the Storage custom domain, and click on Validate Domain. After a few moments, you can see that your storage custom domain status changes to “Allowed”.


Are we done? No, we are not done yet. What we’ve done so far is to verify the domain belong to us, we have access over it.

Mapping the Custom Domain

9. Now, go back to your domain registrar portal again.

Create another CNAME record, with sub domain “blob” (if you want your address become http://blob.wely-lau.net) and point it to your storage account name (with full address).


As usual, it may takes up to a few minutes to update the domain, just be patient.

Let’s Test It Out

10. Since that was newly created azure storage account, obviously it doesn’t have any blob inside.

To test whether the custom domain work, try to upload a blob to that account. You can upload the blobs through many ways including tools such as Cerebrata Cloud Storage Studio, Azure Storage Explorer, and so many more.


11. When I type my original blob address on the browser address bar: http://welyazurestorage.blob.core.windows.net/images/Lighthouse.jpg


How about using our custom domain name http://blob.wely-lau.net/images/Lighthouse.jpg.


Here you go, it works!

I hope this post is useful to you.

Share This: