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
logging.info(f'Python HTTP triggered function processed: {obj.read()}')
169
169
```
170
170
171
-
When the function is invoked, the HTTP request is passed to the function as `req`. An entry will be retrieved from the Azure Blob Storage based on the _ID_ in the route URL and made available as `obj` in the function body. Here the storage account specified is the connection string found in `AzureWebJobsStorage` which is the same storage account used by the function app.
171
+
When the function is invoked, the HTTP request is passed to the function as `req`. An entry will be retrieved from the Azure Blob Storage based on the _ID_ in the route URL and made available as `obj` in the function body. Here the storage account specified is the connection string found in , which is the same storage account used by the function app.
In this function, the value of the `name` query parameter is obtained from the `params` parameter of the [HttpRequest] object. The JSON-encoded message body is read using the `get_json` method.
278
278
279
279
Likewise, you can set the `status_code` and `headers` for the response message in the returned [HttpResponse] object.
280
-
281
-
## Async
282
280
283
-
We recommend that you write your Azure Function as an asynchronous coroutine using the `async def` statement.
281
+
## Concurrency
284
282
285
-
```python
286
-
# Will be run with asyncio directly
283
+
By default, the Functions Python runtime can only process one invocation of a function at a time. This concurrency level might not be sufficient under one or more of the following conditions:
284
+
285
+
+ You're trying to handle a number of invocations being made at the same time.
286
+
+ You're processing a large number of I/O events.
287
+
+ Your application is I/O bound.
288
+
289
+
In these situations, you can improve performance by running asynchronously and by using multiple language worker processes.
287
290
291
+
### Async
292
+
293
+
We recommend that you use the `async def` statement to make your function run as an asynchronous coroutine.
294
+
295
+
```python
296
+
# Runs with asyncio directly
288
297
289
298
asyncdefmain():
290
299
await some_nonblocking_socket_io_op()
291
300
```
292
301
293
-
If the main() function is synchronous (no qualifier), we automatically run the function in an `asyncio` thread-pool.
302
+
When the `main()` function is synchronous (without the `async`qualifier), the function is automatically run in an `asyncio` thread-pool.
294
303
295
304
```python
296
-
# Would be run in an asyncio thread-pool
297
-
305
+
# Runs in an asyncio thread-pool
298
306
299
307
defmain():
300
308
some_blocking_socket_io()
301
309
```
302
310
311
+
### Use multiple language worker processes
312
+
313
+
By default, every Functions host instance has a single language worker process. However there's support to have multiple language worker processes per host instance. Function invocations can then be evenly distributed among these language worker processes. Use the [FUNCTIONS_WORKER_PROCESS_COUNT](functions-app-settings.md#functions_worker_process_count) application setting to change this value.
314
+
303
315
## Context
304
316
305
317
To get the invocation context of a function during execution, include the [`context`](/python/api/azure-functions/azure.functions.context?view=azure-python) argument in its signature.
0 commit comments