surzyn
surzyn

Reputation: 151

Azure service bus subscription action - set subscription name as custom properties

I need to add custom property for message that is autoforwarded from subscription. Value for new property should be subscription name. I have found that I can use subscription rule for adding new properties to message and I'm able to add some hardcoded value there but I can't find how to get subscription name.

Here is example how I'm setting new property with hardcoded value in rule:

SET user.originQueue = 'test'

I was looking here Subscription Rule SQL Action Syntax but I don't see how I can get the subscription name

Also is a way for preview subscription rule in azure portal? I can see only filters in portal. For now I'm using command line for verifying the rules.

Upvotes: 1

Views: 560

Answers (1)

Jdresc
Jdresc

Reputation: 688

You can get the name using the administration client

    using Azure.Messaging.ServiceBus.Administration;
    var adminclient = new ServiceBusAdministrationClient(ServiceBusConnectionString);
    SubscriptionProperties runtime = await adminclient.GetSubscriptionAsync(queueName, "subscription-test");
    Console.WriteLine("This is the subscription name " + runtime.SubscriptionName);

https://learn.microsoft.com/en-us/dotnet/api/azure.messaging.servicebus.administration?view=azure-dotnet

Upvotes: 2

Related Questions