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
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-add-output-binding-storage-queue-python.md
+9-108Lines changed: 9 additions & 108 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,20 +25,11 @@ Most bindings require a stored connection string that Functions uses to access t
25
25
26
26
Before you start this article, complete the steps in [part 1 of the Python quickstart](functions-create-first-function-python.md).
27
27
28
-
## Download the function app settings
29
-
30
-
In the previous quickstart article, you created a function app in Azure, along with the required Storage account. The connection string for this account is stored securely in app settings in Azure. In this article, you write messages to a Storage queue in the same account. To connect to your Storage account when running the function locally, you must download app settings to the local.settings.json file. Run the following Azure Functions Core Tools command to download settings to local.settings.json, replacing `<APP_NAME>` with the name of your function app from the previous article:
> Because it contains secrets, the local.settings.json file never gets published, and it should be excluded from source control.
30
+
## Download the function app settings
40
31
41
-
You need the value `AzureWebJobsStorage`, which is the Storage account connection string. You use this connection to verify that the output binding works as expected.
@@ -48,80 +39,13 @@ You can now add the Storage output binding to your project.
48
39
49
40
## Add an output binding
50
41
51
-
In Functions, each type of binding requires that a `direction`, a `type`, and a unique `name` be defined in the function.json file. Depending on the binding type, additional properties might be required. The [queue output configuration](functions-bindings-storage-queue.md#output---configuration) describes the fields required for an Azure Storage queue binding.
52
-
53
-
To create a binding, you add a binding configuration object to the function.json file. Edit the function.json file in your HttpTrigger folder to add an object to the `bindings` array that has these properties:
54
-
55
-
| Property | Value | Description |
56
-
| -------- | ----- | ----------- |
57
-
|**`name`**|`msg`| The name that identifies the binding parameter referenced in your code. |
58
-
|**`type`**|`queue`| The binding is an Azure Storage queue binding. |
59
-
|**`direction`**|`out`| The binding is an output binding. |
60
-
|**`queueName`**|`outqueue`| The name of the queue that the binding writes to. When the `queueName` doesn't exist, the binding creates it on first use. |
61
-
|**`connection`**|`AzureWebJobsStorage`| The name of an app setting that contains the connection string for the Storage account. The `AzureWebJobsStorage` setting contains the connection string for the Storage account you created with the function app. |
62
-
63
-
Your function.json file should now look like this example:
64
-
65
-
```json
66
-
{
67
-
"scriptFile": "__init__.py",
68
-
"bindings": [
69
-
{
70
-
"authLevel": "function",
71
-
"type": "httpTrigger",
72
-
"direction": "in",
73
-
"name": "req",
74
-
"methods": [
75
-
"get",
76
-
"post"
77
-
]
78
-
},
79
-
{
80
-
"type": "http",
81
-
"direction": "out",
82
-
"name": "$return"
83
-
},
84
-
{
85
-
"type": "queue",
86
-
"direction": "out",
87
-
"name": "msg",
88
-
"queueName": "outqueue",
89
-
"connection": "AzureWebJobsStorage"
90
-
}
91
-
]
92
-
}
93
-
```
94
-
95
-
## Add code that uses the output binding
96
-
97
-
After the `name` is configured, you can start using it to access the binding as a method attribute in the function signature. In the following example, `msg` is an instance of the [`azure.functions.InputStream class`](/python/api/azure-functions/azure.functions.httprequest).
98
-
99
-
```python
100
-
import logging
101
-
102
-
import azure.functions as func
103
-
42
+
In Functions, each type of binding requires a `direction`, `type`, and a unique `name` to be defined in the function.json file. The way you define these attributes depends on the language of your function app.
When you use an output binding, you don't have to use the Azure Storage SDK code for authentication, getting a queue reference, or writing data. The Functions runtime and queue output binding do those tasks for you.
127
51
@@ -144,34 +68,11 @@ Next, you use the Azure CLI to view the new queue and verify that a message was
144
68
145
69
### Set the Storage account connection
146
70
147
-
Open the local.settings.json file and copy the value of `AzureWebJobsStorage`, which is the Storage account connection string. Set the `AZURE_STORAGE_CONNECTION_STRING` environment variable to the connection string by using this Bash command:
When you set the connection string in the `AZURE_STORAGE_CONNECTION_STRING` environment variable, you can access your Storage account without having to provide authentication each time.
You can use the [`az storage queue list`](/cli/azure/storage/queue#az-storage-queue-list) command to view the Storage queues in your account, as in the following example:
158
-
159
-
```azurecli-interactive
160
-
az storage queue list --output tsv
161
-
```
162
-
163
-
The output from this command includes a queue named `outqueue`, which is the queue that was created when the function ran.
164
-
165
-
Next, use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view the messages in this queue, as in this example:
The string returned should be the same as the message you sent to test the function.
172
-
173
-
> [!NOTE]
174
-
> The previous example decodes the returned string from base64. This is because the Queue storage bindings write to and read from Azure Storage as [base64 strings](functions-bindings-storage-queue.md#encoding).
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-add-output-binding-storage-queue-vs-code.md
+2-75Lines changed: 2 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,50 +67,7 @@ In Functions, each type of binding requires a `direction`, `type`, and a unique
67
67
68
68
# [JavaScript](#tab/nodejs)
69
69
70
-
Binding attributes are defined directly in the function.json file. Depending on the binding type, additional properties may be required. The [queue output configuration](functions-bindings-storage-queue.md#output---configuration) describes the fields required for an Azure Storage queue binding. The extension makes it easy to add bindings to the function.json file.
71
-
72
-
To create a binding, right-click (Ctrl+click on macOS) the `function.json` file in your HttpTrigger folder and choose **Add binding...**. Follow the prompts to define the following binding properties for the new binding:
73
-
74
-
| Prompt | Value | Description |
75
-
| -------- | ----- | ----------- |
76
-
|**Select binding direction**|`out`| The binding is an output binding. |
77
-
|**Select binding with direction...**|`Azure Queue Storage`| The binding is an Azure Storage queue binding. |
78
-
|**The name used to identify this binding in your code**|`msg`| Name that identifies the binding parameter referenced in your code. |
79
-
|**The queue to which the message will be sent**|`outqueue`| The name of the queue that the binding writes to. When the *queueName* doesn't exist, the binding creates it on first use. |
80
-
|**Select setting from "local.setting.json"**|`AzureWebJobsStorage`| The name of an application setting that contains the connection string for the Storage account. The `AzureWebJobsStorage` setting contains the connection string for the Storage account you created with the function app. |
81
-
82
-
A binding is added to the `bindings` array in your function.json file, which should now look like the following example:
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-http-webhook.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -723,7 +723,7 @@ Keys are stored as part of your function app in Azure and are encrypted at rest.
723
723
724
724

725
725
726
-
You may obtain function keys programmatically by using [Key management API](https://github.com/Azure/azure-functions-host/wiki/Key-management-API).
726
+
You may obtain function keys programmatically by using [Key management APIs](https://github.com/Azure/azure-functions-host/wiki/Key-management-API).
727
727
728
728
### API key authorization
729
729
@@ -736,8 +736,7 @@ The key can be included in a query string variable named `code`, as above. It ca
736
736
You can allow anonymous requests, which do not require keys. You can also require that the master key be used. You change the default authorization level by using the `authLevel` property in the binding JSON. For more information, see [Trigger - configuration](#trigger---configuration).
737
737
738
738
> [!NOTE]
739
-
> When running functions locally, authorization is disabled regardless of the specified authentication level setting. After publishing to Azure, the `authLevel` setting in your trigger is enforced.
740
-
739
+
> When running functions locally, authorization is disabled regardless of the specified authentication level setting. After publishing to Azure, the `authLevel` setting in your trigger is enforced. Keys are still required when running [locally in a container](functions-create-function-linux-custom-image.md#run-the-image-locally).
0 commit comments