How to deploy a webjob through CI in VSO with vNext - azure

I'm trying to deploy a scheduled webjob through CI and vNext tasks in VSO.
I followed the steps in the following tutorial to deploy a webjob along with a web app ("Enable automatic deployment with a web project"):
https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/
I succeeded partially: the webjob gets deployed along with the web application. However, it is marked as On Demand instead of Scheduled (or whatever the proper status is). I can run the webjob manually and it runs just fine. I checked the files webjob-publish-settings.json (in the webjob) and webjobs-list.json (in the web app) and they seem to be alright, judging from the tutorial.
Am I missing anything? Thank you.

You can use the cron expression to create the webjob scheduler if your app is running in Basic or High mode. Refer to this link for details: Create a scheduled WebJob using a CRON expression
Otherwise, you need to enable continues delivery of Azure Webjobs.
More reference: Deploy your WebJobs projects with your Azure website using continuous delivery

Related

Deploy and schedule console application in Azure

I got a web scraping tool developed using C# console application and Selenium Chrome driver.
Is there an option to deploy and schedule to run daily in Azure platform?
Is there an option to deploy and schedule to run daily in Azure
platform?
Yes. You can deploy your console application project to a web App service as an Azure Webjob.If you're unfamiliar with Azure Webjob, you can see details in this wiki. But I'm not sure whether your application can still work well, because it depends on your application itself and running environment sometimes.
You can use Visual Studio to deploy it. You can follow this tutorial to achieve that.
If you have already created a Webjob and want deploy it to Azure, you can refer to this blog.
Schedule the Webjob:
When you deploy the Webjob, you can use CRON to schedule your Webjob.

Azure WebJob running in WebApp without a JobSchedule/JobCollection - deploy with template

Right. So this article: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ mentions that you can "You can run programs or scripts in WebJobs in your App Service web app in three ways: on demand, continuously, or on a schedule. There is no additional cost to use WebJobs."
Which is great, the free-alternative is a Scheduler Job Collection
with a job, but you're limited to running it every hour. So being able to run the webjob as part of the webapp, and on a higher frequency is what we need.
However, I'm really struggling to find any way of automating this process. Using the Azure portal to add a web job works fine - but the "automation script" generation tool doesn't generate a json file which includes anything about the webjob - so we'd always have to manually create it.
There are examples of custom templates for automating the creation of webjobs - but they all create said webjob as part of a Scheduler Job Collection, where we are limited to the hourly execution.
To summarise: I'm looking for a way of automating the creation of a webjob, linked to a web-app (such that it doesn't incur extra costs).
Any help would be much appreciated.
WebJobs are deployed by folder convention (as described here), so deploying a WebJob is no different from deploying a Web App. It's simply a matter of getting the files in the right place.
Specifically, triggered WebJobs (manual or scheduled) go under site\wwwroot\app_data\jobs\triggered\{job name} and continuous WebJobs go under site\wwwroot\app_data\jobs\continuous\{job name}.

Octopus deployed continuous WebJob not running simultaneously in two locations

I have a continuous webjob that needs to run two webapps in two locations on a TimerTrigger. When I deploy the webjob from Visual Studio to both locations everything works well and both webjobs run at the same time.
Now I'm ready to start deploying this with Octopus-Deploy. I have successfully created a plan with two steps that does that and puts the assemblies in the correct location under the web apps (app_data\jobs\continuous\{jobname}) in Azure. The problem is that only one webjob executes its job at a time even though both webjobs have a status of Running. If I stop and start the one that's executing, the other webjob starts executing its job while the one I turned off/on has a status of running, but doesn't ever execute its job. Also, if I redeploy just one of them from visual studio, they both execute their jobs at both locations again.
I'm not doing anything with Singletons and have actually tried turning it off by using a 'settings.job' file with {is_singleton: false}. Is there something Octopus is doing with the package that makes Azure think the webjob is a singleton?
My guess is that the issue is caused by using the same storage account and host id for both of the apps that you deployed. When you do that, the WebJobs SDK views it as a single Web App that has been scaled out to two instances, and makes sure the timer is only run on one of them.
The simplest solution is to use a different storage account for each app.

Deploying a scheduled webjob to Azure Webapp without Visual Studio

I am having a hard time piecing together the documentation on Azure webjobs, so that I can deploy a scheduled WebJob to my WebApp without using Visual Studio. In my case the code is on GitHub and I want the deployment to be fully inititated by the webhook to Azure.
The documentation mentions that I can drop .exe into: \App_Data\jobs\continuous\webjob1 of my WebApp. I have created a post-build script that does that, which works fine. It's discovered and displayed in the Azure manager. But I can't make i scheduled.
Take a look at the following post to easily add a schedule to your WebJob.
Note that the path you are deploying the WebJob to \App_Data\jobs\continuous\webjob1 is actually for a continuous WebJob, you need a triggered WebJob that would go in the triggered directory \App_Data\jobs\triggered\webjob1.
Then you just add the settings.job file with the schedule property in the form of a cron expression (with 6 fields).
For example - {"schedule": "* 0 * * * *"} (once an hour at 1:00, 2:00, 3:00, ...).
Note that it requires your site to be "Always On".
Another option is to use Azure Scheduler service which you can configure from the current Azure Portal.

How to deploy azure webjob using Octopus

How to deploy azure webjob using Octopus deployment?
For me, octopus says it is deployed to azure but not able to see my webjob under the website.
Can anyone help how to achieve this?
There is a documentation on how to deploy a web job from octopus Azure Web Apps.
I was using Octopus Deploy 3.0 and in my case, I only wanted to deploy a webjob without a web app:
I've chosen Azure Web App Deployment Target:
And in the deployment section, specify the physical path.
For continuous job you can specify a path like that:
For triggered job you can specify a path like that:
have you try to publish your web jobs to your website using Visual Studio?
One way to verify whether your web jobs has been deployed to your website/web app is to access to the Kudu site of your website.
https://.scm.azurewebsites.net/azurejobs/#/jobs
Go to Debug Console (CMD), try to access D:\home\site\wwwroot\App_Data\jobs
and see if there is any web jobs underneath it
You can try using the nuspec to package your artifacts.
Put you web jobs under App_Data\jobs\trigger{webjob} or App_Data\jobs\continuous{webjob} based on your job type.
And then deploy using Octopus, Azure will be able to recognize it.
This might help:
http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/#.VVRSANNViko
Good luck

Resources