0

Below is my code to acquire lease on file in azure fileshare. Before acquiring lease, I need to check lease status of file.

var shareClient = new ShareClient(connectionString, "testfileshare");
shareClient.CreateIfNotExists();
var fileClient = shareClient.GetRootDirectoryClient().GetFileClient("test.xml"); 
var leaseClient = fileClient.GetShareLeaseClient();

//Lease status check to add here

var leaseId = leaseClient.Acquire();
leaseClient.Break();

Thanks.

  • Does this answer your question? [Is it possible to check if there is a lease on a specific Azure blob, using the Python SDK?](https://stackoverflow.com/questions/61305916/is-it-possible-to-check-if-there-is-a-lease-on-a-specific-azure-blob-using-the) – Ecstasy Apr 21 '22 at 05:00
  • You can refer to [After a acquire a lease for a azure blob where do I find the release ID so I can release it?](https://stackoverflow.com/questions/71946449/how-i-can-check-lease-status-before-acquiring-lease-on-file-in-azure-fileshare) and [Lease File](https://learn.microsoft.com/en-us/rest/api/storageservices/lease-file) – Ecstasy Apr 21 '22 at 05:01

0 Answers0