Skip to content

Commit 5281bfa

Browse files
committed
update
1 parent 86eaeae commit 5281bfa

4 files changed

+68
-65
lines changed

articles/azure-signalr/signalr-quickstart-azure-functions-csharp.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ You'll need the Azure Functions Core Tools for this step.
260260
</ItemGroup>
261261
```
262262
263+
1. Azure Functions requires a storage account to work. You can install and run the [Azure Storage Emulator](../storage/common/storage-use-azurite.md). **Or** you can update the setting to use your real storage account with the following command:
264+
```bash
265+
func settings add AzureWebJobsStorage "<storage-connection-string>"
266+
```
267+
263268
1. It's almost done now. The last step is to set a connection string of the SignalR Service to Azure Function settings.
264269
265270
1. Confirm the SignalR Service instance was successfully created by searching for its name in the search box at the top of the portal. Select the instance to open it.
@@ -284,9 +289,6 @@ You'll need the Azure Functions Core Tools for this step.
284289
285290
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.
286291
287-
> [!NOTE]
288-
> SignalR binding needs Azure Storage, but you can use a local storage emulator when the function is running locally.
289-
> If you got the error `There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid.` You need to download and enable [Storage Emulator](../storage/common/storage-use-emulator.md)
290292
291293
[!INCLUDE [Cleanup](includes/signalr-quickstart-cleanup.md)]
292294

articles/azure-signalr/signalr-quickstart-azure-functions-java.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In this article, you'll use Azure SignalR Service, Azure Functions, and Java to
2222
- A code editor, such as [Visual Studio Code](https://code.visualstudio.com/)
2323
- An Azure account with an active subscription. If you don't already have an account, [create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
2424
- [Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing). Used to run Azure Function apps locally.
25-
25+
2626
- The required SignalR Service bindings in Java are only supported in Azure Function Core Tools version 2.4.419 (host version 2.0.12332) or above.
2727
- To install extensions, Azure Functions Core Tools requires the [.NET Core SDK](https://dotnet.microsoft.com/download) installed. However, no knowledge of .NET is required to build Java Azure Function apps.
2828

@@ -52,13 +52,13 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
5252
| **groupId** | `com.signalr` | A value that uniquely identifies your project across all projects, following the [package naming rules](https://docs.oracle.com/javase/specs/jls/se6/html/packages.html#7.7) for Java. |
5353
| **artifactId** | `java` | A value that is the name of the jar, without a version number. |
5454
| **version** | `1.0-SNAPSHOT` | Choose the default value. |
55-
| **package** | `com.signalr` | A value that is the Java package for the generated function code. Use the default. |
55+
| **package** | `com.signalr` | A value that is the Java package for the generated function code. Use the default. |
5656

5757
1. Go to the folder `src/main/java/com/signalr` and copy the following code to *Function.java*:
5858

5959
```java
6060
package com.signalr;
61-
61+
6262
import com.google.gson.Gson;
6363
import com.microsoft.azure.functions.ExecutionContext;
6464
import com.microsoft.azure.functions.HttpMethod;
@@ -71,10 +71,10 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
7171
import com.microsoft.azure.functions.annotation.TimerTrigger;
7272
import com.microsoft.azure.functions.signalr.*;
7373
import com.microsoft.azure.functions.signalr.annotation.*;
74-
74+
7575
import org.apache.commons.io.IOUtils;
76-
77-
76+
77+
7878
import java.io.IOException;
7979
import java.io.InputStream;
8080
import java.net.URI;
@@ -84,24 +84,24 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
8484
import java.net.http.HttpResponse.BodyHandlers;
8585
import java.nio.charset.StandardCharsets;
8686
import java.util.Optional;
87-
87+
8888
public class Function {
8989
private static String Etag = "";
9090
private static String StarCount;
91-
91+
9292
@FunctionName("index")
9393
public HttpResponseMessage run(
9494
@HttpTrigger(
9595
name = "req",
9696
methods = {HttpMethod.GET},
9797
authLevel = AuthorizationLevel.ANONYMOUS)HttpRequestMessage<Optional<String>> request,
9898
final ExecutionContext context) throws IOException {
99-
99+
100100
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("content/index.html");
101101
String text = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
102102
return request.createResponseBuilder(HttpStatus.OK).header("Content-Type", "text/html").body(text).build();
103103
}
104-
104+
105105
@FunctionName("negotiate")
106106
public SignalRConnectionInfo negotiate(
107107
@HttpTrigger(
@@ -111,10 +111,10 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
111111
@SignalRConnectionInfoInput(
112112
name = "connectionInfo",
113113
hubName = "serverless") SignalRConnectionInfo connectionInfo) {
114-
114+
115115
return connectionInfo;
116116
}
117-
117+
118118
@FunctionName("broadcast")
119119
@SignalROutput(name = "$return", hubName = "serverless")
120120
public SignalRMessage broadcast(
@@ -132,10 +132,10 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
132132
GitResult result = gson.fromJson(res.body(), GitResult.class);
133133
StarCount = result.stargazers_count;
134134
}
135-
135+
136136
return new SignalRMessage("newMessage", "Current start count of https://github.com/Azure/azure-signalr is:".concat(StarCount));
137137
}
138-
138+
139139
class GitResult {
140140
public String stargazers_count;
141141
}
@@ -169,7 +169,7 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
169169
| | - main
170170
| | | - java
171171
| | | | - com
172-
| | | | | - signalr
172+
| | | | | - signalr
173173
| | | | | | - Function.java
174174
| | | - resources
175175
| | | | - content
@@ -183,7 +183,7 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
183183
184184
```html
185185
<html>
186-
186+
187187
<body>
188188
<h1>Azure SignalR Serverless Sample</h1>
189189
<div id="messages"></div>
@@ -198,15 +198,17 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
198198
connection.on('newMessage', (message) => {
199199
document.getElementById("messages").innerHTML = message;
200200
});
201-
201+
202202
connection.start()
203203
.catch(console.error);
204204
</script>
205205
</body>
206-
206+
207207
</html>
208208
```
209209
210+
1. Azure Functions requires a storage account to work. You can install and run the [Azure Storage Emulator](../storage/common/storage-use-azurite.md).
211+
210212
1. You're almost done now. The last step is to set a connection string of the SignalR Service to Azure Function settings.
211213
212214
1. Search for the Azure SignalR instance you deployed earlier using the **Search** box in Azure portal. Select the instance to open it.
@@ -234,10 +236,6 @@ Make sure you have Azure Function Core Tools, Java (version 11 in the sample), a
234236
235237
After Azure Function is running locally, go to `http://localhost:7071/api/index` and you'll see the current star count. If you star or "unstar" in the GitHub, you'll get a star count refreshing every few seconds.
236238
237-
> [!NOTE]
238-
> SignalR binding needs Azure Storage, but you can use local storage emulator when the Function is running locally.
239-
> If you got some error like `There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid.` You need to download and enable [Storage Emulator](../storage/common/storage-use-emulator.md)
240-
241239
[!INCLUDE [Cleanup](includes/signalr-quickstart-cleanup.md)]
242240
243241
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qsjava).

