Azure WebJob deployment issue

1.5k Views Asked by At

I have a basic Azure WebJob, when i'm running through VS it runs and print the desired output as belown

enter image description here

But when i deploy and run from portal, I'm getting below error.

[07/15/2020 07:23:03 > 8f28d2: SYS INFO] Status changed to Initializing
[07/15/2020 07:23:03 > 8f28d2: SYS INFO] Job directory change detected: Job file 'RedmineSyncUp.exe' timestamp differs between source and working directories.
[07/15/2020 07:23:15 > 8f28d2: SYS INFO] Run script 'RedmineSyncUp.exe' with script host - 'WindowsScriptHost'
[07/15/2020 07:23:15 > 8f28d2: SYS INFO] Status changed to Running
[07/15/2020 07:23:16 > 8f28d2: SYS INFO] Status changed to Failed
[07/15/2020 07:23:16 > 8f28d2: SYS ERR ] Job failed due to exit code -2146232576

I'm deploying through VS.

Here is the my code.

Function.cs

public class Functions
    {
        // This function will get triggered/executed when a new message is written 
        // on an Azure Queue called queue.
        public static void ManualTrigger([Table("log")] CloudTable logTable)
        {
            for (int i = 0; i < 5; i++)
            {
                DateTime dt = DateTime.Now;

                Console.WriteLine(dt.ToString());
            }
          
        }
    }

Program.cs

static void Main()
        {
            try
            {
                JobHost host = new JobHost();
                Task callTask = host.CallAsync(typeof(Functions).GetMethod("ManualTrigger"));

                Console.WriteLine("Waiting for async operation...");
                callTask.Wait();
                Console.WriteLine("Task completed: " + callTask.Status);

                host.RunAndBlock();
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }
           
        }

If i deploy using published package also the result is same.

1

There are 1 best solutions below

2
On BEST ANSWER

It looks like this error is related to WebJobs's targeted .Net Framework.

Can you please see which .Net framework are you targetting? Can you change the webjob's target framework to 4.7 and see if it works?