Azure WebJob obtains connection string from web application (which runs the job) configuration parameter - AzureWebJobsStorage. I need to monitor two queues in different storages using one WebJob. Is it possible somehow to have multiple connection strings for a WebJob?
1 Answers
3  
				votes
			Related to this post it is possible :
In your case, you'd like to bind to differents storage accounts so your function can look like that:
public static void JobQueue1(
    [QueueTrigger("queueName1"),
    StorageAccount("storageAccount1ConnectionString")] string message)
{
}
public static void JobQueue2(
    [QueueTrigger("queueName2"),
    StorageAccount("storageAccount2ConnectionString")] string message)
{
}
You can also implement a custom INameResolver if you want to get the connectionstrings from the config :
public class ConfigNameResolver : INameResolver
{
    public string Resolve(string name)
    {
        string resolvedName = ConfigurationManager.AppSettings[name];
        if (string.IsNullOrWhiteSpace(resolvedName))
        {
            throw new InvalidOperationException("Cannot resolve " + name);
        }
        return resolvedName;
    }
}
to use it:
var config = new JobHostConfiguration();
config.NameResolver = new ConfigNameResolver();
...
new JobHost(config).RunAndBlock();
And your new functions look like that:
public static void JobQueue1(
    [QueueTrigger("queueName1"),
    StorageAccount("%storageAccount2%")] string filename)
{
}
public static void JobQueue2(
    [QueueTrigger("queueName2"),
    StorageAccount("%storageAccount1%")] string filename)
{
}
- storageAccount1 and storageAccount2 are the connection string key in the 
appSettings 
AzureWebJobsStorage's just default but not the only thing. you can do with multiple connection strings. - Youngjae