Ejemplo n.º 1
0
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, TraceWriter log)
        {
            log.Info("Negotiate trigger called.");
            var asr = new AzureSignalR(Environment.GetEnvironmentVariable("AzureSignalRConnectionString"));

            return(new OkObjectResult(JsonConvert.SerializeObject(asr.GetClientConnectionInfo("simplechat"))));
        }
Ejemplo n.º 2
0
        public VstsBuildStateMonitor(string endpoint, string accessKey, string hubName)
        {
            var signalR = new AzureSignalR($"Endpoint={endpoint};AccessKey={accessKey}");
            var hubUrl  = signalR.GetClientHubUrl(hubName);
            var token   = signalR.GenerateAccessToken(hubName);

            _Connection = new HubConnectionBuilder()
                          .WithUrl(hubUrl, options => {
                options.Headers = new Dictionary <string, string> {
                    { "Authorization", string.Format("bearer {0}", token) }
                };
            })
                          .Build();

            _Connection.On <VstsBuildStateChangeNotification>("StatusUpdate", (noticifation) =>
            {
                ProcessStateChangeNotification(noticifation);
            });
        }
Ejemplo n.º 3
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();

            var body = await req.Content.ReadAsStringAsync();

            var notification = JsonConvert.DeserializeObject <VstsBuildStateChangeNotification>(body);

            var endpoint  = config["SignalR:Endpoint"];
            var accessKey = config["SignalR:AccessKey"];

            var signalR = new AzureSignalR($"Endpoint={endpoint};AccessKey={accessKey}");

            var result = await signalR.SendAsync(config["SignalR:HubName"], "StatusUpdate", notification);

            return(req.CreateResponse(HttpStatusCode.OK));
        }