Reputation: 2161
I have a Azure Function V2.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[CosmosDB(
databaseName:"ct",
collectionName:"ops",
ConnectionStringSetting ="cosmosConn")] IAsyncCollector<object> docs,
ILogger log)
{..................
When running locally I put the "cosmosConn" setting in the
local.settings.json
file. I published the app to Azure and and placed a setting called "cosmosConn"in the application settings but when I call the app I am getting an error.
500 Internal Server Error.
I can access the connections string in the body of the function with
var secret = Environment.GetEnvironmentVariable("cosmosConn");
The bindings don't seem to be able to pick enviromentVariable up? How should I proceed?
Upvotes: 0
Views: 73
Reputation: 15603
If you place cosmosConn
as an Application Setting in your Function App, it will read it.
Are you sure the error comes from that? Did you check your Application Insight logs to see the full stack trace of the exception?
Check if there isn't any other error that is affecting your deployed app.
Upvotes: 1