We have an existing method in an existing controller that we'd like to call at a specific schedule (eg "daily at 2am"). The application is an MVC3 application running on Azure as a web role and we don't want to create, maintain and pay for an entire new role (worker role) just to run one small piece of identical logic.
Is it possible to schedule a controller method to trigger off at a specific scheduled time in the future? Also, would the same technique work in regular ASP.NET webforms?
Assuming you can just call this controller action with a URL, you can just...
1) create a PowerShell script to "ping" the website:
http://learn-powershell.net/2011/02/11/using-powershell-to-query-web-site-information/
2) Schedule that PowerShell script via remote desktop in a Scheduled Task that runs at 2am
You could also write a deployment script that automates #2.
You could use Phil Haack's WebBackgrounder as described here.
I've successfully used Cron jobs in a Shared hosting environment where scheduled tasks/powershell wasn't available.
Here's a website explaining more about it
Related
In my job we are building Web Apps that rely on a common Enterprise class. This class has a method that sends a request to our server every time the app_start or app_end event triggers so we can monitor the status remotely. But we are now requiring that at least once a day the web app reports its status, a bit like telemetry. I don't know how to accomplish this, so far I have found some options, but some have limitations:
Use hangfire. I don't like this since it requires to setup a Database or add more tables and install a new Nuget package on each project, but could be my last option.
Use a Windows Service that reads databases. This could be less work but it can't access the Web App web.config code
Use a Javascript tasks that sends an AJAX request. This requires to have an open web browser and is a big risk.
I'm looking for a server side approach that could allow to set to trigger an event or function at 1am.
I would got with Hangifire.
It is dead easy to setup and very reliable.
You don't need to setup the database, you might want to check memory storage:
https://github.com/perrich/Hangfire.MemoryStorage
Also check:
What is the equivalent to CRON jobs in ASP.NET? - C#
You can use FluentScheduler instead of Hangfire (it is more lightweight).
Instead of a Javascript task that sends an AJAX request you can use a WebJob or an Azure Function.
I'm working on a POC to automate downstream processes in external systems based on JIRA processes and have hit a wall with the API. It appears to have great integration for pulling data about tickets out of JIRA and for the ability to externally generate tickets into JIRA.
However I don't see how to trigger external calls as a part of my workflows. For example if a ticket should be prevented from being routed to the next stage of a workflow without accessing a database to ensure availability of inventory first how could I do that in JIRA?
Based on attributes in the JIRA ticket upon final completion of the workflow we'd like to send a JMS or REST message or possibly update an external database. Is this possible?
Thanks all in advance for the help!
If you want to do a "before" check, use a Validator on the Workflow Transition.
I strongly suggest deploying the (free) Script Runner add-on. There you can implement a ton of things. For example, you'll get a new validator option "Script Validator", where you can specify a Groovy script that decides if it lets through the transition or aborts it.
I have an action method inside a controller class , that do a Sync . currently the user can manually call this action method, by clicking on a button from the view.
But my question is whether I can create a job or bath that runs on the host server let say each 1 hour and call this action method.
Currently I am using form authentication, and i am hosting my asp.net mvc web application on IIS 7
Thanks
There are a few ways of doing this.
Refactor the code out of MVC and put it inside a WCF service, configure this service to make use of http://quarts.net/ and setup the schedule to run. This service can then be hosted inside IIS.
You can also create a Windows Service (NT Service) that makes use of Quartz.Net. This service can then be installed on the production server.
You can create a batch file and use a windows task to fire off an exe that will run the job.
I'm looking for a scheduler for asp.net mvc. For example I want to send notification email weekly and also check expired date of the contract. Please suggest me solution in asp.net mvc.
Thanks in advance.
You may checkout Quartz.NET.
For scheduling functions, you might be better off using a Windows Service or a console app which is kicked-off by a scheduled task, rather than a web app. Web applications work best by responding to immediate inputs, and are not usually suited for handling actions that must start on their own. If you try to run a scheduling service as a background thread in a web app, you may run into problems when the app pool is recycled, or if IIS decides to kill your thread.
In any case, like Darin said, Quartz.NET is a good open source scheduling framework.
Have a look at my answer to the same question:
Scheduler for ASP.NET?
For the non-critical scheduled tasks you can definitely use Quartz.NET from your ASP.NET MVC project but you need to be sure to keep application alive most of the time what is not the case for the low traffic websites.
To keep application alive you can use http://www.uptimerobot.com/ which will ping your app every 5 minutes and also you will get site monitoring with it.
Look at the blog post for the simple example.
http://asmiki.wordpress.com/2011/05/25/using-quartz-net-enterprise-scheduler-to-schedule-jobs-in-asp-net-mvc-application/
I am looking to use itextSharp to create PDFs in my MVC 3 application, and I will be using Azure. What I would like to know is will this create a problem and does Azure support this function.
You can pretty much run anything you want in azure so it wont be a problem from that prospective. The biggest thing to remember is that you probably won't want to perform such a heavy operation in a web role. A worker role is much better suited for this type of task. You could setup a system where you use Azure queues to request PDF jobs and the worker role reads the queue and runs these jobs. You shouldn't have any problem with that approach. Check out the Azure Toolkit to get you started: http://azuretoolkit.codeplex.com