articles/azure-signalr/signalr-quickstart-azure-functions-javascript.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Make sure you have Azure Functions Core Tools installed.
7878
7979
```javascript
8080
var fs = require('fs').promises
81-
81+
8282
module.exports = async function (context, req) {
8383
const path = context.executionContext.functionDirectory + '/../content/index.html'
8484
try {
@@ -134,15 +134,15 @@ Make sure you have Azure Functions Core Tools installed.
134134
]
135135
}
136136
```
137-
137+
138138
3. Create a `broadcast` function to broadcast messages to all clients. In the sample, we use a time trigger to broadcast messages periodically.
139-
139+
140140
```bash
141141
func new -n broadcast -t TimerTrigger
142142
```
143-
143+
144144
Open *broadcast/function.json* and copy the following code:
145-
145+
146146
```json
147147
{
148148
"bindings": [
@@ -162,15 +162,15 @@ Make sure you have Azure Functions Core Tools installed.
162162
]
163163
}
164164
```
165-
165+
166166
Open *broadcast/index.js* and copy the following code:
167-
167+
168168
```javascript
169169
var https = require('https');
170-
170+
171171
var etag = '';
172172
var star = 0;
173-
173+
174174
module.exports = function (context) {
175175
var req = https.request("https://api.github.com/repos/azure/azure-signalr", {
176176
method: 'GET',
@@ -179,9 +179,9 @@ Make sure you have Azure Functions Core Tools installed.
179179
if (res.headers['etag']) {
180180
etag = res.headers['etag']
181181
}
182-
182+
183183
var body = "";
184-
184+
185185
res.on('data', data => {
186186
body += data;
187187
});
@@ -190,7 +190,7 @@ Make sure you have Azure Functions Core Tools installed.
190190
var jbody = JSON.parse(body);
191191
star = jbody['stargazers_count'];
192192
}
193-
193+
194194
context.bindings.signalRMessages = [{
195195
"target": "newMessage",
196196
"arguments": [ `Current star count of https://github.com/Azure/azure-signalr is: ${star}` ]
@@ -213,7 +213,7 @@ Make sure you have Azure Functions Core Tools installed.
213213
214214
```html
215215
<html>
216-
216+
217217
<body>
218218
<h1>Azure SignalR Serverless Sample</h1>
219219
<div id="messages"></div>
@@ -228,31 +228,36 @@ Make sure you have Azure Functions Core Tools installed.
228228
connection.on('newMessage', (message) => {
229229
document.getElementById("messages").innerHTML = message;
230230
});
231-
231+
232232
connection.start()
233233
.catch(console.error);
234234
</script>
235235
</body>
236-
236+
237237
</html>
238238
```
239239

