相关疑难解决方法(0)

我可以如何向Azure函数提供设置文件?

将使用设置文件的应用程序移植到Azure函数时,是否有必要消除对文件的依赖?

我想编写一个功能应用程序,以将数据从Xero导入到Azure sql数据库中。我正在使用的Xero SDK需要一个appsettings.json文件。

因此,当函数运行时,我得到了错误

System.Private.CoreLib: Exception while executing function:
FunctionXeroSync. Xero.Api: The type initializer for 
'Xero.Api.Infrastructure.Applications.Private.Core' threw an exception. 
Microsoft.Extensions.Configuration.FileExtensions: The configuration file 
'appsettings.json' was not found and is not optional. The physical path is 
'C:\Users\kirst\AppData\Local\AzureFunctionsTools\Releases\2.6.0\cli\appsettings.json'.
Run Code Online (Sandbox Code Playgroud)

我尝试通过VS2017 Project Publish选项卡上的Manage Application Settings链接将相关设置放入。显然,这失败了。我还有其他方法可以使用吗?

这是api中的相关代码。我希望不必修改它,以便可以使用官方的nuget包。

namespace Xero.Api
{
    public class XeroApiSettings : IXeroApiSettings
    {
        public IConfigurationSection ApiSettings { get; set; }

        public XeroApiSettings(string settingspath)
        {

            var builder = new ConfigurationBuilder()
                .AddJsonFile(settingspath)
                .Build();

            ApiSettings = builder.GetSection("XeroApi");
        }
        public XeroApiSettings() : this("appsettings.json")
        {
        } …
Run Code Online (Sandbox Code Playgroud)

c# azure xero-api azure-functions

6
推荐指数
1
解决办法
814
查看次数

标签 统计

azure ×1

azure-functions ×1

c# ×1

xero-api ×1