Код: Выделить всё
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureAppConfiguration(config =>
{
config.AddUserSecrets
(optional: true, reloadOnChange: false);
})
.ConfigureServices((hostContext, services) =>
{
var authOptions = hostContext.Configuration.GetSection(nameof(OidcAuthOptions)).Get();
services
.AddTransient()
.AddTransient();
})
.Build();
host.Run();
Код: Выделить всё
public class KeepWarm
{
///
/// KeepWarm, runs twice every minute; can also trigger storages (configfile)
///
private readonly IOptions _options;
private readonly ILogger _log;
public KeepWarm(IOptions options, ILogger log)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
_log = log ?? throw new ArgumentNullException(nameof(log));
}
[Function(nameof(KeepWarm))]
public async Task Run([TimerTrigger("1-2 * * * * *")] TimerInfo myTimer) // Run twice per minute at sec 1 and 2
{
var functionAppUrl = _options.Value.FunctionAppUrl;
_log.LogInformation($"Start querying endpoints (BaseUrl={functionAppUrl})");
using (var client = new HttpClient { BaseAddress = new Uri(functionAppUrl) })
{
var endpoints = new[] {
"echo",
};
var tasks = endpoints.Select(async (endpoint) =>
{
var response = await client.GetAsync(endpoint);
_log.LogInformation($"Called {endpoint} with status code {response.StatusCode}");
});
await Task.WhenAll(tasks);
}
}
}
[img]https://i.sstatic .net/IYRU9z0W.png[/img]
но при выполнении сразу вылетает:
Другие конечные точки работают; в чем проблема с этим?
Лучший
J
Подробнее здесь: https://stackoverflow.com/questions/790 ... -execution