I am following Microsoft Learn path :
https://learn.microsoft.com/en-us/learn/modules/chain-azure-functions-data-using-bindings/7-write-data-with-output-bindings-portal-lab?pivots=javascript
I am trying to use the input binding for CosmoDB, in the example of Microsoft, the Input binding of CosmoDB is done through query string. On the "Try it", I don't see any http request with parameters, only JSON parameter into the request body
Can someone explain my what's happening ? I am confuse, how the ID binding is made from the request body ?
Remarks: I did the exercise on NET Core azure function
public class Function1
{
//http://localhost:7071/api/CosmoDbActionsSandbox/blog/blog/
[FunctionName(nameof(CosmoDbActionsSandbox))]
public async Task<IActionResult> CosmoDbActionsSandbox(
[HttpTrigger(AuthorizationLevel.Function, "get", "post",
Route = nameof(CosmoDbActionsSandbox) + "/{id}")] HttpRequest req,
[CosmosDB(databaseName: "func-io-learn-db",
collectionName: "Bookmarks",
ConnectionStringSetting = "CosmosDBConnection",
Id = "{id}",
PartitionKey = "{id}")] Bookmark bookmark,
[CosmosDB(databaseName: "func-io-learn-db",
collectionName: "Bookmarks",
ConnectionStringSetting = "CosmosDBConnection",
PartitionKey = "{id}")] IAsyncCollector<Bookmark> bookmarkOutput,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
Bookmark newBookmark = JsonConvert.DeserializeObject<Bookmark>(requestBody);
if (bookmark != null)
return new StatusCodeResult(422);
else
{
await bookmarkOutput.AddAsync(newBookmark);
return new OkObjectResult(newBookmark);
}
}
}