-
Notifications
You must be signed in to change notification settings - Fork 18
/
SaveChat.cs
26 lines (24 loc) · 947 Bytes
/
SaveChat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Net;
using System.Net.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace ChangeFeedSignalR
{
public static class SaveChat
{
/// <summary>
/// This HttpTriggered function is called from the web client to save a message into Azure Cosmos DB
/// </summary>
[FunctionName("SaveChat")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]ChatMessage chatMessage,
[DocumentDB("chat", "lines", Id = "id", ConnectionStringSetting = "AzureCosmosDBConnectionString")] out dynamic document,
TraceWriter log)
{
document = new { id = Guid.NewGuid(), user = chatMessage.user, message = chatMessage.message };
return new HttpResponseMessage(HttpStatusCode.OK);
}
}
}