How to handle background and schedule task with asp web api - c#

I have a saas web application using asp web api hosted in azure. I need to schedule some tasks to:
Generate monthly/yearly billing
Run recurring sql script
Send daily summary to users by email
Any recommendation or pointer on how i can do this? Should i create another app or can i host it inside my web api app?

If you want to have a reliable tasks scheduling wherein you can apply time interval depend on your choice, I recommend Quartz. Quartz allow to add/edit/delete/etc a scheduled task easily, manageable and no CPU overhead.

This is what Azure Web Jobs are for - running background tasks. It is a feature of the Azure Web App your Web API is running in. You can set it up as a scheduled job using the Azure Scheduler. How to do this is also in the link I provided.

Related

C# ASP.NET MVC: develop app with running tasks and ASP.NET MVC web UI to control/monitor it

I'm going to develop an application which is in charge of running tasks which may take several days.
I want to develop a web application as UI for it.
This web application is in charge of starting/stopping/pausing tasks and also it should report the progress of task whenever I login back to the application.
I already developed many desktop / ASP.NET MVC web applications however I have no idea which .NET component or technology should be used for developing such application.
I guess my application should be composed of two main components:
The part which is running long-running tasks (may something like a service and I don't know how services are implemented in C#).
A web-UI which binds to this services and control/monitor its activity.
I would be grateful if you can suggest the components which can manage this requirement.

azure webjobs - writing an application vs calling a url

I have a job I'd like to run on my new Azure hosted web app. In the old pre-Azure days, I would create an .aspx page that did the job, then have some service that simply called the url (www.mysite.com/folder/myjob.aspx) on a schedule.
Is there a better way to do this with webjobs? Can I interact with the actual object model of my site or am I restricted to public URLs and the such?
I've heard I can write a full application (.exe) and host that, but I'm wondering what the advantage of that is?
There are a couple of ways to do this
Azure Worker Roles -Create a console application and then spin this cloud service executes the console app or process. https://azure.microsoft.com/en-us/documentation/articles/fundamentals-introduction-to-azure/
Azure Website Jobs - https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/
I think website jobs is what you really are looking for. Build a little powershell or EXE of what you want doing then set it on a website job with a schedule. I don't think there is really much advantage either way, if you are already in the azure cloud this is just another service to leverage. We currently use both jobs and worker roles. Worker roles have the advantage of scaling out if needed.

Have a background process running continously on an MVC4 website

I have an ASP.NET MVC4 website running and now i need some sort of background task that is continously running. But is this even possible?
The MVC4 website is a sort of notifying system. Other websites can register a Callback URL on this website and this website should trigger that callback URL for a specified interval. So, for every hour for example.
Normally the code of my website only becomes active when I visit a page. But in order to make this work I need a way to have my ASP.NET website to run in the background continously. So it can do its checks and make an HTTP call when necessary.
It's important though that other websites can register their own Callback url through an http web request, and not through a socket.
Is something like this possible in an ASP.NET MVC web application? Or do I need a different approach?
Check this out: Easy Background Tasks in ASP.NET MVC
I do not prefer to run continuous jobs in asp.net because of these reasons.
You can use Windows Azure Scheduler for scheduling http requests for a particular URL.
Alternatively you can create a Windows service (example here)
You can also try console app and schedule it using Windows task schedule
Azure Worker Role is also a good option

How to put web service client in wait mode until execute my web service in asp.net?

I've developed a web service in ASP.NET, To process the request it is taking 1 to 10 minutes.But my web service client can wait maximum 2 minutes so how can I handle this situation in ASP.NET web service i.e., how to send a request to web service client to wait for some time.
Thanks in Advance.
In salesforce you're on a cloud platform which you share server resources with others. Their limits enforced so that you'll make efficient and well performing design choices that do not heavily (ab)use resources.
If your service takes 10 minutes, I would opt for an asynchronous setup where your ASP.net service replies to salesforce by invoking the SOAP or REST API or a custom APEX web/restservice.

Quartz.net windows service core concepts

I want to work with job scheduling and browsing on the internet I saw that Quartz.Net is a good option for it. Many blogs show that a windows service must be initialized and my question is: is it always necessary to start a windows service and embed it to run a job scheduler? Is there a way to run a job scheduler without using a windows service, I ask this because I have a access to a hosting that has only a web panel and I don't think it will let start a windows service.
Thanks for reading
Well, a alternative to writing a simple windows service, is to use the inbuilt windows task scheduler, if you have administrative permissions on the machine you would like to configure. To configure a task in Task Scheduler, have a look at the following Microsoft Article
Working with a windows service is very simple too, a good starting point is as shown below
Walkthrough: Creating a Windows Service Application in the Component Designer
I have worked on Quartz.NET and recommend it highly. The best resources that I used when working with Quartz are as given in the following SO Post.
Quartz can also be used in a ASP.NET web application
How to use Quartz.net with ASP.NET
Quartz.net setup in an asp.net website

Categories

Resources