Azure / Azure/azure-functions-host
Azure function's http trigger with cosmosDB output binding is giving 500 internal server error when deployed.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
i have an http trigger with an output binding of CosmosDB (sql api) that gives 500 internal server error when i make a POST call on to the deployed version.
the same code works fine locally.
no logs are generated in KUDU and in the portal for the failed requests. if i remove the cosmosDB binding it works locally (i can see document being created) and in deployed url as well, and success logs are also generated.
However once i was able to observe some error message like "Error parsing boolean value. Path '', line 1, position 1." but after that i was never able to see this problem in logs. because there are no logs in case of 500 internal server error. activating app insights also doesn't shows any failed 500 hit being made.
#### Investigative information
Please provide the following:
- Timestamp:
- Function App version (1.0 or 2.0): 2
- Function App name: haveThatFuncs
- Function name(s) (as appropriate): AddRequest
- Invocation ID:
- Region:
#### Repro steps
Provide the steps required to reproduce the problem:
create a new azure function using httpTrigger (version 2)
install nuget Microsoft.Azure.WebJobs.Extensions.CosmosDB
set values in settings.
` public class Request {
public string ItemRequested {
get;
set;
}
}
public static class AddRequest {
[FunctionName("AddRequest")]
public static async Task < IActionResult > Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] Request request,
ILogger log, [CosmosDB(
databaseName: "haveThatDB",
collectionName: "Requests",
ConnectionStringSetting = "CosmosDBConnection", CreateIfNotExists = true)] IAsyncCollector < Request > requestOutput
)
{
// await requestOutput.AddAsync(request);
return request != null ?
(ActionResult) new OkObjectResult($ "Added Item, " + request.ItemRequested) :
new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}`
#### Expected behavior
after i hit the url using postman with packet
{"ItemRequested":"something"}
it should run normally as it runs locally.
#### Actual behavior
it gives 500 internal server error when i hit the url using postman
and it runs properly when i run it using visual studio.
#### Known workarounds
Provide a description of any known workarounds.
#### Related information
Provide any related information
* Programming language used
* Links to source
* Bindings used
Contributor guide
Research direction
The issue provides a C# Azure Functions v2 reproduction using an HTTP trigger and Cosmos DB output binding, but names no host files or tests. Start by reproducing the POST locally and on the deployed function, then compare the binding settings and available logs; done means the deployed request succeeds with the Cosmos DB binding enabled and produces the expected document.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100