Azure 函数 - 使用 appsettings.json [英] Azure Functions - using appsettings.json

查看:38
本文介绍了Azure 函数 - 使用 appsettings.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Azure Functions 中使用 appsettings.json 文件?

Is it possible to use an appsettings.json file in Azure Functions?

这里有关于环境变量的文档..

There is documentation for environment variables here..

https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#environment-variables

..但是我们使用 Octopus 进行部署,并且非常希望能够控制 appsettings 版本.

..however we use Octopus for deployments and would really like to have appsettings version controlled.

我们已经尝试使用

{
  "frameworks": {
    "net46": {
      "dependencies": {
        "Microsoft.Extensions.Configuration": "1.0.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0"
      }
    }
  }
}

但不断得到

2016-11-23T15:27:03.811 (12,16):错误 CS0012:对象"类型在未引用的程序集中定义.您必须添加对程序集System.Runtime, Version=4.0.0.0

2016-11-23T15:27:03.811 (12,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0

即使能够通过 Octopus 提供/更新环境变量也足以满足我们的需求.

Even being able to supply/update environment variables via Octopus would be sufficient for our needs.

请指教.

推荐答案

应用设置和连接字符串仅支持环境变量.appsettings.json 不受支持.

Only environment variables are supported for app settings and connection strings. appsettings.json is not supported.

但是,您可以使用 Azure 资源管理器 (ARM) 模板来配置函数应用的设置.这是博文 更详细地描述这一点.

However, you can use Azure Resource Manager (ARM) Templates to configure the settings for your Function App. Here's a blog post that describe this in more detail.

这篇关于Azure 函数 - 使用 appsettings.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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