public String acquireLease(int leaseTimeInSec, String leaseId) {
    try {
      String id = leaseBlob.acquireLease(leaseTimeInSec, leaseId);
      LOG.info("Acquired lease with lease id = " + id);
      return id;
    } catch (StorageException storageException) {
      int httpStatusCode = storageException.getHttpStatusCode();
      if (httpStatusCode == HttpStatus.CONFLICT_409) {
        LOG.info("The blob you're trying to acquire is leased already.", storageException.getMessage());
      } else if (httpStatusCode == HttpStatus.NOT_FOUND_404) {
        LOG.error("The blob you're trying to lease does not exist.", storageException);
        throw new AzureException(storageException);
      } else {
        LOG.error("Error acquiring lease!", storageException);
        throw new AzureException(storageException);
      }
    }
    return null;
  }
Acquires a lease on a blob. The lease ID is NULL initially.
@param leaseTimeInSec The time in seconds you want to acquire the lease for.
@param leaseId Proposed ID you want to acquire the lease with, null if not proposed.
@return String that represents lease ID.  Null if acquireLease is unsuccessful because the blob is leased already.
@throws AzureException If a Azure storage service error occurred. This includes the case where the blob you're trying to lease does not exist.
samza-azure/src/main/java/org/apache/samza/util/LeaseBlobManager.java