0

We are trying acquire a lease on a blob by calling Microsoft Azure Blob Java api for a period of 300seconds. But the API always returns null. Has anybody faced this issue? Below is the code that we use.

public void String getBlobLeaseId(com.microsoft.azure.storage.blob.CloudBlob blob) {
    String leaseId = blob.acquireLease(300, null);
    System.out.println(leaseId);
}
Mouli S
  • 1
  • 1

1 Answers1

0

I'm actually surprised that you didn't get any error because you're specifying incorrect value for the lease duration. For infinite lease, the lease duration should be specified as -1 and for finite lease, the lease duration value should be between 15 - 60 seconds.

Ref: https://learn.microsoft.com/en-us/rest/api/storageservices/lease-blob

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Hi @Gaurav, Thanks for the link. We are processing a file which will take 5 or 10mns. We don't want infinite lease since the file can reprocessed by another node if something goes wrong. But now I see the maximum lease time is only 60s. Please let me know if there is any other option for this ? – Mouli S Nov 27 '19 at 09:49