After Swap Azure Function with CosmosDBTrigger Continues Firing On Slot that was Swapped Out

Steve Feidelberg 1 Reputation point
2021-01-25T21:12:02.857+00:00

I've got a function app that is configured as follows:

In production using Azure release pipeline I deploy a new version as follows:

  1. Deploy new version of code to slot
  2. Wait for StatusCheck to return isRunning = false
  3. Swap

Actual: The staging slot (i.e. that now has the "old" code) takes over. More specifically the CosmosDBTrigger on the staging slot appears to be "stealing" the Cosmos updates. If I stop the staging slot then the CosmosDBTrigger on the production slot wins out.

Expectation: That the production slot (i.e. the one with the "new" code) takes over without having to stop the staging slot

Am I missing anything here is there any configuration I need to modify to get the production slot (i.e. new code) CosmosDBTrigger to take over. I would assume the same type of deal applies to other triggers as well.

Thanks

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,309 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,450 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2021-10-07T15:25:41.48+00:00

    Lol, 10 months and no feedback? Did you find any solution to this issue?

    0 comments No comments

  2. Dongyong Li 0 Reputation points Microsoft Employee
    2023-09-15T08:09:41.7433333+00:00

    Hi Steve, I met the same problem and it takes me a while to understand the logic.

    First, slot traffic router will not control the ComsmosDBTrigger message, becuase it is not Http.

    Second, when two azure function runs and they subscribe to the same container, the one which first start will take control, and process the change. It is recored in lease container, the fields is "Owner".

    To solve this problem when deploying with slots, disable the function in the settings, and make is sticky to slots. Or you can use different lease prefix for different slots.

    example:

    set AzureWebJobs.xxxYourFunctionxxx.Disabled to false for production slot and true for staging slot.

    0 comments No comments