I have a simple SqlTrigger Azure function. I am trying to set the ConnectionStringSetting
property dynamically through code but it’s not working and the function is throwing below exception:-
Microsoft.Azure.WebJobs.Extensions.Sql: ConnectionStringSetting
‘SqlConnectionStringSetting’ is missing in your function app settings,
please add the setting with a valid SQL connection string.
I am setting the Environment variable in the Program.cs
file:-
Environment.SetEnvironmentVariable("SqlConnectionStringSetting","myCS");
And using the same in trigger like this:-
public async Task Run(
[SqlTrigger("[dbo].[ToDo]", "%SqlConnectionStringSetting%")]
What’s weird is if I just add the setting in my local.settings.json
file as Environment variable and not as ConnectionString, it’s working. So I am wondering why it’s not working when I am setting the same programmatically?