diff --git a/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ContainerScanInfo.cs b/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ContainerScanInfo.cs index f9008f957..ef3531531 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ContainerScanInfo.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ContainerScanInfo.cs @@ -17,5 +17,6 @@ internal class ContainerScanInfo public DateTime CurrentSweepCycleLatestModified { get; set; } public BlobContinuationToken ContinuationToken { get; set; } + public DateTime CurrentSweepCycleStartTime { get; set; } } } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ScanBlobScanLogHybridPollingStrategy.cs b/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ScanBlobScanLogHybridPollingStrategy.cs index 81a9992f0..1ac17df88 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ScanBlobScanLogHybridPollingStrategy.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/Listeners/ScanBlobScanLogHybridPollingStrategy.cs @@ -76,6 +76,7 @@ public async Task RegisterAsync(CloudBlobContainer container, ITriggerExecutor>(), LastSweepCycleLatestModified = latestStoredScan ?? DateTime.MinValue, + CurrentSweepCycleStartTime = DateTime.MinValue, // value not used as it is set on first use when the continuationToken is null. CurrentSweepCycleLatestModified = DateTime.MinValue, ContinuationToken = null }; @@ -214,6 +215,7 @@ public async Task> PollNewBlobsAsync( // if starting the cycle, reset the sweep time if (continuationToken == null) { + containerScanInfo.CurrentSweepCycleStartTime = DateTime.UtcNow; containerScanInfo.CurrentSweepCycleLatestModified = DateTime.MinValue; } @@ -259,7 +261,8 @@ public async Task> PollNewBlobsAsync( var properties = currentBlob.Properties; DateTime lastModifiedTimestamp = properties.LastModified.Value.UtcDateTime; - if (lastModifiedTimestamp > containerScanInfo.CurrentSweepCycleLatestModified) + // if we are not the first page of this scan (ie, we have a continuation token), then we can not advance past the time the first page was called, otherwise we might miss updates to those blobs + if (lastModifiedTimestamp > containerScanInfo.CurrentSweepCycleLatestModified && (continuationToken == null || lastModifiedTimestamp < containerScanInfo.CurrentSweepCycleStartTime)) { containerScanInfo.CurrentSweepCycleLatestModified = lastModifiedTimestamp; }