Код: Выделить всё
[2024-04-25T09:22:29.421Z] Found
C:\Users\gdifronzo\source_C#\AE.Resp.Device.Sync\
AE.Resp.Device.Sync\AE.Resp.Device.Sync\AE
.Resp.Device.Sync.csproj. Using for user secrets file configuration.
[2024-04-25T09:22:30.766Z] A host error has occurred during startup operation
'd5c1ddb1-1e25-406a-b64c-ef69bf086ab4'.
[2024-04-25T09:22:30.768Z] Microsoft.Azure.WebJobs.Script: Did not find functions with
language [dotnet-isolated].
[2024-04-25T09:22:30.786Z] Failed to stop host instance '8db57ba1-9d37-44cd-a3d9-
e6e01699e700'.
[2024-04-25T09:22:30.788Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
Код: Выделить всё
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"FhirServerUrl": "https://xxxxxxxxxxxx.azurewebsites.net",
"TimeTriggerSchedule": "0 */5 * * *",
"MaximumExecutionTime": 21600,
"MongoDbConnectionString": "mongodb+srv://xxxxxxxxxxx",
"MongoDbThumbprint": "xxxxxxxx"
}
}
Код: Выделить всё
IHostBuilder builder = new HostBuilder().ConfigureFunctionsWebApplication();
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile("local.settings.json", true, true)
.Build();
X509Certificate2 mongoCertificate;
string mongoConnectionString = configuration.GetValue
("MongoDbConnectionString")
??
throw new CertificateNotFoundException("Unable to load configuration with key
'MongoDbConnectionString'");
try
{
mongoCertificate =
Utils.LoadCertificate(configuration.GetRequiredSection("MongoDbThumbprint").Value);
}
catch
{
throw;
}
MongoDBService mongoDBService = new(mongoConnectionString, mongoCertificate);
builder.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddSingleton();
services.AddSingleton(mongoDBService.CreateRepository
("deviceSync"));
});
IHost host = builder.Build();
host.Run();
Код: Выделить всё
private readonly ILogger _logger = loggerFactory.CreateLogger();
private readonly IDeviceSyncService _deviceSyncService = deviceSyncService;
[Function("DeviceSyncFunction")]
public void Run([TimerTrigger("%TimerExpression%", RunOnStartup = true)] TimerInfo
timerInfo)
{
try
{
_logger.LogInformation($"Timer trigger function executed at: {DateTime.UtcNow}
UTC");
_deviceSyncService.GenerateDevices();
_logger.LogInformation($"Timer trigger function terminated at: {DateTime.UtcNow}
UTC");
}
catch (OperationCanceledException opex)
{
_logger.LogWarning(opex, opex.Message);
}
catch (FhirOperationException ex)
{
_logger.LogError(ex, ex.Message, ex.StackTrace);
}
catch (Exception ex)
{
_logger.LogCritical(ex, ex.Message);
}
}
Код: Выделить всё
net8.0
v4
Exe
enable
enable
PreserveNewest
Never
Код: Выделить всё
Always
Подробнее здесь: https://stackoverflow.com/questions/783 ... t-isolated