Код: Выделить всё
[FunctionName("FunctionName")]
public static async Task Run([TimerTrigger("45 0 0 * * *")]TimerInfo myTimer, [DurableClient] IDurableOrchestrationClient starter, Binder binder, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed with frequency: {myTimer}");
await csvFileCreater(binder).ConfigureAwait(false);
log.LogInformation($"FunctionName - completed.");
}
private static async Task csvFileCreater(Binder binder)
{
string csvFileName = CommonUtils.GenerateCSVFileName();
var attributes = new Attribute[]
{
new BlobAttribute($"containerName/{csvFileName}"),
new StorageAccountAttribute("AzureWebsJobsStorage")
};
using (var writer = await binder.BindAsync(attributes))
{
writer.Write($"ColumnName ");
}
return csvFileName;
}
Однако после обновления до dotnet 8 оба объекта стали пустыми. Я нашел обходной путь для ведения журнала и включил его в своем проекте, добавив ведение журнала в файл program.cs:
Код: Выделить всё
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices((appBuilder, services) =>
{
var config = appBuilder.Configuration;
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddSingleton();
services.AddHttpClient();
})
.ConfigureLogging(logging =>
{
logging.Services.Configure(options =>
{
LoggerFilterRule defaultRule = options.Rules.FirstOrDefault(rule => rule.ProviderName
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (defaultRule is not null)
{
options.Rules.Remove(defaultRule);
}
});
})
.Build();
host.Run();
Подробнее здесь: https://stackoverflow.com/questions/784 ... ty-or-null
Мобильная версия