0

I am uploading my .Netframework 4.8v console application to Azure Webjob by using Publish as Azure Webjobs.... This is my code:

    class Program
    {
        private static IServiceCollection services;

        private static IServiceProvider serviceProvider;
        private static ILogger<Program> logger;
        private static TelemetryClient telemetryClient;
        
        static void Main(string[] args)
        {
            services = new ServiceCollection()
                .AddLogging(loggingBuilder => loggingBuilder
                    .AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("",
                        LogLevel.Trace))
                .AddSingleton(typeof(ITelemetryChannel), new InMemoryChannel())
                .AddApplicationInsightsTelemetryWorkerService(
                    ConfigurationManager.AppSettings["ApplicationInsightKey"]);

            serviceProvider = services.BuildServiceProvider();
            logger = serviceProvider.GetRequiredService<ILogger<Program>>();
            telemetryClient = serviceProvider.GetRequiredService<TelemetryClient>();
            
            using (telemetryClient.StartOperation<RequestTelemetry>("Archive"))
            {
                Write("-Archiv.Main Execution Started", false);
                var totalDeletedFiles = 0;
                try
                {
                    using (var unitOfWork = new DataConnector().UnitOfWork)
                    {
                        jsonTemplate = ConfigurationService.GetConfigValueByConfigCode(unitOfWork);

                    }
                }
                catch (Exception ex)
                {
                    Write(ex.ToString(),true);
                }
                finally
                {
                    Write("Total Deleted Files: " + totalDeletedFiles, false);
                    Write("-ArchiveOldSMBFiles.Main Execution Ended", false);
                    telemetryClient.Flush();
                }
            }
        }
    }

I have also made the changes in app.config file's property: enter image description here

After following every step as guided by the microsoft document. I also manually key and values to application settings in azure (screenshot attached below). enter image description here

Now the issue is after doing everything I am still receiving the same error:

[06/21/2022 10:04:23 > fa1ef8: SYS INFO] Status changed to Initializing
[06/21/2022 10:04:28 > fa1ef8: SYS INFO] Run script 'WinSCP.exe' with script host - 'WindowsScriptHost'
[06/21/2022 10:04:28 > fa1ef8: SYS INFO] Status changed to Running
[06/21/2022 10:04:32 > fa1ef8: SYS INFO] Status changed to Failed
[06/21/2022 10:04:32 > fa1ef8: SYS ERR ] Job failed due to exit code -1073740771

I have added application insight and but I still can't find the reason for failed webjob. Is there any way to fix the failed issue?

Just for the reference i have attached the screenshot of stack settings as well: enter image description here

Surprisingly Things ware working perfectly fine in local environment.

Psychonaut007
  • 167
  • 3
  • 13

0 Answers0