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
- A code editor, such as [Visual Studio Code](https://code.visualstudio.com/).
22
-
- An Azure account with an active subscription. If you don't already have an Azure account, [create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
23
-
-[Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing), version 2 or above. Used to run Azure Function apps locally.
24
-
-[Node.js](https://nodejs.org/en/download/), See supported node.js versions in the [Azure Functions JavaScript developer guide](../azure-functions/functions-reference-node.md#node-version).
25
-
- SignalR binding needs Azure Storage, but you can use a local storage emulator when a function is running locally. Install the open source storage emulator [Azurite](../storage/common/storage-use-azurite.md).
26
-
27
-
The examples should work with other versions of Node.js, for more information, see [Azure Functions runtime versions documentation](../azure-functions/functions-versions.md#languages).
28
-
29
21
This quickstart can be run on macOS, Windows, or Linux.
30
22
23
+
| Prerequisite | Description |
24
+
| --- | --- |
25
+
| An Azure subsription |If you don't have an [Azure subscription](../articles/guides/developer/azure-developer-guide.md#understanding-accounts-subscriptions-and-billing), create an [Azure free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio)|
26
+
| A code editor | You'll need a code editor such as [Visual Studio Code](https://code.visualstudio.com/). |
27
+
|[Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing)| Requires version 2.7.1505 or higher to run Python Azure Function apps locally.|
28
+
|[Node.js](https://nodejs.org/en/download/)| See supported node.js versions in the [Azure Functions JavaScript developer guide](../azure-functions/functions-reference-node.md#node-version).|
29
+
|[Azurite](../storage/common/storage-use-azurite.md)| SignalR binding needs Azure Storage. You can use a local storage emulator when a function is running locally. |
30
+
|[Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli)| Optionally, you can use the Azure CLI to create an Azure SignalR Service instance. |
@@ -36,30 +37,28 @@ This quickstart can be run on macOS, Windows, or Linux.
36
37
37
38
Make sure you have Azure Functions Core Tools installed.
38
39
39
-
1. Open a command line
40
-
1. Create an empty directory and then change to it.
41
-
1. Run the Azure Functions `func init` command to initialize a new project:
40
+
1. Open a command line.
41
+
1. Create project directory and then change to it.
42
+
1. Run the Azure Functions `func init` command to initialize a new project.
42
43
43
44
```bash
44
45
# Initialize a function project
45
46
func init --worker-runtime javascript
46
47
```
47
48
48
-
## Create the functions
49
+
## Create the project functions
49
50
50
-
After you initialize a project, you need to create functions. In this sample, we need to create three functions:
51
+
After you initialize a project, you need to create functions. This project requires three functions:
51
52
52
-
-`index`: hosts a web page for a client
53
-
-`negotiate`: allows client to get an access token
54
-
-`broadcast`: broadcasts messages to all clients. In the app, the time trigger broadcasts messages periodically
53
+
-`index`: Hosts a web page for a client.
54
+
-`negotiate`: Allows a client to get an access token.
55
+
-`broadcast`: Uses a time trigger to periodically broadcast messages to all clients.
55
56
56
57
When you run the `func new` command from the root directory of the project, the Azure Functions Core Tools creates the function source files storing them in a folder with the function name. You'll edit the files as necessary replacing the default code with the app code.
57
58
58
59
### Create the index function
59
60
60
-
61
-
62
-
1. Run the following command to create an `index` function.
61
+
1. Run the following command to create the `index` function.
63
62
64
63
```bash
65
64
func new -n index -t HttpTrigger
@@ -112,10 +111,9 @@ When you run the `func new` command from the root directory of the project, the
112
111
}
113
112
```
114
113
115
-
116
114
### Create the negotiate function
117
115
118
-
1. Run the following command to create an`negotiate` function.
116
+
1. Run the following command to create the`negotiate` function.
119
117
120
118
```bash
121
119
func new -n negotiate -t HttpTrigger
@@ -152,12 +150,10 @@ When you run the `func new` command from the root directory of the project, the
152
150
]
153
151
}
154
152
```
155
-
156
-
157
153
158
154
### Create a broadcast function.
159
155
160
-
1. Run the following command to create an`broadcast` function.
156
+
1. Run the following command to create the`broadcast` function.
161
157
162
158
```bash
163
159
func new -n broadcast -t TimerTrigger
@@ -186,7 +182,7 @@ When you run the `func new` command from the root directory of the project, the
186
182
}
187
183
```
188
184
189
-
1.Edit *broadcast/index.js* and replace the contents with the following code:
185
+
1. Edit *broadcast/index.js* and replace the contents with the following code:
190
186
191
187
```javascript
192
188
var https =require('https');
@@ -232,13 +228,14 @@ When you run the `func new` command from the root directory of the project, the
232
228
}
233
229
```
234
230
235
-
The client interface for this app is a web page. The `index` function reads HTML content from the *content/index.html* file.
231
+
### Create the index.html file
232
+
233
+
The client interface for this app is a web page. The `index` function reads HTML content from the *content/index.html* file.
236
234
237
235
1. Create a folder called `content` in your project root folder.
238
-
1. Create a new file *index.html* in the `content` folder.
236
+
1. Create the file *content/index.html*.
239
237
1. Copy the following content to the *content/index.html* file and save it:
240
238
241
-
242
239
```html
243
240
<html>
244
241
@@ -267,17 +264,14 @@ The client interface for this app is a web page. The `index` function reads HTML
267
264
268
265
### Add the SignalR Service connection string to the function app settings
269
266
270
-
The last step is to set the connection string of the SignalR Service in Azure Function settings.
271
-
272
-
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.
273
-
274
-

267
+
The last step is to set the SignalR Service connection string in Azure Function app settings.
275
268
269
+
1. In the Azure portal, go to the SignalR instance you deployed earlier.
276
270
1. Select **Keys** to view the connection strings for the SignalR Service instance.
277
271
278
-

272
+
:::image type="content" source="media/signalr-quickstart-azure-functions-javascript/signalr-quickstart-keys.png" alt-text="Screenshot of Azure SignalR service Keys page.":::
279
273
280
-
1. Copy the primary connection string. And execute the command:
274
+
1. Copy the primary connection string, and execute the command:
@@ -291,16 +285,16 @@ Start the Azurite storage emulator:
291
285
azurite
292
286
```
293
287
294
-
Run the Azure Function in the local environment:
288
+
Run the Azure Function app in the local environment:
295
289
296
290
```bash
297
291
func start
298
292
```
299
293
300
294
> [!NOTE]
301
-
> If you see an error like `There was an error performing a read operation on the Blob Storage Secret Repository`. Please ensure the 'AzureWebJobsStorage' setting in the *local.settings.json* file is set to `UseDevelopmentStorage=true`.
295
+
> If you see an errors showing read errors on the blob storage, ensure the 'AzureWebJobsStorage' setting in the *local.settings.json* file is set to `UseDevelopmentStorage=true`.
302
296
303
-
After the Azure Function is running locally, go to `http://localhost:7071/api/index`. The page shows the current star count for the GitHub Azure/azure-signalr repository. When you star or unstar the repository in GitHub, you'll see the refreshed count on the page every few seconds.
297
+
After the Azure Function is running locally, go to `http://localhost:7071/api/index`. The page displays the current star count for the GitHub Azure/azure-signalr repository. When you star or unstar the repository in GitHub, you'll see the refreshed count every few seconds.
304
298
305
299
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qscsharp)
Copy file name to clipboardExpand all lines: articles/azure-signalr/signalr-quickstart-azure-functions-python.md
+26-30Lines changed: 26 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,22 +18,21 @@ Get started with Azure SignalR Service by using Azure Functions and Python to bu
18
18
19
19
## Prerequisites
20
20
21
-
This quickstart can be run on macOS, Windows, or Linux.
21
+
This quickstart can be run on macOS, Windows, or Linux. You willneed the following:
22
22
23
-
- You'll need a code editor such as [Visual Studio Code](https://code.visualstudio.com/).
24
-
25
-
- Install the [Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing) (version 2.7.1505 or higher) to run Python Azure Function apps locally.
26
-
27
-
- Azure Functions requires [Python 3.6+](https://www.python.org/downloads/). (See [Supported Python versions](../azure-functions/functions-reference-python.md#python-version).)
28
-
29
-
- SignalR binding needs Azure Storage, but you can use a local storage emulator when a function is running locally. You'll need to install and run the open source storage emulator [Azurite](../storage/common/storage-use-azurite.md).
| An Azure subsription |If you don't have an [Azure subscription](../articles/guides/developer/azure-developer-guide.md#understanding-accounts-subscriptions-and-billing), create an [Azure free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio)|
26
+
| A code editor | You'll need a code editor such as [Visual Studio Code](https://code.visualstudio.com/). |
27
+
|[Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing)| Requires version 2.7.1505 or higher to run Python Azure Function apps locally.|
|[Azurite](../storage/common/storage-use-azurite.md)| SignalR binding needs Azure Storage. You can use a local storage emulator when a function is running locally. |
30
+
|[Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli)| Optionally, you can use the Azure CLI to create an Azure SignalR Service instance. |
@@ -49,19 +48,19 @@ Create a local Azure Function project.
49
48
50
49
## Create the functions
51
50
52
-
After you initialize a project, you need to create functions. In this sample, we need to create three functions:
51
+
After you initialize a project, you need to create functions. This project requires three functions:
53
52
54
-
-`index`: hosts a web page for a client
55
-
-`negotiate`: allows client to get an access token
56
-
-`broadcast`: broadcasts messages to all clients. In the app, the time trigger broadcasts messages periodically
53
+
-`index`: Hosts a web page for a client.
54
+
-`negotiate`: Allows a client to get an access token.
55
+
-`broadcast`: Uses a time trigger to periodically broadcast messages to all clients.
57
56
58
-
When you run the `func new` command from the root directory of the project, the Azure Functions Core Tools creates the function source files storing them in a folder with the function name. You'll edit the files as necessary replacing the default code with the app code.
57
+
When you run the `func new` command from the root directory of the project, the Azure Functions Core Tools creates default function source files and stores them in a folder named after the function. You'll edit the files as necessary replacing the default code with the app code.
59
58
60
59
### Create the index function
61
60
62
61
You can use this sample function as a template for your own functions.
63
62
64
-
1. Run the following command to create an`index` function.
63
+
1. Run the following command to create the`index` function.
65
64
66
65
```bash
67
66
func new -n index -t HttpTrigger
@@ -105,7 +104,7 @@ You can use this sample function as a template for your own functions.
105
104
106
105
### Create the negotiate function
107
106
108
-
1. Run the following command to create an `negotiate` function.
107
+
1. Run the following command to create the `negotiate` function.
109
108
110
109
```bash
111
110
func new -n negotiate -t HttpTrigger
@@ -154,7 +153,7 @@ You can use this sample function as a template for your own functions.
154
153
155
154
### Create a broadcast function.
156
155
157
-
1. Run the following command to create an `broadcast` function.
156
+
1. Run the following command to create the `broadcast` function.
158
157
159
158
```bash
160
159
func new -n broadcast -t TimerTrigger
@@ -219,7 +218,7 @@ You can use this sample function as a template for your own functions.
219
218
The client interface for this app is a web page. The `index` function reads HTML content from the *content/index.html* file.
220
219
221
220
1. Create a folder called `content` in your project root folder.
222
-
1. Create a new file *index.html* in the `content` folder.
221
+
1. Create the file *content/index.html*.
223
222
1. Copy the following content to the *content/index.html* file and save it:
224
223
225
224
```html
@@ -250,17 +249,14 @@ The client interface for this app is a web page. The `index` function reads HTML
250
249
251
250
### Add the SignalR Service connection string to the function app settings
252
251
253
-
The last step is to set the connection string of the SignalR Service in Azure Function settings.
254
-
255
-
1. In the Azure portal, search for the SignalR Service instance you deployed earlier. Select the instance to open it.
256
-
257
-

252
+
The last step is to set the SignalR Service connection string in Azure Function app settings.
258
253
254
+
1. In the Azure portal, go to the SignalR instance you deployed earlier.
259
255
1. Select **Keys** to view the connection strings for the SignalR Service instance.
260
256
261
-

257
+
:::image type="content" source="media/signalr-quickstart-azure-functions-javascript/signalr-quickstart-keys.png" alt-text="Screenshot of Azure SignalR service Keys page.":::
262
258
263
-
1. Copy the primary connection string, and then run the following command:
259
+
1. Copy the primary connection string, and execute the command:
@@ -274,16 +270,16 @@ Start the Azurite storage emulator:
274
270
azurite
275
271
```
276
272
277
-
Run the Azure Function in the local environment:
273
+
Run the Azure Function app in the local environment:
278
274
279
275
```bash
280
276
func start
281
277
```
282
278
283
279
> [!NOTE]
284
-
> If you see an error like `There was an error performing a readoperation on the Blob Storage Secret Repository`. Please ensure the 'AzureWebJobsStorage' setting in the *local.settings.json* file is set to `UseDevelopmentStorage=true`.
280
+
> If you see an errors showing readerrors on the blob storage, ensure the 'AzureWebJobsStorage' setting in the *local.settings.json* file is set to `UseDevelopmentStorage=true`.
285
281
286
-
After the Azure Function is running locally, go to `http://localhost:7071/api/index`. The page shows the current star count forthe GitHub Azure/azure-signalr repository. When you star or unstar the repositoryin GitHub, you'll see the refreshed count on the page every few seconds.
282
+
After the Azure Function is running locally, go to `http://localhost:7071/api/index`. The page displays the current star count forthe GitHub Azure/azure-signalr repository. When you star or unstar the repositoryin GitHub, you'll see the refreshed count every few seconds.
0 commit comments