10
votes

I'm currently using the git push deployment option to deploy a few copies of an azure-function. The function's function.json file has multiple "connection" entries linking to different storage accounts (i.e. for a blob trigger & table output). In different copies of the deployed function I'd like to connect to different storage accounts. Is there any special syntax that can be used in function.json to populate the "connection" string from an environment variable?

I guess an alternative would be to edit function.json as part of a custom kudu step, but environment variables seems more consistent with the other azure app service offerings.

1

1 Answers

17
votes

This already works, and is actually the recommended way for you to handle connection strings, since you don't want those checked in with your source code. You can use an app setting name for the connection value, and we'll resolve it. In the following EventHub triggered function, the values MyEventHubReceiver, MyEventHubSender and MyEventHubPath will be auto resolved from app 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 of the binding properties support the %% resolution syntax, allowing you to store the actual values in app settings for both security as well as configurability.