Search code examples
c#azure-functionsazure-servicebus-topicsazure-servicebus-subscriptions

Setting MaxDeliveryCount on Azure service bus dynamically


How can I set the MaxDeliveryCount on a Azure service bus Topic subscription from an Azure function.

I have tried to use NamespaceManager like this.

var manager = NamespaceManager.CreateFromConnectionString(connectionString);
var subscription = manager.GetSubscription("topic", "subscription");
subscription.MaxDeliveryCount = 10;

But it doesn't change.

I read some posts that says it is not possible and you need to do it from the portal, but you can set it from Service Bus Explorer, so it must be possible.

Thanks


Solution

  • Figured it out, you need to call UpdateSubscription like this.

    var manager = NamespaceManager.CreateFromConnectionString(connectionString);
    var subscription = manager.GetSubscription("topic", "subscription");
    subscription.MaxDeliveryCount = 10;
    manager.UpdateSubscription(subscription);