azure-functionsazureservicebusazure-servicebus-subscriptions

How to stop a ServiceBusTrigger Azure function from listening to a topic subscription?


I want to disable a ServiceBusTrigger Azure function from listening to a topic subscription in the code. Let's call the function 'MyFunction'. Locally in local.settings.json file, I can add this setting and it disables the function completely. local.settings.json doesn't get deployed as it's only used locally by .NET/VS.

  "Values": {
    "AzureWebJobs.MyFunction.Disabled": true
  }

However, I tried to add the same setting in appSettings.json, the setting has no effect. The Azure function was retrieving messages from the topic.

Putting an if statement in the body of the function to stop any processing will still cause the function to read a message from the topic in an endless loop.

AutoCompleteMessages = false also doesn't stop the function from retrieving messages.

How do I disable the azure function from listening to the topic completely?


Solution

  • I didn't mention that my Azure function runs in an app container. Here's how to disable the Azure function.