public void TestCanUseLeaseIdForBlobOperations() { using var provider = new TestingAzureBlobLeaseDistributedLockProvider(); var name = provider.GetUniqueSafeName(); var client = new PageBlobClient(AzureCredentials.ConnectionString, AzureCredentials.DefaultBlobContainerName, name); const int BlobSize = 512; client.Create(size: BlobSize); var @lock = new AzureBlobLeaseDistributedLock(client); using var handle = @lock.Acquire(); Assert.Throws <RequestFailedException>(() => client.UploadPages(new MemoryStream(new byte[BlobSize]), offset: 0)) .ErrorCode.ShouldEqual(AzureErrors.LeaseIdMissing); Assert.DoesNotThrow( () => client.UploadPages(new MemoryStream(new byte[BlobSize]), offset: 0, conditions: new PageBlobRequestConditions { LeaseId = handle.LeaseId }) ); handle.Dispose(); Assert.Throws <ObjectDisposedException>(() => handle.LeaseId.ToString()); }