Cosmos DB Bindings with HTTP Triggers on Isolated Runtime Azure Functions

azure functions example code cosmos db

This is a quick start on using the Cosmos DB Bindings with HTTP Triggers on Isolated Runtime Azure Functions.


I threw this together because all the Isolated Runtime examples were using Queues which don't require the extra output that HTTP Triggers require to provide a proper return status.

Check out the code on GitHub

The most important items of note are for the input binding you have to have an extra class specifically made to handle the two output types.

public class CreatePartOutput 
{
    [CosmosDBOutput("demo", "test", Connection = "CosmosConnection")]
    public IReadOnlyList<Part> CosmosOut { get; set; }
    public HttpResponseData HttpResponse { get; set; }
}

You can see that the output attribute is in the class itself. This does bring up an interesting point though of Isolated Functions potentially allowing an arbitrary number of output bindings which could be useful for specific event routing needs.

If you run into any issues with the code make sure to throw them into GitHub issues!

Previous Post