I have CosmosDBTrigger on my 3 WebJobs which is targeting the same container. Meaning, whenever any Upsert happens on this container, these 3 should be triggered. I am seeing the issue where 1 out of 3 job is not triggering and trying to understand why.
I manually disabled these jobs for debug purpose where I hit the break point for WebJob2 and WebJob3. When I do the same for WebJob1 then nothing happens.
This is how CosmosDBTrigger is defined on jobs. If 2 jobs are triggering, then logic seems good to me. Here, WebJob1 is not triggering. What am I missing here?
WebJob1:
public async Task ProcessMessageAsync(
[CosmosDBTrigger(
"%Database:DatabaseName%",
"%Database:ContainerName%",
Connection = CosmosDbConnectionString,
CreateLeaseContainerIfNotExists = true,
LeaseContainerName = "leases",
LeaseContainerPrefix = nameof(WebJob1)
)]
string documents, CancellationToken cancellationToken)
{
// Logic
}
WebJob2:
public async Task ProcessMessageAsync(
[CosmosDBTrigger(
"%Database:DatabaseName%",
"%Database:ContainerName%",
Connection = CosmosDbConnectionString,
CreateLeaseContainerIfNotExists = true,
LeaseContainerName = "leases",
LeaseContainerPrefix = nameof(WebJob2)
)]
string documents, CancellationToken cancellationToken)
{
// Logic
}
WebJob3:
public async Task ProcessMessageAsync(
[CosmosDBTrigger(
"%Database:DatabaseName%",
"%Database:ContainerName%",
Connection = CosmosDbConnectionString,
CreateLeaseContainerIfNotExists = true,
LeaseContainerName = "leases",
LeaseContainerPrefix = nameof(WebJob3)
)]
string documents, CancellationToken cancellationToken)
{
// Logic
}
Theory which fixed this issue: This was due to manually adding or deleting entries in lease container, which corrupted it and caused job's pointer misaligned. Redeployment of the ARM template for cosmos fixed this issue.