Skip to content

Commit de08845

Browse files
authored
Merge pull request #270884 from Y-Sindo/serverlesshub-csharp-isolated-worker
Add SignalR serverless hub for C# isolated process
2 parents 2ae58dc + 1dd8540 commit de08845

File tree

3 files changed

+163
-39
lines changed

3 files changed

+163
-39
lines changed

articles/azure-functions/functions-bindings-signalr-service-trigger.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.topic: reference
66
ms.devlang: csharp
77
# ms.devlang: csharp, javascript, python
88
ms.custom: devx-track-csharp, devx-track-extended-java, devx-track-js, devx-track-python
9-
ms.date: 03/12/2024
9+
ms.date: 04/02/2024
1010
ms.author: zityang
1111
zone_pivot_groups: programming-languages-set-functions-lang-workers
1212
---
@@ -25,7 +25,6 @@ For information on setup and configuration details, see the [overview](functions
2525

2626
::: zone pivot="programming-language-csharp"
2727

28-
2928
[!INCLUDE [functions-bindings-csharp-intro-with-csx](../../includes/functions-bindings-csharp-intro-with-csx.md)]
3029

3130
[!INCLUDE [functions-in-process-model-retirement-note](../../includes/functions-in-process-model-retirement-note.md)]
@@ -36,10 +35,12 @@ The following sample shows a C# function that receives a message event from clie
3635

3736
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/Extensions/SignalR/SignalRTriggerFunctions.cs" id="snippet_on_message":::
3837

38+
> [!IMPORTANT]
39+
> Class based model of SignalR Service bindings in C# isolated worker doesn't optimize how you write SignalR triggers due to the limitation of C# worker model. For more information about class based model, see [Class based model](../azure-signalr/signalr-concept-serverless-development-config.md#class-based-model).
3940
4041
# [In-process model](#tab/in-process)
4142

42-
SignalR Service trigger binding for C# has two programming models. Class based model and traditional model. Class based model provides a consistent SignalR server-side programming experience. Traditional model provides more flexibility and is similar to other function bindings.
43+
SignalR Service trigger binding for C# in-process model has two programming models. Class based model and traditional model. Class based model provides a consistent SignalR server-side programming experience. Traditional model provides more flexibility and is similar to other function bindings.
4344

4445
### With class-based model
4546

@@ -200,7 +201,7 @@ See the [Example section](#example) for complete examples.
200201

201202
### Payloads
202203

203-
The trigger input type is declared as either `InvocationContext` or a custom type. If you choose `InvocationContext` you get full access to the request content. For a custom type, the runtime tries to parse the JSON request body to set the object properties.
204+
The trigger input type is declared as either `InvocationContext` or a custom type. If you choose `InvocationContext`, you get full access to the request content. For a custom type, the runtime tries to parse the JSON request body to set the object properties.
204205

205206
### InvocationContext
206207

@@ -210,11 +211,11 @@ The trigger input type is declared as either `InvocationContext` or a custom typ
210211
|------------------------------|------------|
211212
|Arguments| Available for *messages* category. Contains *arguments* in [invocation message](https://github.com/dotnet/aspnetcore/blob/master/src/SignalR/docs/specs/HubProtocol.md#invocation-message-encoding)|
212213
|Error| Available for *disconnected* event. It can be Empty if the connection closed with no error, or it contains the error messages.|
213-
|Hub| The hub name which the message belongs to.|
214+
|Hub| The hub name that the message belongs to.|
214215
|Category| The category of the message.|
215216
|Event| The event of the message.|
216-
|ConnectionId| The connection ID of the client which sends the message.|
217-
|UserId| The user identity of the client which sends the message.|
217+
|ConnectionId| The connection ID of the client that sends the message.|
218+
|UserId| The user identity of the client that sends the message.|
218219
|Headers| The headers of the request.|
219220
|Query| The query of the request when clients connect to the service.|
220221
|Claims| The claims of the client.|
@@ -235,27 +236,27 @@ After you set `parameterNames`, the names you defined correspond to the argument
235236
[SignalRTrigger(parameterNames: new string[] {"arg1, arg2"})]
236237
```
237238

238-
Then, the `arg1` will contain the content of `message1`, and `arg2` will contain the content of `message2`.
239+
Then, the `arg1` contains the content of `message1`, and `arg2` contains the content of `message2`.
239240

240241
### `ParameterNames` considerations
241242

242243
For the parameter binding, the order matters. If you're using `ParameterNames`, the order in `ParameterNames` matches the order of the arguments you invoke in the client. If you're using attribute `[SignalRParameter]` in C#, the order of arguments in Azure Function methods matches the order of arguments in clients.
243244

244-
`ParameterNames` and attribute `[SignalRParameter]` **cannot** be used at the same time, or you will get an exception.
245+
`ParameterNames` and attribute `[SignalRParameter]` **cannot** be used at the same time, or you'll get an exception.
245246

246247
### SignalR Service integration
247248

248249
SignalR Service needs a URL to access Function App when you're using SignalR Service trigger binding. The URL should be configured in **Upstream Settings** on the SignalR Service side.
249250

250251
:::image type="content" source="../azure-signalr/media/concept-upstream/upstream-portal.png" alt-text="Upstream Portal":::
251252

252-
When using SignalR Service trigger, the URL can be simple and formatted as shown below:
253+
When using SignalR Service trigger, the URL can be simple and formatted as follows:
253254

254255
```http
255256
<Function_App_URL>/runtime/webhooks/signalr?code=<API_KEY>
256257
```
257258

258-
The `Function_App_URL` can be found on Function App's Overview page and The `API_KEY` is generated by Azure Function. You can get the `API_KEY` from `signalr_extension` in the **App keys** blade of Function App.
259+
The `Function_App_URL` can be found on Function App's Overview page and the `API_KEY` is generated by Azure Function. You can get the `API_KEY` from `signalr_extension` in the **App keys** blade of Function App.
259260
:::image type="content" source="media/functions-bindings-signalr-service/signalr-keys.png" alt-text="API key":::
260261

261262
If you want to use more than one Function App together with one SignalR Service, upstream can also support complex routing rules. Find more details at [Upstream settings](../azure-signalr/concept-upstream.md).

articles/azure-functions/functions-bindings-signalr-service.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure Functions SignalR Service bindings
33
description: Understand how to use SignalR Service bindings with Azure Functions.
44
ms.topic: reference
55
ms.custom: devx-track-extended-java, devx-track-js, devx-track-python
6-
ms.date: 03/04/2022
6+
ms.date: 04/02/2024
77
zone_pivot_groups: programming-languages-set-functions-lang-workers
88
---
99

@@ -15,13 +15,13 @@ This set of articles explains how to authenticate and send real-time messages to
1515
|---------|---------|
1616
| Handle messages from SignalR Service | [Trigger binding](./functions-bindings-signalr-service-trigger.md) |
1717
| Return the service endpoint URL and access token | [Input binding](./functions-bindings-signalr-service-input.md) |
18-
| Send SignalR Service messages |[Output binding](./functions-bindings-signalr-service-output.md) |
18+
| Send SignalR Service messages and manage groups |[Output binding](./functions-bindings-signalr-service-output.md) |
1919

2020
::: zone pivot="programming-language-csharp"
2121

2222
## Install extension
2323

24-
The extension NuGet package you install depends on the C# mode you're using in your function app:
24+
The extension NuGet package you install depends on the C# mode you're using in your function app:
2525

2626
# [Isolated worker model](#tab/isolated-process)
2727

@@ -39,18 +39,18 @@ Add the extension to your project by installing this [NuGet package].
3939

4040
---
4141

42-
::: zone-end
42+
::: zone-end
4343

44-
::: zone pivot="programming-language-javascript,programming-language-python,programming-language-powershell"
44+
::: zone pivot="programming-language-javascript,programming-language-python,programming-language-powershell"
4545

46-
## Install bundle
46+
## Install bundle
4747

4848
The SignalR Service extension is part of an [extension bundle], which is specified in your host.json project file. When you create a project that targets version 3.x or later, you should already have this bundle installed. To learn more, see [extension bundle].
4949

50-
::: zone-end
51-
::: zone pivot="programming-language-java"
50+
::: zone-end
51+
::: zone pivot="programming-language-java"
5252

53-
## Add dependency
53+
## Add dependency
5454

5555
To use the SignalR Service annotations in Java functions, you need to add a dependency to the *azure-functions-java-library-signalr* artifact (version 1.0 or higher) to your *pom.xml* file.
5656

@@ -61,7 +61,7 @@ To use the SignalR Service annotations in Java functions, you need to add a depe
6161
<version>1.0.0</version>
6262
</dependency>
6363
```
64-
::: zone-end
64+
::: zone-end
6565

6666
## Connection string settings
6767

0 commit comments

Comments
 (0)