-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSignalRConfiguration.cs
28 lines (26 loc) · 1006 Bytes
/
SignalRConfiguration.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
27
28
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 cosmosdbtrigger
{
public static class SignalRConfiguration
{
private static AzureSignalR signalR = new AzureSignalR(Environment.GetEnvironmentVariable("AzureSignalRConnectionString"));
/// <summary>
/// This HttpTriggered function returns the SignalR configuration to the web client.
/// </summary>
[FunctionName("SignalRConfiguration")]
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequestMessage req, TraceWriter log)
{
return req.CreateResponse(HttpStatusCode.OK,
new
{
hubUrl = signalR.GetClientHubUrl("cosmicServerlessHub"),
accessToken = signalR.GenerateAccessToken("cosmicServerlessHub")
});
}
}
}