diff --git a/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs b/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs index 2e51957..6352ac9 100644 --- a/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs +++ b/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs @@ -206,7 +206,8 @@ namespace Microsoft.Azure.EventHubs.Processor { AzureBlobLease retval = null; - CloudBlockBlob leaseBlob = this.consumerGroupDirectory.GetBlockBlobReference(partitionId); + CloudBlockBlob leaseBlob = GetBlockBlobReference(partitionId); + if (await leaseBlob.ExistsAsync().ConfigureAwait(false)) { retval = await DownloadLeaseAsync(partitionId, leaseBlob).ConfigureAwait(false); @@ -232,7 +233,7 @@ namespace Microsoft.Azure.EventHubs.Processor AzureBlobLease returnLease; try { - CloudBlockBlob leaseBlob = this.consumerGroupDirectory.GetBlockBlobReference(partitionId); + CloudBlockBlob leaseBlob = GetBlockBlobReference(partitionId); returnLease = new AzureBlobLease(partitionId, leaseBlob); string jsonLease = JsonConvert.SerializeObject(returnLease); @@ -470,5 +471,18 @@ namespace Microsoft.Azure.EventHubs.Processor } return retval; } + + CloudBlockBlob GetBlockBlobReference(string partitionId) + { + CloudBlockBlob leaseBlob = this.consumerGroupDirectory.GetBlockBlobReference(partitionId); + + // GetBlockBlobReference creates a new ServiceClient thus resets options. + // Because of this we lose settings like MaximumExecutionTime on the client. + // Until storage addresses the issue we need to override it here once more. + // Tracking bug: https://github.com/Azure/azure-storage-net/issues/398 + leaseBlob.ServiceClient.DefaultRequestOptions = this.storageClient.DefaultRequestOptions; + + return leaseBlob; + } } } \ No newline at end of file diff --git a/src/Microsoft.Azure.EventHubs.Processor/project.json b/src/Microsoft.Azure.EventHubs.Processor/project.json index 96c54da..71d6b89 100644 --- a/src/Microsoft.Azure.EventHubs.Processor/project.json +++ b/src/Microsoft.Azure.EventHubs.Processor/project.json @@ -23,7 +23,7 @@ "target": "project" }, "Newtonsoft.Json": "9.0.1", - "WindowsAzure.Storage": "7.2.1" + "WindowsAzure.Storage": "8.0.1" }, "frameworks": {