From 80b4837817166a432214283b95c051e85a191be1 Mon Sep 17 00:00:00 2001 From: "Liangying.Wei" Date: Tue, 8 Sep 2020 10:05:39 +0800 Subject: [PATCH 1/2] simply the steps (#127) --- samples/bidirectional-chat/README.md | 11 ++--------- samples/bidirectional-chat/csharp/Function.cs | 11 +++++++++++ .../{ => csharp}/content/index.html | 4 ++-- samples/bidirectional-chat/csharp/extensions.csproj | 3 +++ .../csharp/local.settings.sample.json | 4 +--- 5 files changed, 19 insertions(+), 14 deletions(-) rename samples/bidirectional-chat/{ => csharp}/content/index.html (98%) diff --git a/samples/bidirectional-chat/README.md b/samples/bidirectional-chat/README.md index c21e0e3..4ebbabd 100644 --- a/samples/bidirectional-chat/README.md +++ b/samples/bidirectional-chat/README.md @@ -103,14 +103,7 @@ It's a quick try of this sample. You will create an Azure SignalR Service and an 5. Click **Save** to persist the CORS settings. ![CORS](cors.png) -2. Install [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) for your VS Code, that can serve web pages locally -3. Open `bidirectional-chat/content/index.html` and edit base url +2. `/api/index` hosts the web page for the demo - ```js - window.apiBaseUrl = ''; - ``` - -4. With **index.html** open, start Live Server by opening the VS Code command palette (**F1**) and selecting **Live Server: Open with Live Server**. Live Server will open the application in a browser. - -5. Try send messages by entering them into the main chat box. +3. Try send messages by entering them into the main chat box. ![Chatroom](chatroom.png) diff --git a/samples/bidirectional-chat/csharp/Function.cs b/samples/bidirectional-chat/csharp/Function.cs index 1095b08..afb230c 100644 --- a/samples/bidirectional-chat/csharp/Function.cs +++ b/samples/bidirectional-chat/csharp/Function.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Azure.WebJobs.Extensions.SignalRService; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Mvc; namespace FunctionApp { @@ -15,6 +16,16 @@ namespace FunctionApp private const string NewMessageTarget = "newMessage"; private const string NewConnectionTarget = "newConnection"; + [FunctionName("index")] + public IActionResult GetHomePage([HttpTrigger(AuthorizationLevel.Anonymous)]HttpRequest req) + { + return new ContentResult + { + Content = File.ReadAllText("content/index.html"), + ContentType = "text/html", + }; + } + [FunctionName("negotiate")] public SignalRConnectionInfo Negotiate([HttpTrigger(AuthorizationLevel.Anonymous)]HttpRequest req) { diff --git a/samples/bidirectional-chat/content/index.html b/samples/bidirectional-chat/csharp/content/index.html similarity index 98% rename from samples/bidirectional-chat/content/index.html rename to samples/bidirectional-chat/csharp/content/index.html index 53f0274..b3eac2c 100644 --- a/samples/bidirectional-chat/content/index.html +++ b/samples/bidirectional-chat/csharp/content/index.html @@ -4,7 +4,7 @@ Serverless Chat