From Azure Queue to Azure Storage Blob Container
public static void Run(
[QueueTrigger("order-new", Connection = "AzureWebJobsStorage")] string myQueueItem,
[Blob("order-processed/{rand-guid}.json")] out string acceptedQueueItem,
ILogger log)
{
Order data = JsonConvert.DeserializeObject<Order>(myQueueItem);
acceptedQueueItem = JsonConvert.SerializeObject(data);
}
From Azure Queue to Azure NoSQL CosmosDB Container
public static void Run(
[QueueTrigger("order-new", Connection = "AzureWebJobsStorage")] string myQueueItem,
[CosmosDB(databaseName: "MyCosmosDB", collectionName: "Orders",
ConnectionStringSetting = "MyCosmosDBConnectionString")]IAsyncCollector<dynamic> myCosmosItem,
ILogger log)
{
Order data = JsonConvert.DeserializeObject<Order>(myQueueItem);
myCosmosItem.AddAsync(data);
}
Sources:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-add-output-binding-cosmos-db-vs-code?pivots=programming-language-csharp
Comments