I try to publish Azure Function v.2, but I get an error:
The function runtime is unable to start. Microsoft.Extensions.Configuration.FileExtensions: The configuration file 'local.settings.json' was not found and is not optional. The physical path is 'D:\Program Files (x86)\SiteExtensions\Functions\2.0.12961\32bit\local.settings.json'.
I have the following configuration:
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
and I see this file in Kudu.
How to solve it?
ADDED:
I tried to create another file, named config.json
:
{
"FtpSettings": {
"FtpServer": "ftp://address/out",
"FtpLogin": "login",
"FtpPassword": "pass"
}
}
then try to read it:
var config = new ConfigurationBuilder()
.AddJsonFile("config.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
builder.Services.AddTransient<FtpService.IFtpService>(s => new FtpService.Core.FtpService(
address: config.GetSection("FtpSettings:FtpServer").Value,
username: config.GetSection("FtpSettings:FtpLogin").Value,
password: config.GetSection("FtpSettings:FtpPassword").Value
));
so, my Startup
class is:
[assembly: FunctionsStartup(typeof(FunctionAppEfsGetFilesFromFtp.Startup))]
namespace FunctionAppEfsGetFilesFromFtp
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.AddJsonFile("config.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
builder.Services.AddTransient<FtpService.IFtpService>(s => new FtpService.Core.FtpService(
address: config.GetSection("FtpSettings:FtpServer").Value,
username: config.GetSection("FtpSettings:FtpLogin").Value,
password: config.GetSection("FtpSettings:FtpPassword").Value
));
}
}
}
but it can't be read too