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
Related
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.
I'm new to the azure webjob. I have multiple jobs that I hope run at a different frequency. As for now, my solution is to have one single webjob as a standalone project and define the frequency of this job at project level, in the settings.job file.
However, not sure if there is a way to have multiple jobs in the same project and we can have a one time deployment of a single project, yet have each job running at different frequency?
I looked up online, the closest one that I can find is this page, which doesn't seems to work for me. Any help/sample code is appreciated.
To achieve this, we can create a settings.job file in root folder of each web job project as below.
Notice, we need to choose "Copy always" as below
More information about settings.job file, we can refer to: Web Job Types
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.
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.
During development of my webjob i have redeployed it multiple times to Azure. When i visit the webjob dashboard i am greeted by this:
It seems that every webjob deployment gets registered as a new function, deprecating the old one. Searching around how to alter this behaviour (fold all previous functions together with the current one) gives no results.
Does anybody know how to configure the azure webjob dashboard to merge previous functions together if name+arguments are still the same?
The function list/index for a job host exe is based on the fully qualified assembly name. One thing I can think of that might cause the above would be if your assembly name is changing each time you deploy for some reason. Do you have anything like that going on?
Another question: do you have multiple job hosts sharing the same dashboard storage account?