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
1. From a command line, create a directory for your project.
43
+
1. Change to the project directory.
44
+
1. Use the Azure Functions `func init` command to initialize your function project.
45
+
46
+
```bash
47
+
# Initialize a function project
48
+
func init --worker-runtime python
49
+
```
50
+
51
+
## Create the functions
52
+
53
+
After you initialize a project, you need to create functions. This project requires three functions:
54
+
55
+
-`index`: Hosts a web page for a client.
56
+
-`negotiate`: Allows a client to get an access token.
57
+
-`broadcast`: Uses a time trigger to periodically broadcast messages to all clients.
58
+
59
+
When you run the `func new` command from the root directory of the project, the Azure Functions Core Tools appends the function code in the `function_app.py` file. You'll edit the parameters ad content as necessary by replacing the default code with the app code.
60
+
61
+
### Create the index function
62
+
63
+
You can use this sample function as a template for your own functions.
64
+
65
+
Open the file `function_app.py`. This file will contain your functions. First, modify the file to include the neccessary import statements, and define global variables that we will be using in the following functions.
66
+
67
+
```python
68
+
import azure.functions as func
69
+
import os
70
+
import requests
71
+
import json
72
+
73
+
app = func.FunctionApp()
74
+
75
+
etag =''
76
+
start_count =0
77
+
```
78
+
79
+
2. Add the function `index` by adding the following code
res = requests.get('https://api.github.com/repos/azure/azure-functions-python-worker', headers=headers)
117
+
if res.headers.get('ETag'):
118
+
etag = res.headers.get('ETag')
119
+
120
+
if res.status_code ==200:
121
+
jres = res.json()
122
+
start_count = jres['stargazers_count']
123
+
124
+
signalRMessages.set(json.dumps({
125
+
'target': 'newMessage',
126
+
'arguments': [ 'Current star count of https://api.github.com/repos/azure/azure-functions-python-worker is: '+str(start_count) ]
127
+
}))
128
+
```
129
+
130
+
This function uses a time trigger to periodically broadcast messages to all clients.
131
+
36
132
#### [Python v1 model](#tab/python-v1)
37
133
38
134
## Create the Azure Function project
@@ -215,102 +311,6 @@ You can use this sample function as a template for your own functions.
215
311
}))
216
312
```
217
313
218
-
#### [Python v2 model](#tab/python-v2)
219
-
220
-
## Create the Azure Function project
221
-
222
-
Create a local Azure Function project.
223
-
224
-
1. From a command line, create a directory for your project.
225
-
1. Change to the project directory.
226
-
1. Use the Azure Functions `func init` command to initialize your function project.
227
-
228
-
```bash
229
-
# Initialize a function project
230
-
func init --worker-runtime python
231
-
```
232
-
233
-
## Create the functions
234
-
235
-
After you initialize a project, you need to create functions. This project requires three functions:
236
-
237
-
-`index`: Hosts a web page for a client.
238
-
-`negotiate`: Allows a client to get an access token.
239
-
-`broadcast`: Uses a time trigger to periodically broadcast messages to all clients.
240
-
241
-
When you run the `func new` command from the root directory of the project, the Azure Functions Core Tools appends the function code in the `function_app.py` file. You'll edit the parameters ad content as necessary by replacing the default code with the app code.
242
-
243
-
### Create the index function
244
-
245
-
You can use this sample function as a template for your own functions.
246
-
247
-
Open the file `function_app.py`. This file will contain your functions. First, modify the file to include the neccessary import statements, and define global variables that we will be using in the following functions.
248
-
249
-
```python
250
-
import azure.functions as func
251
-
import os
252
-
import requests
253
-
import json
254
-
255
-
app = func.FunctionApp()
256
-
257
-
etag =''
258
-
start_count =0
259
-
```
260
-
261
-
2. Add the function `index` by adding the following code
0 commit comments