Reputation: 61
How can I create two azure functions in C# under single solution where each functionApp reads messages from two different queues respectively? I am unable to specify %queueName% for both functions at same time in localhost json file.
[FunctionName("FuncA")]
public static async Task Run([ServiceBusTrigger("%queueName%", Connection = "sb_connection_string")]string myQueueItem, ILogger log)
{
}
and
[FunctionName("FuncB")]
public static async Task Run([ServiceBusTrigger("%failedQueueName%", Connection = "sb_connection_string")]string myQueueItem, ILogger log)
{
}
local setting json file :
"queueName" : "queueA",
"%failedQueueName%":"queueB"
How to read messages from queueB in funcB?
Error: Microsoft.Azure.WebJobs.Host: '%failedQueueName%' does not resolve to a value.
Upvotes: 1
Views: 770
Reputation: 14103
First of all, what you want to do is definitely possible.
Then I need to explain to you the meaning of the percent sign. In your binding or trigger, in addition to Connection being parsed as an environment variable by default, you need to use a form like %key%
to specify the value from the environment variable in other locations. Once you mark this way, the function host will try to find the environment variable whose key name is 'key' in the environment variable and replace %key%
with the value of the corresponding key.
So, the format on your side your be like these:
In trigger or binding, use:
[ServiceBusTrigger("%queueName%", Connection = "sb_connection_string")]
[ServiceBusTrigger("%failedQueueName%", Connection = "sb_connection_string")]
And set the 'queuename' and 'failedQueueName' in local.settings.json(On azure, you need to set it in the configuration settings.). Like this:
{
"IsEncrypted": false,
"Values": {
"queueName": "xxx",
"failedQueueName": "xxx",
"sb_connection_string": "xxx"
}
}
And this is the official doc:
Upvotes: 1