private void AcquireBlobLease(LeaseTakingPolicy policy)
        {
            string ProposedLeaseId = Guid.NewGuid().ToString();
            bool   isDone          = false;

            // if policy == LeaseTakingPolicy.TryUntilSuccessful then loop indefinitely
            while (!isDone)
            {
                try
                {
                    LeaseId  = blob.AcquireLease(null, ProposedLeaseId);
                    HasLease = true;
                    isDone   = true;
                }
                catch (StorageException ex)
                {
                    HasLease = false;
                    if (StorageExceptionCode.Conflict(ex)) //Conflict
                    {
                        if (policy == LeaseTakingPolicy.TryOnce)
                        {
                            isDone = true;
                        }
                    }
                    else
                    {
                        ReleaseBlobLease();
                        throw;
                    }
                }
            }
        }
 /// <summary>
 /// Trys to acquire the lease on a blob.
 /// Note that the caller must check HasLease to see whether the acquisition succeeded.
 /// </summary>
 /// <param name="blob">Particular blob we would like to take the lease on</param>
 /// <param name="policy">Whether to try once or many times</param>
 /// <returns>An instance of the CloudBlobLease object.</returns>
 public CloudBlobLease(ICloudBlob blob, LeaseTakingPolicy policy)
 {
     this.blob = blob;
     AcquireBlobLease(policy);
 }
 /// <summary>
 /// Trys to acquire the lease on the configuration blob.
 /// Note that the caller must check HasLease to see whether the acquisition succeeded.
 /// </summary>
 /// <param name="containerName">Name of the container/configuration</param>
 /// <param name="policy">Whether to try once or many times</param>
 /// <returns>An instance of the CloudBlobLease object.</returns>
 public CloudBlobLease(string containerName, LeaseTakingPolicy policy)
 {
     this.blob = ClientRegistry.GetConfigurationContainer(containerName).GetBlockBlobReference(ConstPool.CURRENT_CONFIGURATION_BLOB_NAME);
     AcquireBlobLease(policy);
 }