How to set Azure WebJob queue name at runtime?

后端 未结 4 1745
一个人的身影
一个人的身影 2020-11-29 05:37

I am developing an Azure WebJobs executable that I would like to use with multiple Azure websites. Each web site would need its own Azure Storage queue.

The proble

4条回答
  •  情歌与酒
    2020-11-29 06:19

    A slight better implementation of name resolver to avoid fetching from configuration all time. It uses a Dictionary to store the config values once retrieved.

    using Microsoft.Azure.WebJobs;
    using System.Collections.Generic;
    using System.Configuration;
    
    public class QueueNameResolver : INameResolver
    {
        private static Dictionary keys = new Dictionary();
        public string Resolve(string name)
        {
            if (!keys.ContainsKey(name))
            {
                keys.Add(name, ConfigurationManager.AppSettings[name].ToString());
            }
            return keys[name];
        }
    }
    

提交回复
热议问题