I have created an Azure WebJob in Visual Studio 2015 and deployed it to Azure.
When trying to run the WebJob I get this error:
[03/12/2017 22:47:46 > 070c62: SYS INFO] Status changed to Running
[03/12/2017 22:47:47 > 070c62: ERR ]
[03/12/2017 22:47:47 > 070c62: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.HostingProcess.Utilities.Sync, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[03/12/2017 22:47:47 > 070c62: ERR ] at Microsoft.VisualStudio.HostingProcess.EntryPoint.Main()
[03/12/2017 22:47:47 > 070c62: SYS ERR ] Job failed due to exit code -532462766
[03/12/2017 22:47:47 > 070c62: SYS INFO] Process went down, waiting for 60 seconds
[03/12/2017 22:47:47 > 070c62: SYS INFO] Status changed to PendingRestart
I have tried to search for this error but can't find anything related to this. I don't know if this is an problem in my WebJob code or the configuration of the WebJob in Azure.
Does anyone have some ideas or pointers of where the problem lies?
[03/12/2017 22:47:47 > 070c62: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.HostingProcess.Utilities.Sync, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[03/12/2017 22:47:47 > 070c62: ERR ] at Microsoft.VisualStudio.HostingProcess.EntryPoint.Main()
Firstly, as David Ebbo said, please try to run the same logic outside of the Azure Web App sandbox, and check if it works fine.
Besides, as far as I know, if the WebJobs project missed the referenced assemblies or files, we would get similar issue as yours. For example, my console application referenced Newtonsoft.Json, but I do not include this file when I deploy console app as WebJobs to Azure, I get below error.
The ConsoleApplication13.Program.Main() is entry point of my console application, please check your project to make sure you did not miss some assemblies.
I had solved the same problem by changing the Main()
method slightly.
It is important to leave the following lines at the top of the Main()
.
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
config.Queues.BatchSize = 2; //Number of messages to dequeue at the same time.
config.Queues.MaxDequeueCount = 5; //Max retries before move the messate to the poison.
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(1); //Pooling request to the queue.
config.NameResolver = new QueueNameResolver(); //Dynamic queue name resolver.
JobHost host = new JobHost(config);
After that I searched all the "Console.Writeline()" that I wrote in all the source code and deleted them, because I was thinking that it belonged to the Microsoft.VisualStudio.HostingProcess.Utilities.Sync dll.
After that I deleted all the webjobs configured at the webApp in the portal and published again.
Voilá all the WebJobs were running again.
Now I wrote again the "console.WriteLine" and every continues running well. So I think that the important thing is to have the JobHostconfiguration at the top most of the Main:
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
config.Queues.BatchSize = 2; //Number of messages to dequeue at the same time.
config.Queues.MaxDequeueCount = 5; //Max retries before move the messate to the poison.
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(1); //Pooling request to the queue.
config.NameResolver = new QueueNameResolver(); //Dynamic queue name resolver.
JobHost host = new JobHost(config);
First, remove the web job with error from azure.
Then verify whether Solution configuration is in "Release" mode.
Finally, deploy again.
PS: Hope the web job runs without any errors from local !