diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs
index 49bfa9d816..3287f1b857 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs
@@ -132,6 +132,11 @@ public ChangeFeedProcessorBuilder WithPollInterval(TimeSpan pollInterval)
/// The instance of to use.
internal virtual ChangeFeedProcessorBuilder WithStartFromBeginning()
{
+ if (this.changeFeedProcessorOptions.Mode == ChangeFeedMode.AllVersionsAndDeletes)
+ {
+ throw new InvalidOperationException($"Using the '{nameof(WithStartFromBeginning)}' option with ChangeFeedProcessor is not supported with {ChangeFeedMode.AllVersionsAndDeletes} mode.");
+ }
+
this.changeFeedProcessorOptions.StartFromBeginning = true;
return this;
}
@@ -149,6 +154,11 @@ internal virtual ChangeFeedProcessorBuilder WithStartFromBeginning()
/// The instance of to use.
public ChangeFeedProcessorBuilder WithStartTime(DateTime startTime)
{
+ if (this.changeFeedProcessorOptions.Mode == ChangeFeedMode.AllVersionsAndDeletes)
+ {
+ throw new InvalidOperationException($"Using the '{nameof(WithStartTime)}' option with ChangeFeedProcessor is not supported with {ChangeFeedMode.AllVersionsAndDeletes} mode.");
+ }
+
if (startTime == null)
{
throw new ArgumentNullException(nameof(startTime));
diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/GetChangeFeedProcessorBuilderWithAllVersionsAndDeletesTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/GetChangeFeedProcessorBuilderWithAllVersionsAndDeletesTests.cs
index 0479bbb353..ee316a4932 100644
--- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/GetChangeFeedProcessorBuilderWithAllVersionsAndDeletesTests.cs
+++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/GetChangeFeedProcessorBuilderWithAllVersionsAndDeletesTests.cs
@@ -588,5 +588,53 @@ private async Task CreateMonitoredContainer(ChangeFeedMode ch
return (ContainerInternal)response;
}
+
+ [TestMethod]
+ [Owner("philipthomas-MSFT")]
+ [Description("Scenario: WithStartTime should throw an exception when used in AVAD mode.")]
+ public async Task WhenACFPInAVADModeUsesWithStartTimeExpectExceptionTestsAsync()
+ {
+ ContainerInternal monitoredContainer = await this.CreateMonitoredContainer(ChangeFeedMode.AllVersionsAndDeletes);
+
+ InvalidOperationException exception = Assert.ThrowsException(() =>
+ {
+ ChangeFeedProcessor processor = monitoredContainer
+ .GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes(
+ processorName: "processor",
+ onChangesDelegate: (ChangeFeedProcessorContext context, IReadOnlyCollection> docs, CancellationToken cancellationToken) => Task.CompletedTask)
+ .WithStartTime(DateTime.Now)
+ .WithInstanceName(Guid.NewGuid().ToString())
+ .WithLeaseContainer(this.LeaseContainer)
+ .Build();
+ });
+
+ Assert.AreEqual(
+ expected: "Using the 'WithStartTime' option with ChangeFeedProcessor is not supported with Microsoft.Azure.Cosmos.ChangeFeed.ChangeFeedModeFullFidelity mode.",
+ actual: exception.Message);
+ }
+
+ [TestMethod]
+ [Owner("philipthomas-MSFT")]
+ [Description("Scenario: WithStartFromBeginning should throw an exception when used in AVAD mode.")]
+ public async Task WhenACFPInAVADModeUsesWithStartFromBeginningExpectExceptionTestsAsync()
+ {
+ ContainerInternal monitoredContainer = await this.CreateMonitoredContainer(ChangeFeedMode.AllVersionsAndDeletes);
+
+ InvalidOperationException exception = Assert.ThrowsException(() =>
+ {
+ ChangeFeedProcessor processor = monitoredContainer
+ .GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes(
+ processorName: "processor",
+ onChangesDelegate: (ChangeFeedProcessorContext context, IReadOnlyCollection> docs, CancellationToken cancellationToken) => Task.CompletedTask)
+ .WithStartFromBeginning()
+ .WithInstanceName(Guid.NewGuid().ToString())
+ .WithLeaseContainer(this.LeaseContainer)
+ .Build();
+ });
+
+ Assert.AreEqual(
+ expected: "Using the 'WithStartFromBeginning' option with ChangeFeedProcessor is not supported with Microsoft.Azure.Cosmos.ChangeFeed.ChangeFeedModeFullFidelity mode.",
+ actual: exception.Message);
+ }
}
}