logger)
11 | {
12 | _logger = logger;
13 | }
14 |
15 | public void OnGet()
16 | {
17 |
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Error.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model ErrorModel
3 | @{
4 | ViewData["Title"] = "Error";
5 | }
6 |
7 | Error.
8 | An error occurred while processing your request.
9 |
10 | @if (Model.ShowRequestId)
11 | {
12 |
13 | Request ID: @Model.RequestId
14 |
15 | }
16 |
17 | Development Mode
18 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
27 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.RazorPages;
3 | using System.Diagnostics;
4 |
5 | namespace ClientInvocationSample.Pages
6 | {
7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8 | [IgnoreAntiforgeryToken]
9 | public class ErrorModel : PageModel
10 | {
11 | public string? RequestId { get; set; }
12 |
13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14 |
15 | private readonly ILogger _logger;
16 |
17 | public ErrorModel(ILogger logger)
18 | {
19 | _logger = logger;
20 | }
21 |
22 | public void OnGet()
23 | {
24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Index.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 |
18 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Index.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.RazorPages;
3 |
4 | namespace ClientInvocationSample.Pages
5 | {
6 | public class IndexModel : PageModel
7 | {
8 | private readonly ILogger _logger;
9 |
10 | public IndexModel(ILogger logger)
11 | {
12 | _logger = logger;
13 | }
14 |
15 | public void OnGet()
16 | {
17 |
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Privacy.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model PrivacyModel
3 | @{
4 | ViewData["Title"] = "Privacy Policy";
5 | }
6 | @ViewData["Title"]
7 |
8 | Use this page to detail your site's privacy policy.
9 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Privacy.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.RazorPages;
3 |
4 | namespace ClientInvocationSample.Pages
5 | {
6 | public class PrivacyModel : PageModel
7 | {
8 | private readonly ILogger _logger;
9 |
10 | public PrivacyModel(ILogger logger)
11 | {
12 | _logger = logger;
13 | }
14 |
15 | public void OnGet()
16 | {
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Shared/_Layout.cshtml.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | a {
11 | color: #0077cc;
12 | }
13 |
14 | .btn-primary {
15 | color: #fff;
16 | background-color: #1b6ec2;
17 | border-color: #1861ac;
18 | }
19 |
20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21 | color: #fff;
22 | background-color: #1b6ec2;
23 | border-color: #1861ac;
24 | }
25 |
26 | .border-top {
27 | border-top: 1px solid #e5e5e5;
28 | }
29 | .border-bottom {
30 | border-bottom: 1px solid #e5e5e5;
31 | }
32 |
33 | .box-shadow {
34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35 | }
36 |
37 | button.accept-policy {
38 | font-size: 1rem;
39 | line-height: inherit;
40 | }
41 |
42 | .footer {
43 | position: absolute;
44 | bottom: 0;
45 | width: 100%;
46 | white-space: nowrap;
47 | line-height: 60px;
48 | }
49 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/Shared/_ValidationScriptsPartial.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using ClientInvocationSample
2 | @namespace ClientInvocationSample.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Pages/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = (Context.Request.Path.Value == "/") ? "_Layout" : null;
3 | }
4 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Program.cs:
--------------------------------------------------------------------------------
1 | using ClientInvocationSample;
2 | using Microsoft.AspNetCore.SignalR;
3 |
4 | var builder = WebApplication.CreateBuilder(args);
5 |
6 | // Add services to the container.
7 | builder.Services.AddRazorPages();
8 | builder.Services.AddSignalR(o =>
9 | {
10 | o.MaximumParallelInvocationsPerClient = 2;
11 | }).AddAzureSignalR();
12 |
13 | var app = builder.Build();
14 |
15 | // Configure the HTTP request pipeline.
16 | if (!app.Environment.IsDevelopment())
17 | {
18 | app.UseExceptionHandler("/Error");
19 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
20 | app.UseHsts();
21 | }
22 |
23 | app.UseHttpsRedirection();
24 | app.UseStaticFiles();
25 |
26 | app.UseRouting();
27 |
28 | app.UseAuthorization();
29 |
30 | app.MapHub("/chat");
31 | app.MapRazorPages();
32 |
33 | app.MapGet("/get/{id}", async (string id, IHubContext hubContext) =>
34 | {
35 | return await hubContext.Clients.Client(id).InvokeAsync("GetMessage", default);
36 | });
37 |
38 | app.Run();
39 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:53383",
7 | "sslPort": 44380
8 | }
9 | },
10 | "profiles": {
11 | "ClientInvocationSample": {
12 | "commandName": "Project",
13 | "dotnetRunMessages": true,
14 | "launchBrowser": true,
15 | "applicationUrl": "https://localhost:7243;http://localhost:5243",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "Server1": {
21 | "commandName": "Project",
22 | "dotnetRunMessages": true,
23 | "launchBrowser": true,
24 | "applicationUrl": "https://localhost:7245;http://localhost:5245",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | },
29 | "IIS Express": {
30 | "commandName": "IISExpress",
31 | "launchBrowser": true,
32 | "environmentVariables": {
33 | "ASPNETCORE_ENVIRONMENT": "Development"
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | html {
2 | font-size: 14px;
3 | }
4 |
5 | @media (min-width: 768px) {
6 | html {
7 | font-size: 16px;
8 | }
9 | }
10 |
11 | html {
12 | position: relative;
13 | min-height: 100%;
14 | }
15 |
16 | body {
17 | margin-bottom: 60px;
18 | }
19 |
20 | iframe {
21 | height: 1024px;
22 | width: 100%;
23 | }
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ClientInvocationSample/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/ClientInvocationSample/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Hosting;
2 |
3 | namespace IsolatedModel_BidirectionChat
4 | {
5 | public class Program
6 | {
7 | public static void Main()
8 | {
9 | var host = new HostBuilder()
10 | .ConfigureFunctionsWorkerDefaults()
11 | .Build();
12 |
13 | host.Run();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | },
10 | "logLevel": {
11 | "default": "Debug"
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/chatroom-noauth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/chatroom-noauth.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/chatroom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/chatroom.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/cors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/cors.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/getkeys.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/getkeys.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/identity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/identity.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/key-vault-reference.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/key-vault-reference.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/system-assigned-identity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/system-assigned-identity.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/upstream-details-portal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/upstream-details-portal.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/imgs/upstream-portal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-BidirectionChat/imgs/upstream-portal.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-BidirectionChat/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AzureSignalRConnectionString": ""
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/NewConnection.cs:
--------------------------------------------------------------------------------
1 | namespace DotnetIsolated_ClassBased;
2 |
3 | public class NewConnection
4 | {
5 | public string ConnectionId { get; }
6 |
7 | public string Authentication { get; }
8 |
9 | public NewConnection(string connectionId, string auth)
10 | {
11 | ConnectionId = connectionId;
12 | Authentication = auth;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/NewMessage.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Functions.Worker;
2 |
3 | namespace DotnetIsolated_ClassBased;
4 | public class NewMessage
5 | {
6 | public string ConnectionId { get; }
7 | public string Sender { get; }
8 | public string Text { get; }
9 |
10 | public NewMessage(SignalRInvocationContext invocationContext, string message)
11 | {
12 | Sender = string.IsNullOrEmpty(invocationContext.UserId) ? string.Empty : invocationContext.UserId;
13 | ConnectionId = invocationContext.ConnectionId;
14 | Text = message;
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/Program.cs:
--------------------------------------------------------------------------------
1 | using DotnetIsolated_ClassBased;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Microsoft.Extensions.Hosting;
4 |
5 | var host = new HostBuilder()
6 | .ConfigureFunctionsWorkerDefaults(b => b.Services
7 | .AddServerlessHub())
8 | .Build();
9 |
10 | host.Run();
11 |
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/chatroom-noauth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/chatroom-noauth.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/chatroom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/chatroom.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/cors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/cors.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/getkeys.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/getkeys.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/identity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/identity.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/key-vault-reference.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/key-vault-reference.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/system-assigned-identity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/system-assigned-identity.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/upstream-details-portal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/upstream-details-portal.png
--------------------------------------------------------------------------------
/samples/DotnetIsolated-ClassBased/imgs/upstream-portal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/DotnetIsolated-ClassBased/imgs/upstream-portal.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/csharp/csharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | v4
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 | PreserveNewest
19 | Never
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/csharp/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0"
3 | }
--------------------------------------------------------------------------------
/samples/EventGridIntegration/csharp/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureSignalRConnectionString": "",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "AzureWebJobsStorage": "",
7 | "AZURE_STORAGE_CONNECTION_STRING": ""
8 | },
9 | "Host": {
10 | "LocalHttpPort": 7071,
11 | "CORS": "http://127.0.0.1:5500",
12 | "CORSCredentials": true
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | csx
4 | .vs
5 | edge
6 | Publish
7 |
8 | *.user
9 | *.suo
10 | *.cscfg
11 | *.Cache
12 | project.lock.json
13 |
14 | /packages
15 | /TestResults
16 |
17 | /tools/NuGet.exe
18 | /App_Data
19 | /secrets
20 | /data
21 | .secrets
22 | appsettings.json
23 | local.settings.json
24 |
25 | node_modules
26 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/OnConnection/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "eventGridTrigger",
7 | "name": "eventGridEvent",
8 | "direction": "in"
9 | },
10 | {
11 | "type": "signalR",
12 | "name": "sendToConnection",
13 | "hubName": "EventGridIntegrationSampleChat",
14 | "direction": "out"
15 | },
16 | {
17 | "type": "signalR",
18 | "name": "broadcast",
19 | "hubName": "EventGridIntegrationSampleChat",
20 | "direction": "out"
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/SendMessage/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "route": "messages",
10 | "methods": [
11 | "post"
12 | ]
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "res"
18 | },
19 | {
20 | "type": "signalR",
21 | "name": "$return",
22 | "hubName": "EventGridIntegrationSampleChat",
23 | "direction": "out"
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/SendMessage/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async function (context, req) {
2 | const message = req.body;
3 | message.sender = req.headers && req.headers['x-ms-client-principal-name'] || '';
4 |
5 | let recipientUserId = '';
6 | if (message.recipient) {
7 | recipientUserId = message.recipient;
8 | message.isPrivate = true;
9 | }
10 |
11 | return {
12 | 'userId': recipientUserId,
13 | 'target': 'newMessage',
14 | 'arguments': [ message ]
15 | };
16 | };
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 | **
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0"
3 | }
4 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureSignalRConnectionString": "",
5 | "WEBSITE_NODE_DEFAULT_VERSION": "10.14.1",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AzureWebJobsStorage": "",
8 | "AZURE_STORAGE_CONNECTION_STRING": ""
9 | },
10 | "Host": {
11 | "LocalHttpPort": 7071,
12 | "CORS": "http://127.0.0.1:5500",
13 | "CORSCredentials": true
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/negotiate/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req"
9 | },
10 | {
11 | "type": "http",
12 | "direction": "out",
13 | "name": "res"
14 | },
15 | {
16 | "type": "signalRConnectionInfo",
17 | "name": "connectionInfo",
18 | "userId": "",
19 | "hubName": "EventGridIntegrationSampleChat",
20 | "direction": "in"
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/negotiate/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async function (context, req, connectionInfo) {
2 | context.log('JavaScript HTTP trigger function processed a request.');
3 | context.res.body = connectionInfo;
4 | };
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "signalr-event-grid",
3 | "version": "1.0.0",
4 | "description": "Azure SignalR integrate with Event Grid",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/aspnet/AzureSignalR-samples.git"
12 | },
13 | "author": "chenyl",
14 | "license": "ISC",
15 | "bugs": {
16 | "url": "https://github.com/aspnet/AzureSignalR-samples/issues"
17 | },
18 | "homepage": "https://github.com/aspnet/AzureSignalR-samples#readme",
19 | "dependencies": {
20 | "azure-storage": "^2.10.7"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/javascript/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/add-subscription.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/add-subscription.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/authentication.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/authentication.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/overview-with-auth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/overview-with-auth.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/overview.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/signalr-event-grid-subscribe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/signalr-event-grid-subscribe.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/signalr-get-key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/signalr-get-key.png
--------------------------------------------------------------------------------
/samples/EventGridIntegration/media/signalr-serverless.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/EventGridIntegration/media/signalr-serverless.png
--------------------------------------------------------------------------------
/samples/FlightMap/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | .vs/
4 |
--------------------------------------------------------------------------------
/samples/FlightMap/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft. All rights reserved.
2 | # Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | FROM microsoft/dotnet:2.1-sdk-stretch AS build-env
5 | WORKDIR /app
6 |
7 | # copy csproj and restore as distinct layers
8 | COPY NuGet.config ./
9 | RUN mkdir FlightMap && cd FlightMap/
10 | COPY *.csproj ./
11 | RUN dotnet restore
12 |
13 | # copy everything else and build
14 | COPY ./ ./
15 | RUN dotnet publish -c Release -o out
16 |
17 | # build runtime image
18 | FROM microsoft/dotnet:2.1-aspnetcore-runtime
19 | WORKDIR /app
20 | COPY --from=build-env /app/out .
21 | ENTRYPOINT ["dotnet", "FlightMap.dll"]
22 |
--------------------------------------------------------------------------------
/samples/FlightMap/FlightMap.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | flightmap
5 | Microsoft.Azure.SignalR.Samples.FlightMap
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/FlightMap/Hub/FlightMapSampleHub.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore.SignalR;
5 | using System;
6 | using System.Threading.Tasks;
7 |
8 | namespace Microsoft.Azure.SignalR.Samples.FlightMap
9 | {
10 | public class FlightMapSampleHub : Hub
11 | {
12 | private IFlightControl control;
13 |
14 | public FlightMapSampleHub(IFlightControl ctrl)
15 | {
16 | control = ctrl;
17 | }
18 |
19 | public override Task OnConnectedAsync()
20 | {
21 | return Clients.All.SendAsync("updateVisitors", control.VisitorJoin());
22 | }
23 |
24 | public override Task OnDisconnectedAsync(Exception exception)
25 | {
26 | return Clients.All.SendAsync("updateVisitors", control.VisitorLeave());
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/FlightMap/IFlightControl.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Azure.SignalR.Samples.FlightMap
5 | {
6 | public interface IFlightControl {
7 | void Start();
8 |
9 | void Stop();
10 |
11 | void Restart();
12 |
13 | int VisitorJoin();
14 |
15 | int VisitorLeave();
16 |
17 | void SetSpeed(int speed);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/FlightMap/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/FlightMap/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore;
5 | using Microsoft.AspNetCore.Hosting;
6 |
7 | namespace Microsoft.Azure.SignalR.Samples.FlightMap
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateWebHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
17 | WebHost.CreateDefaultBuilder(args)
18 | .UseStartup();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/samples/FlightMap/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5000/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "FlightMap": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://localhost:5000/"
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/samples/FlightMap/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Debug"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Debug"
12 | }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/FlightMap/data/generate.js:
--------------------------------------------------------------------------------
1 | if (process.argv.length < 8) {
2 | console.log('node generate ');
3 | return;
4 | }
5 |
6 | var time = Number.parseInt(process.argv[2]),
7 | planeCount = Number.parseInt(process.argv[3]),
8 | top = Number.parseFloat(process.argv[4]),
9 | bottom = Number.parseFloat(process.argv[5]),
10 | left = Number.parseFloat(process.argv[6]),
11 | right = Number.parseFloat(process.argv[7]);
12 |
13 | var current = new Date().getTime();
14 | var rand = () => [top + (bottom - top) * Math.random(), left + (right - left) * Math.random()];
15 | var planes = Array(planeCount).fill().map((v, i) => ({
16 | icao: i.toString(),
17 | from: rand(),
18 | to: rand()
19 | }));
20 | var count = time * 60 / 5;
21 | var data = Array(count + 1).fill().map((v, i) => planes.map(p => ({
22 | Icao: p.icao,
23 | PosTime: current + 5000 * i,
24 | Lat: p.from[0] + (p.to[0] - p.from[0]) * i / count,
25 | Long: p.from[1] + (p.to[1] - p.from[1]) * i / count,
26 | })));
27 |
28 | console.log(JSON.stringify(data));
29 |
--------------------------------------------------------------------------------
/samples/FlightMap/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flightmap",
3 | "requires": true,
4 | "lockfileVersion": 1,
5 | "dependencies": {
6 | "@aspnet/signalr": {
7 | "version": "1.0.0",
8 | "resolved": "https://registry.npmjs.org/@aspnet/signalr/-/signalr-1.0.0.tgz",
9 | "integrity": "sha512-7fXNdSTnp2y7a3i7BnvBpQpDEoG71DNq1J/Caowr+3v/nzGivnJApRg40VgBp6FlyeJqoBEQO/QuDPE0kTpczg=="
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/samples/FlightMap/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flightmap",
3 | "private": true,
4 | "dependencies": {
5 | "@aspnet/signalr": "^1.0.0"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/css/global.css:
--------------------------------------------------------------------------------
1 | .full-screen-outer {
2 | position: absolute;
3 | width: 100%;
4 | bottom: 50px;
5 | top: 50px;
6 | }
7 |
8 | #overlay-canvas {
9 | width: 500px;
10 | height: 500px;
11 | }
12 |
13 | .full-height {
14 | height: 100%;
15 | }
16 |
17 | .logo-title-up {
18 | padding-bottom: 0;
19 | padding-top: 0;
20 | margin-bottom: -0.2rem;
21 | }
22 |
23 | .logo-title-down {
24 | font-size: 0.7rem;
25 | padding-top: 0;
26 | padding-bottom: 0;
27 | color: #a0a0a0;
28 | }
29 |
30 | #microsoft {
31 | color: #a0a0a0;
32 | }
33 |
34 | #microsoft-center {
35 | color: #a0a0a0;
36 | text-align: center;
37 | }
38 |
39 | .navbar {
40 | padding: 0;
41 | }
42 |
43 | .navbar-brand {
44 | padding: 0;
45 | margin: 0;
46 | }
47 |
48 | .nav-logo-img {
49 | width: 50px;
50 | }
51 |
52 | #counter {
53 | color: #c1c1c1;
54 | }
55 |
56 | #time {
57 | color: #c1c1c1;
58 | }
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/css/sticky-footer-navbar.css:
--------------------------------------------------------------------------------
1 | /* Sticky footer styles
2 | -------------------------------------------------- */
3 | html {
4 | position: relative;
5 | min-height: 100%;
6 | }
7 | body {
8 | /* Margin bottom by footer height */
9 | margin-bottom: 60px;
10 | }
11 | .footer {
12 | position: absolute;
13 | bottom: 0;
14 | width: 100%;
15 | /* Set the fixed height of the footer here */
16 | height: 50px;
17 | line-height: 50px; /* Vertically center the text there */
18 | background-color: #343a40;
19 | font-size: 0.8em;
20 | }
21 |
22 | #content{padding:20px 0}
23 |
24 | /* Custom page CSS
25 | -------------------------------------------------- */
26 | /* Not required for template or sticky footer method. */
27 |
28 | body > .container {
29 | padding: 60px 15px 0;
30 | }
31 |
32 | body > .container-fluid {
33 | padding: 60px 15px 0;
34 | }
35 |
36 | .footer > .container {
37 | padding-right: 15px;
38 | padding-left: 15px;
39 | }
40 |
41 | code {
42 | font-size: 80%;
43 | }
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/FlightMap/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/images/microsoft-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/FlightMap/wwwroot/images/microsoft-logo.png
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/images/plane-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/FlightMap/wwwroot/images/plane-white.png
--------------------------------------------------------------------------------
/samples/FlightMap/wwwroot/images/signalr-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/FlightMap/wwwroot/images/signalr-logo.png
--------------------------------------------------------------------------------
/samples/GitHubChat/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | .vs/
4 | **.csproj.user
5 |
--------------------------------------------------------------------------------
/samples/GitHubChat/Controllers/AuthController.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using AspNet.Security.OAuth.GitHub;
5 | using Microsoft.AspNetCore.Authentication;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace Microsoft.Azure.SignalR.Samples.ChatRoom
9 | {
10 | [Route("/")]
11 | public class AuthController : Controller
12 | {
13 | [HttpGet("login")]
14 | public IActionResult Login()
15 | {
16 | if (User.Identity == null || !User.Identity.IsAuthenticated)
17 | {
18 | return Challenge(GitHubAuthenticationDefaults.AuthenticationScheme);
19 | }
20 |
21 | HttpContext.Response.Cookies.Append("githubchat_username", User.Identity.Name ?? "");
22 | HttpContext.SignInAsync(User);
23 | return Redirect("/");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/GitHubChat/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
2 | WORKDIR /src/GitHubChat
3 |
4 | COPY ./. ./
5 | RUN dotnet restore && dotnet build
6 |
7 | ENTRYPOINT ["bash","-c", "dotnet run --GitHubClientId $GITHUB_CLIENT_ID --GitHubClientSecret $GITHUB_CLIENT_SECRET --urls http://0.0.0.0:80"]
--------------------------------------------------------------------------------
/samples/GitHubChat/GitHubChat.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | enable
5 | chatroom
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/GitHubChat/Hub/ChatSampleHub.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 | using Microsoft.AspNetCore.Authorization;
4 | using Microsoft.AspNetCore.SignalR;
5 |
6 | [Authorize]
7 | public class ChatSampleHub : Hub
8 | {
9 | public override Task OnConnectedAsync()
10 | {
11 | return Clients.All.SendAsync("broadcastMessage", "_SYSTEM_", $"{Context.User?.Identity?.Name} JOINED");
12 | }
13 |
14 | // Uncomment this line to only allow user in Microsoft to send message
15 | //[Authorize(Policy = "Microsoft_Only")]
16 | public Task BroadcastMessage(string message)
17 | {
18 | return Clients.All.SendAsync("broadcastMessage", Context.User?.Identity?.Name, message);
19 | }
20 |
21 | public Task Echo(string message)
22 | {
23 | var echoMessage = $"{message} (echo from server)";
24 | return Clients.Client(Context.ConnectionId).SendAsync("echo", Context.User?.Identity?.Name, echoMessage);
25 | }
26 | }
--------------------------------------------------------------------------------
/samples/GitHubChat/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5000/",
7 | "sslPort": 5001
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "GitHubChat": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://0.0.0.0:5000/;https://0.0.0.0:5001/;"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/GitHubChat/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Information"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Information"
12 | }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/GitHubChat/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/GitHubChat/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/Llama2/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.*~
3 | project.lock.json
4 | .DS_Store
5 | *.pyc
6 | nupkg/
7 |
8 | # Visual Studio Code
9 | .vscode/
10 |
11 | # Rider
12 | .idea/
13 |
14 | # Visual Studio
15 | .vs/
16 |
17 | # Fleet
18 | .fleet/
19 |
20 | # Code Rush
21 | .cr/
22 |
23 | # User-specific files
24 | *.suo
25 | *.user
26 | *.userosscache
27 | *.sln.docstates
28 |
29 | # Build results
30 | [Dd]ebug/
31 | [Dd]ebugPublic/
32 | [Rr]elease/
33 | [Rr]eleases/
34 | x64/
35 | x86/
36 | build/
37 | bld/
38 | [Bb]in/
39 | [Oo]bj/
40 | [Oo]ut/
41 | msbuild.log
42 | msbuild.err
43 | msbuild.wrn
44 |
45 | model/*
--------------------------------------------------------------------------------
/samples/Llama2/media/llama-chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/Llama2/media/llama-chat.png
--------------------------------------------------------------------------------
/samples/Llama2/model/placeholder:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/Llama2/model/placeholder
--------------------------------------------------------------------------------
/samples/Llama2/src/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | .vs/
4 | **.csproj.user
5 |
--------------------------------------------------------------------------------
/samples/Llama2/src/ChatRoom.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net7.0
4 | chatroom
5 | disable
6 | Microsoft.Azure.SignalR.Samples.ChatRoom
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/samples/Llama2/src/LLama/AsyncLock.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | public class AsyncLock
5 | {
6 | private readonly SemaphoreSlim _semaphore;
7 |
8 | public AsyncLock()
9 | {
10 | _semaphore = new SemaphoreSlim(1);
11 | }
12 |
13 | public Task WaitAsync()
14 | {
15 | return _semaphore.WaitAsync();
16 | }
17 |
18 | public void Release()
19 | {
20 | _semaphore.Release();
21 | }
22 | }
--------------------------------------------------------------------------------
/samples/Llama2/src/LLama/IModelService.cs:
--------------------------------------------------------------------------------
1 | using LLama.Abstractions;
2 | using System.Threading.Tasks;
3 |
4 | namespace LLama.Web.Services
5 | {
6 | ///
7 | /// Service for managing language Models
8 | ///
9 | public interface IModelService
10 | {
11 | ILLamaExecutor GetExecutor();
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/Llama2/src/LLama/LLamaOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace LLama.Web.Common
4 | {
5 | public class LLamaOptions
6 | {
7 | public ModelOptions Models { get; set; }
8 |
9 | public void Initialize()
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/samples/Llama2/src/ModelLoaderService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.Hosting;
4 |
5 | namespace LLama.Web.Services
6 | {
7 | public class ModelLoaderService : IHostedService
8 | {
9 | private readonly IModelService _modelService;
10 |
11 | public ModelLoaderService(IModelService modelService)
12 | {
13 | _modelService = modelService;
14 | }
15 |
16 | public async Task StartAsync(CancellationToken cancellationToken)
17 | {
18 | }
19 |
20 | public async Task StopAsync(CancellationToken cancellationToken)
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/samples/Llama2/src/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using LLama.Native;
5 | using Microsoft.AspNetCore;
6 | using Microsoft.AspNetCore.Hosting;
7 |
8 | namespace Microsoft.Azure.SignalR.Samples.ChatRoom
9 | {
10 | public class Program
11 | {
12 | public static void Main(string[] args)
13 | {
14 | NativeLibraryConfig.Default.WithLogs();
15 | CreateWebHostBuilder(args).Build().Run();
16 | }
17 |
18 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
19 | WebHost.CreateDefaultBuilder(args)
20 | .UseStartup();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/samples/Llama2/src/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "ChatRoom": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "applicationUrl": "http://0.0.0.0:8080/"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/Llama2/src/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Azure": {
3 | "SignalR": {
4 | "ConnectionString": ""
5 | }
6 | },
7 | "LLamaOptions": {
8 | "Models": {
9 | "Name": "LLama2-7b-Chat",
10 | "ModelPath": "",
11 | "ContextSize": 2048,
12 | "Threads": 4,
13 | "GpuLayerCount": 0
14 | }
15 | },
16 | "Logging": {
17 | "IncludeScopes": false,
18 | "Debug": {
19 | "LogLevel": {
20 | "Default": "Information"
21 | }
22 | },
23 | "Console": {
24 | "LogLevel": {
25 | "Default": "Information"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/Llama2/src/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/Llama2/src/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/Management/.gitignore:
--------------------------------------------------------------------------------
1 | *.sln
--------------------------------------------------------------------------------
/samples/Management/MessagePublisher/MessagePublisher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | ManagementSample
7 | Microsoft.Azure.SignalR.Samples.Management
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/Management/NegotiationServer/NegotiationServer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | InProcess
6 | ManagementSample
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/Management/NegotiationServer/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore;
5 | using Microsoft.AspNetCore.Hosting;
6 |
7 | namespace NegotiationServer
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateWebHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
17 | WebHost.CreateDefaultBuilder(args)
18 | .UseStartup();
19 | }
20 | }
--------------------------------------------------------------------------------
/samples/Management/NegotiationServer/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:12269",
8 | "sslPort": 44393
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "negotiate",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "NegotiationServer": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "negotiate",
24 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/samples/Management/SignalRClient/SignalRClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | Microsoft.Azure.SignalR.Samples.Management
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp-isolated/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Hosting;
2 |
3 | var host = new HostBuilder()
4 | .ConfigureFunctionsWorkerDefaults()
5 | .Build();
6 |
7 | host.Run();
8 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp-isolated/README.md:
--------------------------------------------------------------------------------
1 | # SignalR Service Serverless Quick Start (C#)
2 |
3 | In this sample, we demonstrate how to broadcast messages with SignalR Service and Azure Function in serverless.
4 |
5 | ## Prerequisites
6 |
7 | * [Azure Function Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
8 | * [.NET](https://dotnet.microsoft.com/download)
9 |
10 | ## Setup and run locally
11 |
12 | 1. Rename `local.settings.template.json` to `local.settings.json`
13 |
14 | 2. Install local Azure Storage emulator [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite) or update `AzureWebJobsStorage` setting to your storage account connection string.
15 |
16 | 3. Update `AzureSignalRConnectionString` setting to your SignalR Service connection string
17 |
18 | 2. In Azure Portal of your SignalR service, update Service Mode from Default to Serverless in Settings Panel.
19 |
20 | 3. Run `func start` to start Azure Function locally.
21 |
22 | 4. Visit `http://localhost:7071/api/index` and you can see the result.
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp-isolated/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 |
6 |
7 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp-isolated/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp-isolated/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AzureSignalRConnectionString": ""
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp/README.md:
--------------------------------------------------------------------------------
1 | # SignalR Service Serverless Quick Start (C#)
2 |
3 | In this sample, we demonstrate how to broadcast messages with SignalR Service and Azure Function in serverless.
4 |
5 | ## Prerequisites
6 |
7 | * [Azure Function Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
8 | * [.NET](https://dotnet.microsoft.com/download)
9 |
10 | ## Setup and run locally
11 |
12 | 1. Rename `local.settings.template.json` to `local.settings.json`
13 |
14 | 2. Install local Azure Storage emulator [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite) or update `AzureWebJobsStorage` setting to your storage account connection string.
15 |
16 | 3. Update `AzureSignalRConnectionString` setting to your SignalR Service connection string
17 |
18 | 2. In Azure Portal of your SignalR service, update Service Mode from Default to Serverless in Settings Panel.
19 |
20 | 3. Run `func start` to start Azure Function locally.
21 |
22 | 4. Visit `http://localhost:7071/api/index` and you can see the result.
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 |
6 |
7 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp/csharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | v4
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Always
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 | PreserveNewest
19 | Never
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingExcludedTypes": "Request",
6 | "samplingSettings": {
7 | "isEnabled": true
8 | }
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/csharp/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "AzureSignalRConnectionString": ""
7 | },
8 | "ConnectionStrings": {}
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/java/.gitignore:
--------------------------------------------------------------------------------
1 | # Build output
2 | target/
3 | *.class
4 |
5 | # Log file
6 | *.log
7 |
8 | # BlueJ files
9 | *.ctxt
10 |
11 | # Mobile Tools for Java (J2ME)
12 | .mtj.tmp/
13 |
14 | # Package Files #
15 | *.jar
16 | *.war
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
25 | # IDE
26 | .idea/
27 | *.iml
28 | .settings/
29 | .project
30 | .classpath
31 |
32 | # macOS
33 | .DS_Store
34 |
35 | # Azure Functions
36 | local.settings.json
37 | bin/
38 | obj/
39 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/java/README.md:
--------------------------------------------------------------------------------
1 | # SignalR Service Serverless Quick Start (Java)
2 |
3 | In this sample, we demonstrate how to broadcast messages with SignalR Service and Azure Function in serverless.
4 |
5 | ## Prerequisites
6 |
7 | * [Azure Function Core Tools](https://review.docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash&branch=pr-en-us-162554#v2)
8 | * [Java version 11](https://www.azul.com/downloads/zulu/)
9 |
10 | ## Setup and run locally
11 |
12 | 1. Rename `local.settings.template.json` to `local.settings.json` and update `AzureSignalRConnectionString` setting to your SignalR Service connection string.
13 |
14 | 1. Run the following command to start Azure Function locally.
15 |
16 | ```bash
17 | mvn clean package
18 | mvn azure-functions:run
19 | ```
20 |
21 | 1. Visit `http://localhost:7071/api/index` and you can see the result.
22 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/java/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureSignalRConnectionString": "",
6 | "FUNCTIONS_WORKER_RUNTIME": "java"
7 | },
8 | "ConnectionStrings": {}
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/java/src/main/resources/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 |
6 |
7 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | csx
4 | .vs
5 | edge
6 | Publish
7 |
8 | *.user
9 | *.suo
10 | *.cscfg
11 | *.Cache
12 | project.lock.json
13 |
14 | /packages
15 | /TestResults
16 |
17 | /tools/NuGet.exe
18 | /App_Data
19 | /secrets
20 | /data
21 | .secrets
22 | appsettings.json
23 | local.settings.json
24 |
25 | node_modules
26 | dist
27 |
28 | # Local python packages
29 | .python_packages/
30 |
31 | # Python Environments
32 | .env
33 | .venv
34 | env/
35 | venv/
36 | ENV/
37 | env.bak/
38 | venv.bak/
39 |
40 | # Byte-compiled / optimized / DLL files
41 | __pycache__/
42 | *.py[cod]
43 | *$py.class
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/README.md:
--------------------------------------------------------------------------------
1 | # SignalR Service Serverless Quick Start (JavaScript)
2 |
3 | In this sample, we demonstrate how to broadcast messages with SignalR Service and Azure Function in serverless.
4 |
5 | ## Prerequisites
6 |
7 | * [Azure Function Core Tools](https://review.docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash&branch=pr-en-us-162554#v2)
8 | * [Node.js](https://nodejs.org/en/download/)
9 |
10 | ## Setup and run locally
11 |
12 | 1. Rename `local.settings.template.json` to `local.settings.json` and update `AzureSignalRConnectionString` setting to your SignalR Service connection string.
13 |
14 | 1. Run `func start` to start Azure Function locally.
15 |
16 | 1. Visit `http://localhost:7071/api/index` and you can see the result.
17 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/broadcast/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "name": "myTimer",
5 | "type": "timerTrigger",
6 | "direction": "in",
7 | "schedule": "*/5 * * * * *"
8 | },
9 | {
10 | "type": "signalR",
11 | "name": "signalRMessages",
12 | "hubName": "serverless",
13 | "connectionStringSetting": "AzureSignalRConnectionString",
14 | "direction": "out"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/broadcast/readme.md:
--------------------------------------------------------------------------------
1 | # TimerTrigger - JavaScript
2 |
3 | The `TimerTrigger` makes it incredibly easy to have your functions executed on a schedule. This sample demonstrates a simple use case of calling your function every 5 minutes.
4 |
5 | ## How it works
6 |
7 | For a `TimerTrigger` to work, you provide a schedule in the form of a [cron expression](https://en.wikipedia.org/wiki/Cron#CRON_expression)(See the link for full details). A cron expression is a string with 6 separate expressions which represent a given schedule via patterns. The pattern we use to represent every 5 minutes is `0 */5 * * * *`. This, in plain text, means: "When seconds is equal to 0, minutes is divisible by 5, for any hour, day of the month, month, day of the week, or year".
8 |
9 | ## Learn more
10 |
11 | Documentation
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 |
6 |
7 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
13 | "version": "[2.*, 3.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/index/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "req",
8 | "methods": [
9 | "get",
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "res"
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/index/index.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs').promises
2 |
3 | module.exports = async function (context, req) {
4 | const path = context.executionContext.functionDirectory + '/../content/index.html'
5 | try {
6 | var data = await fs.readFile(path);
7 | context.res = {
8 | headers: {
9 | 'Content-Type': 'text/html'
10 | },
11 | body: data
12 | }
13 | context.done()
14 | } catch (error) {
15 | context.log.error(err);
16 | context.done(err);
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "FUNCTIONS_WORKER_RUNTIME": "node",
5 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
6 | "AzureSignalRConnectionString": ""
7 | },
8 | "ConnectionStrings": {}
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/negotiate/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "methods": [
9 | "post"
10 | ],
11 | "name": "req",
12 | "route": "negotiate"
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "res"
18 | },
19 | {
20 | "type": "signalRConnectionInfo",
21 | "name": "connectionInfo",
22 | "hubName": "serverless",
23 | "connectionStringSetting": "AzureSignalRConnectionString",
24 | "direction": "in"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/negotiate/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async function (context, req, connectionInfo) {
2 | context.res.body = connectionInfo;
3 | };
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v3-programming-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "version": "",
4 | "description": "",
5 | "scripts" : {
6 | "test": "echo \"No tests yet...\""
7 | },
8 | "author": ""
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
13 | "version": "[4.*, 5.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "node",
6 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
7 | "SIGNALR_CONNECTION_STRING": ""
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/media/screenshot-index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/QuickStartServerless/javascript/v4-programming-model/media/screenshot-index.png
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "javascript",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start:azurite": "azurite -s -l __azurite__",
7 | "start": "func start",
8 | "test": "echo \"No tests yet...\""
9 | },
10 | "dependencies": {
11 | "@azure/functions": "^4.0.0",
12 | "node-fetch": "2.7.0"
13 | },
14 | "devDependencies": {
15 | "azurite": "3.29.0",
16 | "azure-functions-core-tools": "^4.0.5611"
17 | },
18 | "main": "src/functions/*.js"
19 | }
20 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/src/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 | Instructions: Goto
GitHub repo and star the repository.
6 |
7 |
8 |
9 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/src/functions/index.js:
--------------------------------------------------------------------------------
1 | const { app } = require('@azure/functions');
2 | const fs = require('fs').promises;
3 | const path = require('path');
4 |
5 | app.http('index', {
6 | methods: ['GET', 'POST'],
7 | authLevel: 'anonymous',
8 | handler: async (request, context) => {
9 |
10 | try {
11 |
12 | context.log(`Http function processed request for url "${request.url}"`);
13 |
14 | const filePath = path.join(__dirname,'../content/index.html');
15 | const html = await fs.readFile(filePath);
16 |
17 | return {
18 | body: html,
19 | headers: {
20 | 'Content-Type': 'text/html'
21 | }
22 | };
23 |
24 | } catch (error) {
25 | context.log(error);
26 | return {
27 | status: 500,
28 | jsonBody: error
29 | }
30 | }
31 | }
32 | });
33 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/src/functions/negotiate.js:
--------------------------------------------------------------------------------
1 | const { app, input } = require('@azure/functions');
2 |
3 | const inputSignalR = input.generic({
4 | type: 'signalRConnectionInfo',
5 | name: 'connectionInfo',
6 | hubName: 'serverless',
7 | connectionStringSetting: 'SIGNALR_CONNECTION_STRING',
8 | });
9 |
10 | app.post('negotiate', {
11 | authLevel: 'anonymous',
12 | handler: (request, context) => {
13 | try {
14 | return { body: JSON.stringify(context.extraInputs.get(inputSignalR)) }
15 | } catch (error) {
16 | context.log(error);
17 | return {
18 | status: 500,
19 | jsonBody: error
20 | }
21 | }
22 | },
23 | route: 'negotiate',
24 | extraInputs: [inputSignalR],
25 | });
26 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/javascript/v4-programming-model/src/getStars.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 |
3 | const URL = "https://api.github.com/repos/azure/azure-signalr"
4 |
5 | async function getStars(currentEtag){
6 |
7 | console.log(`currentEtag: ${currentEtag}`);
8 | const headers = {
9 | 'If-None-Match': currentEtag
10 | };
11 |
12 | const response = await fetch(URL, { headers });
13 | if(response.ok){
14 |
15 | const etag = response.headers.get('etag');
16 | const { stargazers_count } = await response.json();
17 |
18 | console.log(`Current star count is: ${stargazers_count}`);
19 |
20 | return { etag, stars: stargazers_count };
21 | } else {
22 | console.log('Failed to fetch data: ' + response.status + ' ' + response.statusText);
23 | return { etag: currentEtag, stars: undefined };
24 | }
25 | }
26 |
27 | module.exports = getStars;
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | csx
4 | .vs
5 | edge
6 | Publish
7 |
8 | *.user
9 | *.suo
10 | *.cscfg
11 | *.Cache
12 | project.lock.json
13 |
14 | /packages
15 | /TestResults
16 |
17 | /tools/NuGet.exe
18 | /App_Data
19 | /secrets
20 | /data
21 | .secrets
22 | appsettings.json
23 | local.settings.json
24 |
25 | node_modules
26 | dist
27 |
28 | # Local python packages
29 | .python_packages/
30 |
31 | # Python Environments
32 | .env
33 | .venv
34 | env/
35 | venv/
36 | ENV/
37 | env.bak/
38 | venv.bak/
39 |
40 | # Byte-compiled / optimized / DLL files
41 | __pycache__/
42 | *.py[cod]
43 | *$py.class
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/README.md:
--------------------------------------------------------------------------------
1 | # SignalR Service Serverless Quick Start (Python)
2 |
3 | In this sample, we demonstrate how to broadcast messages with SignalR Service and Azure Function in serverless.
4 |
5 | ## Prerequisites
6 |
7 | * [Azure Function Core Tools](https://review.docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash&branch=pr-en-us-162554#v2)
8 | * [Python 3.6+](https://www.python.org/downloads/)
9 |
10 | ## Setup and run locally
11 |
12 | 1. Rename `local.settings.template.json` to `local.settings.json` and update `AzureSignalRConnectionString` setting to your SignalR Service connection string.
13 |
14 | 1. Run `func start` to start Azure Function locally.
15 |
16 | 1. Visit `http://localhost:7071/api/index` and you can see the result.
17 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/broadcast/__init__.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 |
4 | import azure.functions as func
5 |
6 | etag = ''
7 | start_count = 0
8 |
9 | def main(myTimer: func.TimerRequest, signalRMessages: func.Out[str]) -> None:
10 | global etag
11 | global start_count
12 | headers = {'User-Agent': 'serverless', 'If-None-Match': etag}
13 | res = requests.get('https://api.github.com/repos/azure/azure-signalr', headers=headers)
14 | if res.headers.get('ETag'):
15 | etag = res.headers.get('ETag')
16 |
17 | if res.status_code == 200:
18 | jres = res.json()
19 | start_count = jres['stargazers_count']
20 |
21 | signalRMessages.set(json.dumps({
22 | 'target': 'newMessage',
23 | 'arguments': [ 'Current star count of https://github.com/Azure/azure-signalr is: ' + str(start_count) ]
24 | }))
25 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/broadcast/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "name": "myTimer",
6 | "type": "timerTrigger",
7 | "direction": "in",
8 | "schedule": "*/5 * * * * *"
9 | },
10 | {
11 | "type": "signalR",
12 | "name": "signalRMessages",
13 | "hubName": "serverless",
14 | "connectionStringSetting": "AzureSignalRConnectionString",
15 | "direction": "out"
16 | }
17 | ]
18 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/content/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Azure SignalR Serverless Sample
5 |
6 |
7 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
13 | "version": "[2.*, 3.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/index/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | import azure.functions as func
4 |
5 |
6 | def main(req: func.HttpRequest) -> func.HttpResponse:
7 | f = open(os.path.dirname(os.path.realpath(__file__)) + '/../content/index.html')
8 | return func.HttpResponse(f.read(), mimetype='text/html')
9 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/index/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "authLevel": "function",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "methods": [
10 | "get",
11 | "post"
12 | ]
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "$return"
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/local.settings.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "FUNCTIONS_WORKER_RUNTIME": "python",
5 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
6 | "AzureSignalRConnectionString": ""
7 | },
8 | "ConnectionStrings": {}
9 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/negotiate/__init__.py:
--------------------------------------------------------------------------------
1 | import azure.functions as func
2 |
3 |
4 | def main(req: func.HttpRequest, connectionInfo) -> func.HttpResponse:
5 | return func.HttpResponse(connectionInfo)
6 |
7 |
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/negotiate/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "authLevel": "function",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "$return"
17 | },
18 | {
19 | "type": "signalRConnectionInfo",
20 | "name": "connectionInfo",
21 | "hubName": "serverless",
22 | "connectionStringSetting": "AzureSignalRConnectionString",
23 | "direction": "in"
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/samples/QuickStartServerless/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # Do not include azure-functions-worker as it may conflict with the Azure Functions platform
2 |
3 | azure-functions
4 | requests
--------------------------------------------------------------------------------
/samples/RealtimeSignIn/content/images/signalr-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/RealtimeSignIn/content/images/signalr-logo.png
--------------------------------------------------------------------------------
/samples/RealtimeSignIn/function/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0"
3 | }
--------------------------------------------------------------------------------
/samples/RealtimeSignIn/function/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "",
5 | "AzureWebJobsDashboard": ""
6 | }
7 | }
--------------------------------------------------------------------------------
/samples/RealtimeSignIn/function/signin/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurationSource": "attributes",
3 | "bindings": [
4 | {
5 | "type": "httpTrigger",
6 | "methods": [
7 | "get",
8 | "post"
9 | ],
10 | "authLevel": "anonymous",
11 | "name": "req"
12 | }
13 | ],
14 | "disabled": false,
15 | "scriptFile": "../RealtimeSignIn.dll",
16 | "entryPoint": "RealtimeSignIn.SignInFunction.Run"
17 | }
18 |
--------------------------------------------------------------------------------
/samples/RealtimeSignIn/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/RealtimeSignIn/screenshot.png
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | .vs/
4 | **.csproj.user
5 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2 | WORKDIR /src/AdvancedChatRoom
3 |
4 | COPY ./. ./
5 | RUN dotnet restore && dotnet build
6 | ENTRYPOINT ["bash", "-c", "dotnet run --ConnectionStrings:AzureStorage $STORAGE_CONN_STRING --urls http://0.0.0.0:80"]
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Images/AddAzureSignalRServiceDependency.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ReliableChatRoom/Images/AddAzureSignalRServiceDependency.PNG
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Images/AddConnectionString.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ReliableChatRoom/Images/AddConnectionString.PNG
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Images/AppConfiguration.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ReliableChatRoom/Images/AppConfiguration.PNG
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/MessageHandler/Message.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Azure.SignalR.Samples.ReliableChatRoom
7 | {
8 | public class Message : IComparable
9 | {
10 | public string SenderName { get; }
11 |
12 | public DateTime SendTime { get; }
13 |
14 | public string SequenceId { get; set; }
15 |
16 | public string MessageContent { get; set; }
17 |
18 | public string MessageStatus { get; set; }
19 |
20 | public Message(string senderName, DateTime sendTime, string messageContent, string messageStatus)
21 | {
22 | SenderName = senderName;
23 | SendTime = sendTime;
24 | MessageContent = messageContent;
25 | MessageStatus = messageStatus;
26 | }
27 |
28 | public int CompareTo(Message message)
29 | {
30 | return SequenceId.CompareTo(message.SequenceId);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore;
5 | using Microsoft.AspNetCore.Hosting;
6 |
7 | namespace Microsoft.Azure.SignalR.Samples.ReliableChatRoom
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateWebHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
17 | WebHost.CreateDefaultBuilder(args)
18 | .UseStartup();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5000/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "ChatRoom": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://0.0.0.0:5000/"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/ReliableChatRoom.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | reliablechatroom
5 | Microsoft.Azure.SignalR.Samples.ReliableChatRoom
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/ReliableChatRoom.sln.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | ForceIncluded
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/SessionHandler/AzureTableSessionStorage/SessionEntity.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.WindowsAzure.Storage.Table;
5 |
6 | namespace Microsoft.Azure.SignalR.Samples.ReliableChatRoom
7 | {
8 | public class SessionEntity : TableEntity
9 | {
10 | public string SessionId { get; set; }
11 |
12 | public SessionEntity() { }
13 |
14 | public SessionEntity(string pkey, string rkey)
15 | {
16 | PartitionKey = pkey;
17 | RowKey = rkey;
18 | }
19 |
20 | public SessionEntity(string pkey, string rkey, Session session)
21 | {
22 | PartitionKey = pkey;
23 | RowKey = rkey;
24 | SessionId = session.SessionId;
25 | }
26 |
27 | public Session ToSession()
28 | {
29 | return new Session(SessionId);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/SessionHandler/ISessionHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.Azure.SignalR.Samples.ReliableChatRoom
8 | {
9 | public interface ISessionHandler
10 | {
11 | ///
12 | /// Creates a new session or loads the existed session.
13 | ///
14 | ///
15 | ///
16 | /// The session instance
17 | Task GetOrCreateSessionAsync(string userName, string partnerName);
18 |
19 | ///
20 | /// Gets all related sessions of one user.
21 | ///
22 | ///
23 | /// A list of sessions
24 | Task[]> GetLatestSessionsAsync(string userName);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/SessionHandler/Session.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Azure.SignalR.Samples.ReliableChatRoom
5 | {
6 | public class Session
7 | {
8 | public string SessionId { get; }
9 |
10 | public Session(string sessionId)
11 | {
12 | SessionId = sessionId;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Debug"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Debug"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/ReliableChatRoom/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ReliableChatRoom/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/App.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Sorry, there's nothing at this address.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Data/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ServerSideBlazor.Data
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Data/WeatherForecastService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 |
5 | namespace ServerSideBlazor.Data
6 | {
7 | public class WeatherForecastService
8 | {
9 | private static readonly string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | public Task GetForecastAsync(DateTime startDate)
15 | {
16 | var rng = new Random();
17 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
18 | {
19 | Date = startDate.AddDays(index),
20 | TemperatureC = rng.Next(-20, 55),
21 | Summary = Summaries[rng.Next(Summaries.Length)]
22 | }).ToArray());
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Pages/Counter.razor:
--------------------------------------------------------------------------------
1 | @page "/counter"
2 |
3 | Counter
4 |
5 | Current count: @currentCount
6 |
7 | Click me
8 |
9 | @code {
10 | int currentCount = 0;
11 |
12 | void IncrementCount()
13 | {
14 | currentCount++;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Pages/Error.razor:
--------------------------------------------------------------------------------
1 | @page "/error"
2 |
3 |
4 | Error.
5 | An error occurred while processing your request.
6 |
7 | Development Mode
8 |
9 | Swapping to Development environment will display more detailed information about the error that occurred.
10 |
11 |
12 | The Development environment shouldn't be enabled for deployed applications.
13 | It can result in displaying sensitive information from exceptions to end users.
14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
15 | and restarting the app.
16 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 | Hello, world!
4 |
5 | Welcome to your new app.
6 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Pages/_Host.cshtml:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @namespace ServerSideBlazor.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
5 |
6 |
7 |
8 |
9 |
10 | ServerSideBlazor
11 |
12 |
13 |
14 |
15 |
16 |
17 | @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered))
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 | using Microsoft.AspNetCore;
10 | using Microsoft.AspNetCore.Hosting;
11 | using Microsoft.Extensions.Configuration;
12 | using Microsoft.Extensions.Hosting;
13 | using Microsoft.Extensions.Logging;
14 |
15 | namespace ServerSideBlazor
16 | {
17 | public class Program
18 | {
19 | public static void Main(string[] args)
20 | {
21 | CreateHostBuilder(args).Build().Run();
22 | }
23 |
24 | public static IHostBuilder CreateHostBuilder(string[] args) =>
25 | Host.CreateDefaultBuilder(args)
26 | .ConfigureWebHostDefaults(webBuilder =>
27 | {
28 | webBuilder.UseStartup();
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:41285",
7 | "sslPort": 44334
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "ServerSideBlazor": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/ServerSideBlazor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | ServerSideBlazor
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
6 |
7 |
8 |
11 |
12 |
13 | @Body
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using Microsoft.AspNetCore.Authorization
3 | @using Microsoft.AspNetCore.Components.Authorization
4 | @using Microsoft.AspNetCore.Components.Forms
5 | @using Microsoft.AspNetCore.Components.Routing
6 | @using Microsoft.AspNetCore.Components.Web
7 | @using Microsoft.JSInterop
8 | @using ServerSideBlazor
9 | @using ServerSideBlazor.Shared
10 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.eot
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.otf
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ServerSideBlazor/wwwroot/css/open-iconic/font/fonts/open-iconic.woff
--------------------------------------------------------------------------------
/samples/ServerSideBlazor/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/ServerSideBlazor/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/samples/Serverless/Serverless.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | serverless
7 | Microsoft.Azure.SignalR.Sample.Serverless
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | csx
4 | .vs
5 | edge
6 | Publish
7 |
8 | *.user
9 | *.suo
10 | *.cscfg
11 | *.Cache
12 | project.lock.json
13 |
14 | /packages
15 | /TestResults
16 |
17 | /tools/NuGet.exe
18 | /App_Data
19 | /secrets
20 | /data
21 | .secrets
22 | appsettings.json
23 | local.settings.json
24 |
25 | node_modules
26 | dist
27 |
28 | # Local python packages
29 | .python_packages/
30 |
31 | # Python Environments
32 | .env
33 | .venv
34 | env/
35 | venv/
36 | ENV/
37 | env.bak/
38 | venv.bak/
39 |
40 | # Byte-compiled / optimized / DLL files
41 | __pycache__/
42 | *.py[cod]
43 | *$py.class
44 |
45 | # Azurite artifacts
46 | __blobstorage__
47 | __queuestorage__
48 | __azurite_db*__.json
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/README.md:
--------------------------------------------------------------------------------
1 | # Tutorial: Azure SignalR Service authentication with Azure Functions
2 | The source code for doc: https://learn.microsoft.com/azure/azure-signalr/signalr-tutorial-authenticate-azure-functions .
3 |
4 | To run the code locally, please remember to remove the `userId` property of `signalRConnectionInfo` binding in _negotiate/function.json_, as without an identity provider, the user ID of the client is missing locally.
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
13 | "version": "[3.*, 4.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/index/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "anonymous",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "req",
8 | "methods": ["get", "post"]
9 | },
10 | {
11 | "type": "http",
12 | "direction": "out",
13 | "name": "res"
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/index/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 |
3 | module.exports = async function (context, req) {
4 | const fileContent = fs.readFileSync('content/index.html', 'utf8');
5 |
6 | context.res = {
7 | // status: 200, /* Defaults to 200 */
8 | body: fileContent,
9 | headers: {
10 | 'Content-Type': 'text/html'
11 | },
12 | };
13 | }
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/negotiate/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "methods": ["post"],
9 | "name": "req",
10 | "route": "negotiate"
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "res"
16 | },
17 | {
18 | "type": "signalRConnectionInfo",
19 | "name": "connectionInfo",
20 | "userId": "{headers.x-ms-client-principal-name}",
21 | "hubName": "default",
22 | "connectionStringSetting": "AzureSignalRConnectionString",
23 | "direction": "in"
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/negotiate/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async function (context, req, connectionInfo) {
2 | context.res.body = connectionInfo;
3 | };
4 |
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {},
10 | "devDependencies": {
11 | "azure-functions-core-tools": "^4.x"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/sendMessage/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "disabled": false,
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "route": "messages",
10 | "methods": ["post"]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "res"
16 | },
17 | {
18 | "type": "signalR",
19 | "name": "$return",
20 | "hubName": "default",
21 | "direction": "out"
22 | }
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v3-model/sendMessage/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async function (context, req) {
2 | const message = req.body;
3 | message.sender = req.headers && req.headers['x-ms-client-principal-name'] || '';
4 |
5 | let recipientUserId = '';
6 | if (message.recipient) {
7 | recipientUserId = message.recipient;
8 | message.isPrivate = true;
9 | }
10 |
11 | return {
12 | 'userId': recipientUserId,
13 | 'target': 'newMessage',
14 | 'arguments': [message]
15 | };
16 | };
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | local.settings.json
6 | test
7 | getting_started.md
8 | node_modules/@types/
9 | node_modules/azure-functions-core-tools/
10 | node_modules/typescript/
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | csx
4 | .vs
5 | edge
6 | Publish
7 |
8 | *.user
9 | *.suo
10 | *.cscfg
11 | *.Cache
12 | project.lock.json
13 |
14 | /packages
15 | /TestResults
16 |
17 | /tools/NuGet.exe
18 | /App_Data
19 | /secrets
20 | /data
21 | .secrets
22 | appsettings.json
23 | local.settings.json
24 |
25 | node_modules
26 | dist
27 |
28 | # Local python packages
29 | .python_packages/
30 |
31 | # Python Environments
32 | .env
33 | .venv
34 | env/
35 | venv/
36 | ENV/
37 | env.bak/
38 | venv.bak/
39 |
40 | # Byte-compiled / optimized / DLL files
41 | __pycache__/
42 | *.py[cod]
43 | *$py.class
44 |
45 | # Azurite artifacts
46 | __blobstorage__
47 | __queuestorage__
48 | __azurite_db*__.json
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/README.md:
--------------------------------------------------------------------------------
1 | # Tutorial: Azure SignalR Service authentication with Azure Functions
2 | The source code for doc: https://learn.microsoft.com/azure/azure-signalr/signalr-tutorial-authenticate-azure-functions .
3 |
4 | To run the code locally, please remember to remove the `userId` property of `inputSignalR` binding in _src/negotiate.js_, as without an identity provider, the user ID of the client is missing locally.
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
13 | "version": "[4.*, 5.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "src/functions/*.js",
6 | "scripts": {
7 | "start": "func start",
8 | "test": "echo \"No tests yet...\""
9 | },
10 | "dependencies": {
11 | "@azure/functions": "^4.0.0"
12 | },
13 | "devDependencies": {
14 | "azure-functions-core-tools": "^4.x"
15 | }
16 | }
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/src/functions/index.js:
--------------------------------------------------------------------------------
1 | const { app } = require('@azure/functions');
2 | const { readFile } = require('fs/promises');
3 |
4 | app.http('index', {
5 | methods: ['GET'],
6 | authLevel: 'anonymous',
7 | handler: async (context) => {
8 | const content = await readFile('index.html', 'utf8', (err, data) => {
9 | if (err) {
10 | context.err(err)
11 | return
12 | }
13 | });
14 |
15 | return {
16 | status: 200,
17 | headers: {
18 | 'Content-Type': 'text/html'
19 | },
20 | body: content,
21 | };
22 | }
23 | });
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/src/functions/negotiate.js:
--------------------------------------------------------------------------------
1 | const { app, input } = require('@azure/functions');
2 |
3 | const inputSignalR = input.generic({
4 | type: 'signalRConnectionInfo',
5 | name: 'connectionInfo',
6 | hubName: 'default',
7 | connectionStringSetting: 'AzureSignalRConnectionString',
8 | userId: '{headers.x-ms-client-principal-name}' // remove this line if run locally
9 | });
10 |
11 | app.post('negotiate', {
12 | authLevel: 'anonymous',
13 | handler: (request, context) => {
14 | return { body: JSON.stringify(context.extraInputs.get(inputSignalR)) }
15 | },
16 | route: 'negotiate',
17 | extraInputs: [inputSignalR],
18 | });
--------------------------------------------------------------------------------
/samples/ServerlessChatWithAuth/v4-model/src/functions/sendMessage.js:
--------------------------------------------------------------------------------
1 | const { app, output } = require('@azure/functions');
2 |
3 | const signalR = output.generic({
4 | type: 'signalR',
5 | name: 'signalR',
6 | hubName: 'default',
7 | connectionStringSetting: 'AzureSignalRConnectionString',
8 | });
9 |
10 | app.http('messages', {
11 | methods: ['POST'],
12 | authLevel: 'anonymous',
13 | extraOutputs: [signalR],
14 | handler: async (request, context) => {
15 | const message = await request.json();
16 | message.sender = request.headers && request.headers.get('x-ms-client-principal-name') || '';
17 |
18 | let recipientUserId = '';
19 | if (message.recipient) {
20 | recipientUserId = message.recipient;
21 | message.isPrivate = true;
22 | }
23 | context.extraOutputs.set(signalR,
24 | {
25 | 'userId': recipientUserId,
26 | 'target': 'newMessage',
27 | 'arguments': [message]
28 | });
29 | }
30 | });
31 |
--------------------------------------------------------------------------------
/samples/SimpleEcho/Client.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using Microsoft.AspNetCore.SignalR.Client;
8 |
9 | namespace Microsoft.Azure.SignalR.Samples.SimpleEcho
10 | {
11 | public class Client
12 | {
13 | private const string message = "Hello!";
14 | private readonly TaskCompletionSource resp = new TaskCompletionSource();
15 |
16 | public async Task StartAsync(CancellationToken cancellationToken = default)
17 | {
18 | cancellationToken.Register(() => resp.TrySetCanceled());
19 | var connection = new HubConnectionBuilder().WithUrl("http://localhost:5000/echo").Build();
20 | connection.On("echo", _resp => resp.TrySetResult(_resp));
21 | await connection.StartAsync(cancellationToken);
22 | await connection.InvokeAsync("echo", message, cancellationToken);
23 | Console.WriteLine(await resp.Task);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/SimpleEcho/EchoSampleHub.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore.SignalR;
5 |
6 | namespace Microsoft.Azure.SignalR.Samples.SimpleEcho
7 | {
8 | public class EchoSampleHub : Hub
9 | {
10 | public void Echo(string message)
11 | {
12 | Clients.Client(Context.ConnectionId).SendAsync("echo", message);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/SimpleEcho/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5000",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "SimpleEcho": {
12 | "commandName": "Project",
13 | "environmentVariables": {
14 | "ASPNETCORE_ENVIRONMENT": "Development"
15 | },
16 | "applicationUrl": "http://localhost:5000"
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/samples/SimpleEcho/README.md:
--------------------------------------------------------------------------------
1 | # Azure SignalR Service Simple Echo
2 |
3 | This is the simplest sample that shows how to send a message back and forth between the client and the server through Azure SignalR Service. This sample can be also used as the connectivity check tool.
4 |
5 | ## Prerequisites
6 | * Install .NET Core SDK
7 | * Provision an Azure SignalR Service instance
8 |
9 | Set the connection string in the [Secret Manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets#secret-manager) tool for .NET Core, and run this app.
10 |
11 | ```
12 | dotnet restore
13 | dotnet user-secrets set Azure:SignalR:ConnectionString ""
14 | dotnet run
15 | ```
16 |
17 | After running, you will see that the web server starts, makes connections to the Azure SignalR Service instance and creates an endpoint at `http://localhost:5000/echo`. Then a client will be launched and sends a hello message to it. If everything goes well you will see `Hello!` printed on the screen.
--------------------------------------------------------------------------------
/samples/SimpleEcho/SimpleEcho.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | 2da0d60d-9962-455e-97af-f0d2668c4ea1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/SimpleEcho/Startup.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace Microsoft.Azure.SignalR.Samples.SimpleEcho
9 | {
10 | public class Startup
11 | {
12 | public void ConfigureServices(IServiceCollection services)
13 | {
14 | services.AddMvc();
15 | services.AddSignalR().AddAzureSignalR();
16 | }
17 |
18 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
19 | {
20 | app.UseRouting();
21 | app.UseEndpoints(e =>
22 | {
23 | e.MapHub("/echo");
24 | });
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/samples/SimpleEcho/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "Debug": {
4 | "LogLevel": {
5 | "Default": "Information"
6 | }
7 | },
8 | "Console": {
9 | "LogLevel": {
10 | "Default": "Information"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/Whiteboard/MCPServer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "signalrmcp",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [],
9 | "author": "",
10 | "license": "ISC",
11 | "description": "",
12 | "type": "module",
13 | "dependencies": {
14 | "@microsoft/signalr": "^8.0.7",
15 | "@modelcontextprotocol/sdk": "^1.9.0",
16 | "dotenv": "^16.4.7"
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/Whiteboard/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Azure.SignalR.Samples.Whiteboard;
7 |
8 | var builder = WebApplication.CreateBuilder(args);
9 | builder.Services.AddSingleton();
10 | builder.Services.AddMvc();
11 | builder.Services.AddSignalR().AddAzureSignalR();
12 |
13 | var app = builder.Build();
14 | app.UseRouting();
15 | app.UseFileServer();
16 | app.MapControllers();
17 | app.MapHub("/draw");
18 |
19 | app.Run();
--------------------------------------------------------------------------------
/samples/Whiteboard/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5000/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "Whiteboard": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://localhost:5000/"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/Whiteboard/Whiteboard.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0
4 | whiteboard
5 | Microsoft.Azure.SignalR.Samples.Whiteboard
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/Whiteboard/Whiteboard.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.5.2.0
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Whiteboard", "Whiteboard.csproj", "{E4CDAD0A-E491-036F-B3BE-BDF81466BF12}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Any CPU = Debug|Any CPU
10 | Release|Any CPU = Release|Any CPU
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {E4CDAD0A-E491-036F-B3BE-BDF81466BF12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14 | {E4CDAD0A-E491-036F-B3BE-BDF81466BF12}.Debug|Any CPU.Build.0 = Debug|Any CPU
15 | {E4CDAD0A-E491-036F-B3BE-BDF81466BF12}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 | {E4CDAD0A-E491-036F-B3BE-BDF81466BF12}.Release|Any CPU.Build.0 = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(SolutionProperties) = preSolution
19 | HideSolutionNode = FALSE
20 | EndGlobalSection
21 | GlobalSection(ExtensibilityGlobals) = postSolution
22 | SolutionGuid = {1E3E8FF2-65C4-40E1-A734-AA964A438553}
23 | EndGlobalSection
24 | EndGlobal
25 |
--------------------------------------------------------------------------------
/samples/Whiteboard/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Warning"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Warning"
12 | }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/Whiteboard/mcp.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/Whiteboard/mcp.gif
--------------------------------------------------------------------------------
/samples/Whiteboard/wwwroot/images/signalr-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AzureSignalR-samples/7c051c1298a2a28914571ab8695d2711308d3fa0/samples/Whiteboard/wwwroot/images/signalr-logo.png
--------------------------------------------------------------------------------