I have an azure function that I'd like to have target 2 different queues.
I don't really want to have 2 separate repositories to manage and to try to keep them identical. For testing my functions, I've been using precompiler statements and thought I might be able to simply expand that like this:
public static class ProdIndividualParse
{
#if DEBUG
[FunctionName("TESTIndividualParse")]
[Timeout("60:00:00")]
public async static Task Run([QueueTrigger("parse-to-cosmos", Connection = "QueueAddress")]string myQueueItem, TraceWriter log)
#elif RELEASE
[FunctionName("PRODIndividualParse")]
[Timeout("10:00:00")]
public async static Task Run([QueueTrigger("prod-cosmos-parse", Connection = "QueueAddress")]string myQueueItem, TraceWriter log)
#elif DEV
[FunctionName("DEVIndividualParse")]
[Timeout("10:00:00")]
public async static Task Run([QueueTrigger("dev-cosmos-parse", Connection = "QueueAddress")]string myQueueItem, TraceWriter log)
#endif
(no idea how to format this properly with the '#' signs)
I have tried adding a key-value pair to the settings of the dev environment: CONFIGURATION DEV to no avail.
Queue name can be taken from Application Setting. Add a setting called e.g. myqueuename
and then define your function as
[FunctionName("IndividualParse")]
[Timeout("10:00:00")]
public async static Task Run([QueueTrigger("%myqueuename%", Connection = "QueueAddress")]
string myQueueItem, TraceWriter log)
Obviously, you can set different values for Dev vs Test Vs Prod environments, as long as they are in separate Function Apps or slots.