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()}')
365
362
```
366
363
367
-
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 account based on the _ID_ in the route URL and made available as `obj` in the function body. Here, the specified storage account is the connection string that's found in the `AzureWebJobsStorage` app setting, which is the same storage account that's used by the function app.
364
+
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 account based on the _ID_ in the route URL and made available as `obj` in the function body. Here, the specified storage account is the connection string that's found in the `CONNECTION_STRING` app setting.
368
365
::: zone-end
369
366
::: zone pivot="python-mode-decorators"
370
367
Inputs are divided into two categories in Azure Functions: trigger input and other input. Although they're defined using different decorators, their usage is similar in Python code. Connection strings or secrets for trigger and input sources map to values in the *local.settings.json* file when they're running locally, and they map to the application settings when they're running in Azure.
@@ -377,6 +374,7 @@ As an example, the following code demonstrates how to define a Blob Storage inpu
logging.info(f'Python HTTP-triggered function processed: {obj.read()}')
399
396
```
400
397
401
-
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 account based on the _ID_ in the route URL and made available as `obj` in the function body. Here, the specified storage account is the connection string that's found in the AzureWebJobsStorage app setting, which is the same storage account that's used by the function app.
398
+
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 account based on the _ID_ in the route URL and made available as `obj` in the function body. Here, the specified storage account is the connection string that's found in the `STORAGE_CONNECTION_STRING` app setting.
402
399
::: zone-end
403
400
404
401
For data intensive binding operations, you may want to use a separate storage account. For more information, see [Storage account guidance](storage-considerations.md#storage-account-guidance).
@@ -445,7 +442,7 @@ To produce multiple outputs, use the `set()` method provided by the [`azure.func
445
442
"direction": "out",
446
443
"type": "queue",
447
444
"queueName": "outqueue",
448
-
"connection": "AzureWebJobsStorage"
445
+
"connection": "STORAGE_CONNECTION_STRING"
449
446
},
450
447
{
451
448
"name": "$return",
@@ -459,7 +456,6 @@ To produce multiple outputs, use the `set()` method provided by the [`azure.func
459
456
```python
460
457
import azure.functions as func
461
458
462
-
463
459
defmain(req: func.HttpRequest,
464
460
msg: func.Out[func.QueueMessage]) -> str:
465
461
@@ -478,10 +474,10 @@ To produce multiple outputs, use the `set()` method provided by the [`azure.func
Inside your *.venv* Python virtual environment folder, install your favorite Python test framework, such as `pip install pytest`. Then run `pytest tests` to check the test result.
@@ -1180,7 +1169,6 @@ from shared_code import my_second_helper_function
1180
1169
1181
1170
app = func.FunctionApp()
1182
1171
1183
-
1184
1172
# Define the HTTP trigger that accepts the ?value=<int> query parameter
1185
1173
# Double the value and return the result in HttpResponse
1186
1174
@app.function_name(name="my_second_function")
@@ -1215,27 +1203,24 @@ You can start writing test cases for your HTTP trigger.
1215
1203
# <project_root>/tests/test_my_second_function.py
1216
1204
import unittest
1217
1205
import azure.functions as func
1218
-
from function_app import main
1219
1206
1207
+
from function_app import main
1220
1208
1221
1209
classTestFunction(unittest.TestCase):
1222
-
deftest_my_second_function(self):
1223
-
# Construct a mock HTTP request.
1224
-
req = func.HttpRequest(
1225
-
method='GET',
1226
-
body=None,
1227
-
url='/api/my_second_function',
1228
-
params={'value': '21'})
1229
-
1230
-
# Call the function.
1231
-
func_call = main.build().get_user_function()
1232
-
resp = func_call(req)
1233
-
1234
-
# Check the output.
1235
-
self.assertEqual(
1236
-
resp.get_body(),
1237
-
b'21 * 2 = 42',
1238
-
)
1210
+
deftest_my_second_function(self):
1211
+
# Construct a mock HTTP request.
1212
+
req = func.HttpRequest(method='GET',
1213
+
body=None,
1214
+
url='/api/my_second_function',
1215
+
params={'value': '21'})
1216
+
# Call the function.
1217
+
func_call = main.build().get_user_function()
1218
+
resp = func_call(req)
1219
+
# Check the output.
1220
+
self.assertEqual(
1221
+
resp.get_body(),
1222
+
b'21 * 2 = 42',
1223
+
)
1239
1224
```
1240
1225
1241
1226
Inside your *.venv* Python virtual environment folder, install your favorite Python test framework, such as `pip install pytest`. Then run `pytest tests` to check the test result.
@@ -1255,6 +1240,7 @@ The following example creates a named temporary file in the temporary directory
0 commit comments