You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-signalr/signalr-quickstart-azure-functions-csharp.md
+103-9Lines changed: 103 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,26 @@ ms.service: signalr
6
6
ms.devlang: csharp
7
7
ms.topic: quickstart
8
8
ms.custom: devx-track-csharp, mode-other
9
-
ms.date: 03/30/2022
9
+
ms.date: 12/28/2022
10
10
ms.author: lianwei
11
11
---
12
12
13
13
# Quickstart: Create an app showing GitHub star count with Azure Functions and SignalR Service via C#
14
14
15
15
In this article, you'll learn how to use SignalR Service and Azure Functions to build a serverless application with C# to broadcast messages to clients.
16
16
17
+
# [In-process](#tab/in-process)
18
+
17
19
> [!NOTE]
18
20
> You can get the code mentioned in this article from [GitHub](https://github.com/aspnet/AzureSignalR-samples/tree/main/samples/QuickStartServerless/csharp).
19
21
22
+
# [Isolated process](#tab/isolated-process)
23
+
24
+
> [!NOTE]
25
+
> You can get the code mentioned in this article from [GitHub](https://github.com/aspnet/AzureSignalR-samples/tree/main/samples/QuickStartServerless/csharp-isolated).
26
+
27
+
---
28
+
20
29
## Prerequisites
21
30
22
31
The following prerequisites are needed for this quickstart:
@@ -37,6 +46,8 @@ You'll need the Azure Functions Core Tools for this step.
37
46
1. Create an empty directory and change to the directory with the command line.
38
47
1. Initialize a new project.
39
48
49
+
# [In-process](#tab/in-process)
50
+
40
51
```bash
41
52
# Initialize a function project
42
53
func init --worker-runtime dotnet
@@ -45,8 +56,22 @@ You'll need the Azure Functions Core Tools for this step.
var result = await response.Content.ReadFromJsonAsync<GitResult>();
202
+
if (result != null)
203
+
{
204
+
StarCount = result.StarCount;
205
+
}
206
+
}
207
+
return new SignalRMessageAction("newMessage", new object[] { $"Current star count of https://github.com/Azure/azure-signalr is: {StarCount}" });
208
+
}
209
+
210
+
private class GitResult
211
+
{
212
+
[JsonPropertyName("stargazers_count")]
213
+
public int StarCount { get;set; }
214
+
}
215
+
}
216
+
```
217
+
218
+
---
219
+
126
220
The code in*Function.cs* has three functions:
127
221
- `GetHomePage` is used to get a website as client.
128
222
- `Negotiate` is used by the client to get an access token.
@@ -188,7 +282,7 @@ You'll need the Azure Functions Core Tools for this step.
188
282
func start
189
283
```
190
284
191
-
After the Azure function is running locally, open `http://localhost:7071/api/index` and you can see the current star count. If you star or unstar in the GitHub, you'll get a star count refreshing every few seconds.
285
+
After the Azure function is running locally, open `http://localhost:7071/api/index`, and you can see the current star count. If you star or unstar in the GitHub, you'll get a star count refreshing every few seconds.
192
286
193
287
> [!NOTE]
194
288
> SignalR binding needs Azure Storage, but you can use a local storage emulator when the functionis running locally.
0 commit comments