ZoharYosef ZoharYosef - 3 months ago 32
C# Question

Get ServiceBusTrigger name from App.config in Console App

I have function that receive ServiceBusTrigger message:

public static void ProcessQueueMessage([ServiceBusTrigger("mysb")] string message)
{
// do something with message
}


when I send message to "mysb" Azure Que - this function start to work.

My question is: Can I take the Que name from the App.config?

Answer

This SO question seems to answer your question.

You'll use this code: Microsoft.WindowsAzure.CloudConfigurationManager.GetSettings("QueueName")

With this kind of code in your app.config file:

<configuration>
  <appSettings>
   <add key="QueueName" value="mysb"/>
  </appSettings>
</configuration>