I have a Function App which is successfully running locally and successfully running as "Azure Function App Container", but when I'm trying to deploy it as simply "Azure Function App", right after publishing it can't read the fields that I put in the appsettings.json file (I put there s3 key access and secret key among other things), the error that is shown is that "No RegionEndpoint or ServiceURL configured", which should be taken from the appsettings.json file. This is what happens in my startup class:
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("appsettings.json", false)
.AddUserSecrets(Assembly.GetExecutingAssembly(), false)
.AddEnvironmentVariables()
.Build();
builder.Services.AddLogging();
builder.Services.AddSingleton<IConfiguration>(config);
builder.Services.AddSingleton(svc =>
{
var client = new AzureLogAnalyticsClient(
config[LogAnalyticsWorkspaceID],
config[LogAnalyticsKey]);
client.TimeStampField = config["LogAnalyticsTimestampField"];
return client;
});
}
CodePudding user response:
An Azure Function App deployment will not read appsettings.json by default. Instead, put those configuration values in the Azure Function's application settings.
This can be done by logging into the Azure portal, going to your Azure Function, then:
- Click "Configuration" on the Azure Function blade.
- Choose Application Settings in the header.
- Enter your settings in the table below.