240+
1. Azure Functions requires a storage account to work. You can install and run the [Azure Storage Emulator](../storage/common/storage-use-azurite.md). **Or** you can update the setting to use your real storage account with the following command:
241+
```bash
242+
func settings add AzureWebJobsStorage "<storage-connection-string>"
243+
```
244+
240245
4. You're almost done now. The last step is to set a connection string of the SignalR Service to Azure Function settings.
241246
242247
1. In the Azure portal, find the SignalR instance you deployed earlier by typing its name in the **Search** box. Select the instance to open it.
243248
244249
![Search for the SignalR Service instance](media/signalr-quickstart-azure-functions-csharp/signalr-quickstart-search-instance.png)
245250
246251
1. Select **Keys** to view the connection strings for the SignalR Service instance.
247-
252+
248253
![Screenshot that highlights the primary connection string.](media/signalr-quickstart-azure-functions-javascript/signalr-quickstart-keys.png)
249254
250255
1. Copy the primary connection string. And execute the command below.
251-
256+
252257
```bash
253258
func settings add AzureSignalRConnectionString "<signalr-connection-string>"
254259
```
255-
260+
256261
5. Run the Azure function in local host:
257262
258263
```bash
@@ -261,9 +266,6 @@ Make sure you have Azure Functions Core Tools installed.
261266
262267
After Azure Function running locally. Use your browser to visit `http://localhost:7071/api/index` and you can see the current star count. And if you star or "unstar" in GitHub, you'll see the star count refreshing every few seconds.
263268

264-
> [!NOTE]
265-
> SignalR binding needs Azure Storage, but you can use local storage emulator when the function is running locally.
266-
> If you got an error like `There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid.` You need to download and enable [Storage Emulator](../storage/common/storage-use-emulator.md)
267269

268270
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qscsharp)
269271

0 commit comments

Comments
 (0)