【发布时间】:2017-08-14 12:15:36
【问题描述】:
我有一个 Azure Functions 项目,我正在使用 Visual Studio 2017 15.3 preview 7 用 C# 编写该项目。函数项目包含两个单独的函数,这两个函数都是计时器触发的。我在 appsettings.json 文件中指定了许多 appsettings,该文件设置为 Copy to the output directory on build.
当我发布 Azure Functions 项目时,这两个函数会显示在 Azure 门户中,但是它们会失败,因为它们无权访问应用程序设置。现在我知道我可以在应用程序设置刀片中指定设置,但我想使用 appsettings.json 根据这个 github 问题应该是可能的:https://github.com/Azure/azure-functions-cli/issues/33
这个 SO 答案包含一些关于让它工作的信息Azure Functions - using appsettings.json。现在问题在于“Azure 将尝试将 appsettings.json 文件查找到您正在处理的函数的根文件夹中。”我的函数项目包含以下文件结构:
-appsettings.json
-Function_function1.cs
-Function_function2.cs
-host.json
当项目构建和部署时,我最终为 wwwroot 中的每个函数创建了一个文件夹,每个函数都包含一个 function.json 文件。 appsettings.json 文件进入 wwwroot/bin 文件夹,函数无法访问。
我想如果我将函数项目更改为具有文件夹结构它将部署 appsettings.json,我将其更改为以下内容
-host.json
-Function_function1\
--Function_function1.cs
--appsettings.json
-Function_function2\
--Function_function2.cs
--appsettings.json
这没有达到我预期的结果,此时我不太确定我需要做什么才能将 appsettings 复制到 wwwroot 下的功能文件夹而不是 bin 文件夹中,任何指导将不胜感激。
【问题讨论】:
标签: azure azure-functions