Azure功能设置 [英] Azure functions settings

查看:43
本文介绍了Azure功能设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将环境变量添加到azure函数中,其中包含"local.settings.json",但这仅用于本地开发,尽管该文档并未提供任何有关如何设置设置的线索在生产中.

I'm trying to add an environment variable to azure functions, there is the "local.settings.json", but it's only for local development, though the documentation doesn't give any clue as to how I can set settings in production.

任何有关环境变量的文档都只说明了如何读取环境变量,但是我想写一个环境变量...

Any documentation about environment variable only explains how to READ environment variables, but I wish to WRITE an environment variable...

如果不存在这样的文件选项,是否可以使用AZ cli设置环境变量?

If no such file option exists, is it possible to set environment variables using the AZ cli?

推荐答案

有几种选择,这取决于您如何将功能部署到Azure.

There are several options and it depends a bit how you are deploying your function to Azure.

az functionapp config appsettings set [--ids]
                                      [--name]
                                      [--resource-group]
                                      [--settings]
                                      [--slot]
                                      [--slot-settings]
                                      [--subscription]

其中-settings参数包含以空格分隔的name=value对.

Where the -settings argument contains space separated name=value pairs.

更多信息:这会将您的功能应用程序(包括您的本地设置)发布到云端:

This publishes your function app including your local settings to the cloud:

func azure functionapp publish <FunctionAppName> --publish-local-settings

这仅将您的本地设置发布到云中的功能应用程序:

This publishes only your local settings to your function app in the cloud:

func azure functionapp publish <FunctionAppName> --publish-settings-only

请参见 https://docs.microsoft.com/zh-CN/azure/azure-functions/functions-run-local#project-file-deployment

如果您将Azure DevOps与发布管道一起使用,则可以轻松使用Azure Function App任务:

If you're using Azure DevOps with Release Pipelines the Azure Function App task is convenient to use:

在任务的appSettings参数中以空格分隔的-key value对提供设置.

Supply the settings as space separated -key value pairs in the appSettings parameter in the task.

更多信息:如Matt所述,您也可以通过配置->应用程序设置使用Azure门户进行添加/更新,但是如果您要进行自动部署,则建议您这样做.

As Matt described you could add/update using the Azure Portal as well via Configuration -> Application Settings but I recommend against that if you're doing automated deployments (which you should ;).

这篇关于Azure功能设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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