Azure-functions: Can environment variables be used in .json functions?

I am currently using the git deployment option to deploy multiple copies of the azure function. The function.json function file has several "connection" entries associated with various storage accounts (i.e., for a blob trigger and table output). In different instances of the deployed function, I would like to connect to different accounts. Is there a special syntax that can be used in a .json function to populate a connection string from an environment variable?

I suppose an alternative would be to edit the .json function as part of the kudu user step, but the environment variables look more consistent with other offers for azure applications.

+8
azure azure-functions kudu
source share
1 answer

This already works and is actually the recommended way to handle connection strings, since you do not want them to be included in your source code. You can use the application parameter name for the connection value, and we will enable it. In the following EventHub function that is running, the values MyEventHubReceiver , MyEventHubSender and MyEventHubPath will be automatically resolved from the application settings:

  "bindings": [ { "type": "eventHubTrigger", "name": "input", "direction": "in", "connection": "MyEventHubReceiver", "path": "%MyEventHubPath%" }, { "type": "eventHub", "name": "output", "direction": "out", "connection": "MyEventHubSender", "path": "%MyEventHubPath%" } ] } 

In general, most binding properties support the %% permission syntax, which allows you to store the actual values ​​in the application settings for both security and configuration.

+11
source share

All Articles