Disable azure durable function in staging slot

627 Views Asked by At

I have a function app (a service bus trigger function and it is a durable function containing a starter, orchestrator, activity functions) with a production and a staging slot.

I do not want the functions in the staging slot to be tripped by the queue elements in the service bus. I have disabled the starter function in the staging slot by adding a setting AzureWebJobs.StarterFunction.Disabled = 1.

I still see all other functions in the staging slot running. Should I add the setting to disable all the functions in the staging slot? Is there a different approach to make sure that the functions in staging don't run?

1

There are 1 best solutions below

0
On

We had the same problem and added a simple hack that does the trick.

  1. Create a fake Service Bus that has a queue with the same name as your production service bus.

  2. In your Azure Function's Staging Slot's Configuration blade, override your Service Bus Connection string. Mark this setting as a Deployment Slot setting. This way, it won't be swapped when you swap slots.

  3. Deploy to your staging slot as you currently do. Your Azure Function will read the Service Bus connection string from your App Configuration. Since nothing is putting messages into this Service Bus queue, the binding is not triggered.

You'll also need to be cognizant of how you handle your Durable Task taskhub name in host.json. If you use the same hardcoded name between your staging and prod slots, your staging deployment will begin running orchestrator and activity functions from prod.