Azure WebJobs get deleted each time I redeploy? - azure

Are Azure WebJobs get deleted each time when I redeploy? I found those WebJobs mysterious disappeared, so I guess maybe it's because I redeployed my app but didn't go to Azure portal to re set WebJobs again.
If that's the case, it is really a trouble to re set WebJobs again and again. Is there a way to automate this?
I deploy from Visual Studio. I read somewhere saying I can put my WebJobs (e.g. xxx.ps1) under App_Data/jobs/continuous/, and then whenever I deploy, the WebJobs will be deployed automatically. I did that, but I didn't see those WebJobs in my Azure portal.

See https://learn.microsoft.com/en-us/azure/app-service-web/websites-dotnet-deploy-webjobs for instructions on how to add WebJobs to your Web App from VS. Note that you don't need to worry about the App_Data/jobs/continuous folder, as that's taken care of by VS deployment.
Note that this is supported for ASP.NET but not yet for ASP.NET Core.

Related

Azure devOps WebJobs fails after .NET 5 Migration

I've got several webjobs that I deploy using an Azure DevOps pipeline. After the .NET 5 migration I have these errors in Kudu
This happened after .net 5 migration but I don't really think it is connected to it. The app service configuration is set to NET5.
I already try these actions:
Manually delete all jobs in kudu and redeploy them
Deploy the webjobs in another app service
Obviously (ironically) in the local environment it works
The fact that they won't work in another app service means the problem is in the devOps pipeline, but I didn't change it. I mean, it builds in net5 right now, that's all.
Could someone know about this type of error? I never encountered something like this in kudu and It's difficult to even search for a solution.
Thanks in advance.
You can add extension on portal or in scm site. After installed ASP.NET Core 5.0 (x86 and x64) Runtime, your issue will be solved.
1. On portal.
2. On scm site.
At the end of the day, we developed a brand new application based on .net 5 and we deployed it to a new app service based on .NET 5.
We didn't install anything to the app service, so it wasn't the problem.
I don't really know what happened.

NodeJs project as a Azure WebJob

What is process to upload NodeJs project as Azure WebJob from Visual Studio.
I want to upload my nodeJs Project to azure as a WebJob from visual studio with out a WebAPP I am not able to find any blogs or articles to progress further.
Any suggestions?
There is an offical tutorial Deploy WebJobs using Visual Studio which you can refer to, but the deployment is within a WebApp.
However, I discovered a new preview feature Azure WebJobs as Api App on Azure new portal. I think it seems to satisfy your needs, please see and try at the link.
Hope it helps.
This question is problematic, WebJobs run always in the context of a WebApp, that's what they are designed for.
In the meantime Microsoft published Azure Functions https://azure.microsoft.com/en-us/services/functions/
which can do mostly the same and more, only problem is you'll be developing more functional (haha) as global objects/settings/environment variables aren't accessible (because there is no WebApp context).

Azure WebJob running old code

We have a bug in our WebJob running in our live environment, I have identified the bug and fixed it, this I can verify in our Dev-environment. I published my WebJob as a "Azure WebJob" to our live environment but the bug i still present. To add to the confusion the bug now just occurs sometimes. So for some reason the old code is running somewhere sometimes.
Can someone please help me understand this?
I had a similar problem. We deploy using a stage environment in Azure and it turned out that the "old" WebJobs (running code with an old version of the entity framework model) where still running on the queue. These jobs where then fetching messages and consuming them. To add to the problem the exception was consumed in a try catch and the status of the WebJob was success.
Check if you have a stage environment (add -stage to the Webapp name) and if so go in to the Azure management portal and stop them.
Note, it is not enough to stop the Webapp, you must stop the WebJobs directly. This is done (in the new portal) under Settings->WebJobs and then right-clicking on the webjobs name selecting stop.
I spent ages looking into this problem. Turns out I had the web job project running in a console on my PC at work! No matter what I did on Azure the presence of this exe running and using the same storage for the web jobs meant that the old code running on my work PC picked up the jobs before Azure did. Easy fix: just make sure no exes are running outside of Azure!
In our case the web app was published to physical path /site/www instead of the default /site/wwwroot, because of this the Azure web portal interface adds the WebJobs to folder /site/jobs, but the webdeploy via VS or Azure are still trying to publish the webjobs inside the /site/www.
More details at Publishing WebJobs with Azure Pipelines

Azure: Can I deploy Web Jobs to a Worker Role?

Azure Web Jobs are a big time saver in that they solve the plumbing of triggers, continuous running, dashboard, etc. But I've only seen them run in Web sites. It'd be great to be able to move them to a Worker Role. Do you have suggestions about how to do it?
I'd personally love to see how they implement it, so that I can replicate it in my worker role, without reinventing the wheel...
The answer to the main question is No Azure WebJobs are part of Azure Websites and only run in an Azure Website context/host.
But Azure WebJobs SDK which is an SDK that allows you to write code that is triggered on Azure storage blobs/queues and Azure service bus queues including some great logging capabilities, can be used outside of Azure WebJobs and so they can run anywhere (locally, VMs, WebRoles).
It is important to understand that Azure WebJobs are a framework that is part of Azure Websites that allows (almost) any console application (and .bat, .php, .js, ... scripts) to run continuously or triggered (manually/scheduled).
WebJobs SDK and WebJobs are not dependent on each other although they work great together.
Also to see how it's implemented go to https://github.com/projectkudu/kudu as it's open sourced (for now The WebJobs part, SDK may be open sourced in the future).
Yes, you can use Azure WebJobs outside of Azure Web Sites. You use the Azure WebJobs SDK to do so. There is a sample on MSDN on how to use the SDK in an console app. It then goes on to host it in a web site, but you can of course host it in other ways. There is another article, "Hosting Azure webjobs outside Azure, with the logging benefits from an Azure hosted webjob" that explicitly talks about using WebJobs outside of Azure. With a little work this should work in a Worker role as well.
I'll stipulate that I've not actually done this myself, but the SDK does make it possible.
I'd also recommend this treasure trove of resources for WebJobs.

Redeploying an Azure WebJob

How do you redeploy an Azure WebJob? I can see in the Azure portal how to create a WebJob and do the initial upload, but the portal does not appear to allow re-uploading changes, am I right?
I've also looked in the Kudu interface but I don't see anywhere obvious there that allows uploading updates.
So when I make an update to a job how do I release the update.
Thanks.
The Azure portal currently doesn't support updating a WebJob but all you have to do is update the files in the correct place on your site which is: d:\home\site\wwwroot\app_data\jobs\{jobtype - triggered/continuous}\{jobname}'
Read more about this here: http://www.amitapple.com/post/74215124623/deploy-azure-webjobs/
As of Visual Studio 2013 Update 3 and Azure SDK 2.4 this is possible from within Visual Studio. Just right click and select Publish on the web job project.
How are you deploying ? If you use then this will generate the code in your solution to deal with the deployment. I am deploying and using this plugin with VS Team Services and Azure and it is working well.
http://visualstudiogallery.msdn.microsoft.com/f4824551-2660-4afa-aba1-1fcc1673c3d0

Resources