How to do Bind Azure CosmoDB by Visual Studio in Azure Functions?
Note the code below, the inputDocument parameter would be the CosmosDB Bind. When we create the direct function in the Azure portal, it already does this automatically because it already creates the connections in the local.settings.json
file.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using System.Collections.Generic;
namespace CDPCompare
{
public static class CallWS
{
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log, IEnumerable<dynamic> inputDocument)
{
foreach(var item in inputDocument)
{
log.Info(item);
}
}
}
}