Looking to understand if this is possible. If so, then how? If not, then why?
I would like to have a single azure queue function process messages like this:
{
"tenanatDb": Db_Name_3102,
"command": "getCountryCurrencies",
"args": "US"
}
I'm using DI so in my Function I have a Startup
internal class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddDbContext<MyDbContext>(options =>
options
.UseSqlServer("<ConnectionString>"));
builder.Services.AddSingleton<IMyService>((s) => {
return new MyService();
});
}
}
I can provide a connection string, however, what can I do so that a standard connection string is used, but the Database is specified at runtime from the Queue Message:
Server=myServerAddress;Database=***Db_Name_3102***;User Id=myUsername;Password=myPassword;
Thanks
I have been able to get this working in this way, however, it does not use Dependency Injection.
SomeClass obj = new SomeClass("DatabaseName");
obj.getCoutnryCurrecies(args);
In the SomeClass constructor, I'm setting up the database connection string.