Thursday, August 30, 2012

Azure version conflict sucks!

Yes Azure version conflict is a pain in the neck and the OS does its part as well! Ridiculous version numbering system!! There is a name for each version: file version, assembly version... which is there just to confuse us :)

This is taken from visual studio


This version number comes from file system. Why one earth cant they cant provide the same in visual studio or the other way around?
How about this! a dll from the same location and version listed two times in add reference window!!

I found a tool which help you figure out the dll version as given in VS on file : http://powerext.codeplex.com/dotpeek from jetbrains in another free tool.
 

Thursday, August 23, 2012

Testing Transient errors in Azure

It is a bit difficult to generate a genuine throttling exception for testing purposes. But we can easily create fakes.
Create a mock class derived from ITransientErrorDetectionStrategy and return true(IsTransient). Use this class in
 var retryPolicy = new RetryPolicy<MockClass>(retryStrategy);  
Throw any exception in code and that is it, it retries!
If needed the ITransientErrorDetectionStrategy can be injected for unit testing.

ITransientErrorDetectionStrategy implementation is described in this class diagram and for more reading here

//------------------Code-
 
using Microsoft.Practices.TransientFaultHandling;
using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling;
...
// Define your retry strategy: retry 5 times, starting 1 second apart
// and adding 2 seconds to the interval each retry.
var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), 
  TimeSpan.FromSeconds(2));
// Define your retry policy using the retry strategy and the Windows Azure storage
// transient fault detection strategy.
var retryPolicy =
  //new RetryPolicy<StorageTransientErrorDetectionStrategy>(retryStrategy);
new RetryPolicy<TransientMock>(retryStrategy);
// Receive notifications about retries.
retryPolicy.Retrying += (sender, args) =>
    {
        // Log details of the retry.
        var msg = String.Format("Retry - Count:{0}, Delay:{1}, Exception:{2}",
            args.CurrentRetryCount, args.Delay, args.LastException);
        Trace.WriteLine(msg, "Information");
    };
try
{
  // Do some work that may result in a transient fault.
  retryPolicy.ExecuteAction(
    () =>
    {
        // Call a method or write on or more statements that uses Windows Azure storage and which  may
        // throw a transient exception. 
       //for the mock to work throw any exception
       throw new Exception();
        this.queue.CreateIfNotExist();
    });
}
catch (Exception)
{//exceptions not caught by transient framework comes here
  // All the retries failed.
}



//==========================
public class TransientMock : ITransientErrorDetectionStrategy
{
 public bool IsTransient(Exception ex)
        {
  return true;
        }
} 
~comment your thoughts, please~

Monday, August 20, 2012

TableStorageEntity vs TableServiceEntity

In the early days of Azure, a table entity was represented by the base class TableStorageEntity. This has been changed to TableServiceEntity

Friday, August 17, 2012

Could not load file or assembly 'Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0

Azure error ApplicationServer.Caching.Client, Version=1.0.0.0 !











solved it!
The version I had in my dev box was ApplicationServer.Caching.Client, Version=101.0.0.0
but some other dll is asking for 1.0 version, which one?

These three seems to be connected :
1) Microsoft.ApplicationServer.Caching.Client
2) Microsoft.ApplicationServer.Caching.Core
3) Microsoft.Web.DistributedCache.dll

My problem was with Microsoft.Web.DistributedCache.dll !
It had 1.0.0.0 version and naturally it requires ApplicationServer.Caching.Client to be 1.0 as well. I changed DistributedCache.dll to version 101 and it worked !

if you still have issue or similar dll mismatch issues, check this out for the step by step approach.

For deployment related errors we can quickly check this by copying the dlls from local dev machine to azure directly through rdp. Redeploying takes time(to try out). Ofcourse we need to update the deployment for the next deployment.

To copy dll : Azure management portal ->instances->connect button.

comment your thoughts please