Thursday, September 13, 2012

Awesome Azure Diagnostics!

Just started working on diagnostics in azure and I can't help expressing  my happiness about the features it provides.

1) Errors and logs can be treated equally: Errors and traces and logs can all be logged as traces(advantage given below).

2) Tier wise tracing: You decide which layer should trace. Data layer , service layer Etc. This is done with Trace Switching.

3) Filter on Tier wise tracing:  Filter what needs to be traced. Errors,Information,Warning ,etc.

4) Transfer logs/traces to storages periodically with the help of Azure Diagnostics  library

5) Filter on Transfer : You decide what to Transfer (Errors,Information,Warning ,etc).

Easy to visualise architecture wise !  Easy to implement coding wise!

It is not over! This one is my favourite:

6) Runtime change of filtering and fetching: We usually put diagnostic related info in web.config. But by putting this in ServiceConfiguration.cscfg , we can trigger the changing event to reset the filtering and tracing.

Developers spend years amassing skills to become an architect but then they did not work on Azure!

 

Tuesday, September 11, 2012

Edit Azure config files in emulator

The deployment ID of Windows Azure can be see this by checking the development fabric UI from the system tray while the service is running. This will be a number like 177.

find the config file and update it and run this command:
csrun /update:NNN;ServiceConfiguration.cscfg

Tip: search 'ServiceConfiguration.cscfg' to find where the build has deployed the dlls.


 

Unit testing Azure components

You could run the emulator on [Assembly Initialise] of the test project.
ProcessStartInfo start = new ProcessStartInfo  
{                                              
    Arguments = "/devstore:start",                                              
    FileName = @"C:\Program Files\Windows Azure Emulator\emulator\csrun.exe"                         
}; 
 
 
for more these two links might helphttp://andrewmatthewthompson.blogspot.nl/2011/12/deploying-packages-to-azure-compute.html
to test storage : http://www.neovolve.com/post/2012/01/12/Integration-testing-with-Azure-development-storage.aspx


How to manually edit a azure config file in emulator : click here


 

Monday, September 3, 2012

ErrorCode < ERRCA0021>:SubStatus < ES0001>:Server collection cannot be empty

ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty
This could be caused by incorrect configuration.
I was using caching preview and in my case it was a configuration error
  <dataCacheClients>
       <dataCacheClient name="default">
         <autoDiscover isEnabled="false" identifier="VideoDeals" />
       </dataCacheClient>
   </dataCacheClients>
I changed isEnabled to "true" and it worked!

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