how to put azure webjob on hold with out deleting it? - azure

I am not able to find any options to put the azure webjob on hold , Currently we disable our jobs from "Task scheduler" whenever we have a deployment.
But in Azure Webjob I cannot see an option to disable.
I read from some old forums that we can only delete , then we need to publish again.
Can anybody advise on this? if we have deployed the job , to just hold for some hours or couple of days why we need to delete it?
thanks

You can add the below configuration setting to your web app to disable the Webjob.
WEBJOBS_STOPPED - Set this setting to 1 to disable running any job (will also stop all currently running jobs).
WEBJOBS_DISABLE_SCHEDULE - Set this to 1 to turn off all scheduled triggering. Unlike with WEBJOBS_STOPPED, WebJobs can still be manually invoked
For more information you can refer this github link .

Related

I have Triggered Webjob which runs every midnight once, But its seems multiple instance are invoked which duplicates the task performed by them

I have a webjob as below.
I deployed it via VSTS CICD pipeline.
It should ideally run 1 instance and send only 1 email and stop after that but it runs 2 instances and sends 2 emails like below. As it is triggered job i was hoping only 1 instance would be invoked in azure.
Can anyone suggest me over this?
UPDATE
You can check this post which title is Why is TimerTrigger in AzureWebJob is being triggered twice?.
I’m not sure if this bug is currently fixed, you can raise a support ticket to check you logs.
Since TimerTrigger itself is in singleton mode, this error appears in your code currently. I suggest checking your code to make sure that the code is not executed twice, and then add the Singleton attribute to the method.
I'm not sure if this can solve your problem, you can try it.
PRIVIOUS
You can set your webjob as Singleton.
If your Azure Web Sites site is running on multiple instances and you create a new continuous WebJob, the WebJob will run on all instances by default. (Note that a triggered WebJob will run on just one instance selected at random.)
For more details, you can check the offical document. You also can read other related posts.

Is it possible to publish a Webjob as "Triggered" type as well as "Continuous" type

I have a console application that has been converted to a Webjob.
There are a lot of functionalities in the webjob that is required to be run once a every night(midnight).
However, there is also a specific need that the same Webjob should be continuously running to do some jobs and be able to queue the requests from multiple users.
As the most of the processes are the same I don't see the point of creating another console application as type "Continuous".
As we have a continuous delivery in azure( when there is a new commit to git the online visual studio builds and release the web app and webjobs automatically).
How can I manage to tell build or release process to create 2 webjobs from the same console application which one of those is scheduled(Triggered) and the other is "Continuous"?
While I was writing up the question, stackoverflow similar questions highlighted me this question : Azure webjob; Scheduled execution as well triggers by queue
It looks like it would be possible to use TimerTrigger in a continuous type to handle both cases.
I will try to see if that works. Please give your suggestions for this work case.
You should have a single WebJob that is continuous. You can have as many functions that are decorated with TimerTrigger or message triggers as needed to respond to events or execute on a schedule. You are definitely on the right track.

Run on Schedule not an option in Azure Web Jobs anymore?

I am using this - https://msdn.microsoft.com/en-us/pnp_articles/getting-started-with-building-azure-webjobs-for-your-office365-sites approach to create a web job and I am not able to see below screen. Is ‘Run on Schedule’ not an option anymore?
Below is the screen I am getting:
The web job works perfectly on demand but what I really need is to schedule. Any help on this would be highly appreciated.
You can add a settings.job file to your WebJob. This can include a CHRON expression that specifies when the job should run. The appropriate docs are here.
Alternatively, you can use a TimerTriggerAttribute. This is a WebJobs SDK Extension. Docs and examples for doing so are here. Note that if you use TimerTrigger, you'll need to make sure your WebJob is deployed as continuous. The TimerTrigger will wake up and call the designated methods based on the schedule that you provide.

Azure Web Job Missing from the list

I am currently facing one issue with my Azure Webjobs. I have created custom build tasks in TFS that build my solution and copy the files of 5 different console projects to app_data/jobs/triggered/MyProjectName then zip them into 1 file and deploy into my staging slot of my Azure Web App. When I navigate to the slot I can see 4 out of 5 jobs. When I log in to the FTP location I can see all 5 jobs. What is the possible issue, is there a limit on the number of jobs ? I do not think it is the webjob name as I have one with longer name and it is showing fine. The name format is following xxxx.webjobs.projectname no numbers, no special characters. I have tried to rename the webjob did not help.
It was a silly mistake that I made, when I publish to azure I was publishing both Release and Debug folder. The Release folder was my leftover from my previous test with no files. I have removed the Release folder and it all started working. Perhaps, if Azure by default will use Release folder and does not find anything in that folder and if there is Debug folder it should go to debug and leave a note in logs that Debug is currently being used? I hope that helps!

Change webjob from on demand to schedule

We have an azure webjob that was deployed as on demand. Is there a way to change this to run on a schedule without redeploying?
Not a lot of info out there on this.
I tried creating a new schedule collection like this and adding a job to run the existing webjob, but that didn't seem to work either.
I prefer to do this in the GUI portal, but if its not possible, I'll do it in powershell (if it is possible like that).
(Also, if it can only be changed by redeploying, I need to know that and it effectively answers the question)
To easily add a schedule to your triggered (on demand) webjob add a file called settings.job at the root of your webjob with this content:
{"schedule": "the schedule as a cron expression"}
Find out more about this here
Note: it'll only work properly for Standard or Premium sites and requires you to set the site as always on.
In the end the link in the original post I referenced worked. The thing that was missing for me was the understanding that creating a trigger job in scheduler will not affect the run status (on-demand or scheduled) of the web job itself. In my case it stayed "on-demand", but the schedule was in fact running it.
This should point you in the direction on how to do this via PowerShell. It looks possible to add already existing WebJobs to a scheduler.
Create a Scheduled Azure WebJob with PowerShell

Resources