async Task <bool> TryAquireLeaseAsync() { bool leaseAcquired; try { this.settings.Logger.LeaseAcquisitionStarted( this.storageAccountName, this.taskHub, this.workerName, this.appLeaseContainerName); await appLeaseContainer.AcquireLeaseAsync(this.options.LeaseInterval, this.appLeaseId); await this.UpdateOwnerAppIdToCurrentApp(); leaseAcquired = true; this.settings.Logger.LeaseAcquisitionSucceeded( this.storageAccountName, this.taskHub, this.workerName, this.appLeaseContainerName); } catch (DurableTaskStorageException e) { leaseAcquired = false; this.settings.Logger.LeaseAcquisitionFailed( this.storageAccountName, this.taskHub, this.workerName, this.appLeaseContainerName); this.settings.Logger.PartitionManagerWarning( this.storageAccountName, this.taskHub, this.workerName, this.appLeaseContainerName, $"Failed to acquire app lease with appLeaseId {this.appLeaseId}. Another app likely has the lease on this container. Exception: {e.Message}"); } return(leaseAcquired); }