Azure函数:可以在function.json中使用环境变量吗? [英] Azure-functions: Can environment variables be used in function.json?

查看:166
本文介绍了Azure函数:可以在function.json中使用环境变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用git push部署选项来部署azure函数的一些副本.函数的function.json文件具有多个连接"条目,这些条目链接到不同的存储帐户(例如,用于Blob触发器和表输出).在不同的部署功能副本中,我想连接到不同的存储帐户.在function.json中是否可以使用任何特殊的语法来填充环境变量中的连接"字符串?

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?

我想一个替代方法是在自定义kudu步骤中编辑function.json,但是环境变量似乎与其他Azure应用服务产品更加一致.

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.

推荐答案

这已经有效,并且实际上是您推荐的处理连接字符串的方法,因为您不希望使用源代码进行检入.您可以为connection值使用应用设置名称,我们将对其进行解析.在以下EventHub触发的函数中,值MyEventHubReceiverMyEventHubSenderMyEventHubPath将从应用程序设置中自动解析:

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.

这篇关于Azure函数:可以在function.json中使用环境变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