I have c# console application which is using for some long running task. In my local system I am executing it from ASP.Net MVC 5 controller by System.Diagnostics.Process class. Now we are going it to implement it into azure as our site is deployed in azure in development mode.
I am new to azure so don't how to do it.However study several article I have found that I can upload my console application as web jobs. I can run web jobs as trigger i.e. ondemand.
But now my question is how can execute this web job from MVC controller as I need to pass some argument from controller?
Currently there is no direct link between WebSite and WebJob, even though they are executed in the same application pool. And the best way would be to post a message to a queue from you MVC app. And on the other end have your WebJob to check for the queue for new messages. Just like Andres already said.
This will not be instant, but easy to implement and cheap.
If you need instant reaction from your console app, you'll need to implement your background tasks as Worker Roles and deploy as a separate VMs, and have there some sort of network communication going on, so you can always reach out for your worker role via TCP.
You can set up your web site to push an item to an Azure Queue, and then have your web job be triggered every time an item is pushed to the queue.
There is some information, including code samples for how to do that on http://www.asp.net/aspnet/overview/developing-apps-with-windows-azure/getting-started-with-windows-azure-webjobs.
Related
I have an architectural question with signalR
Let's say I have a web app (pure front JS) that use a web api and the web app query an API that do a long task and want to be notified when the task is finished.
So the web api create a fire and forget task, and we use SSE with signalR to notify the web app. It's working. Great, thanks to signalR.
But now, I want the long task to be run in another process, let's say with a msmq based system.
So, the web app query the API, the web api create a message, and the msmq service process the message asynchronously.
Can the msmq service hosted in another process (maybe another machine !) notify the web app that the task is finished ? It can be possible to put the connection id in the message, but the service can be able to send the notification ?
I would use a servicebus, you can then use this library to forward the message directly to the clients.
https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy
We're building a real-time Web-based monitoring system for .NET applications (ASP.NET and Windows executable). Those applications can start a long-running operations and statistics are displayed in real-time on Web page.
For ASP.NET ones we found SignalR a perfect solution: Long running operation (even caused by simple WebForms form postback) periodically call JS client-side functions via SignalR RPC to update monitoring page. But we hit 2 caveats:
In ASP.NET we need to monitor several different apps located in several different virtual directories. How do we push data from those different apps onto a single HTML monitoring page?
Another app is a .NET Windows console executable that runs periodically on a schedule. How do we push its run-time statistics to the same monitoring HTML page? One thing comes to mind - have EXE store temporary statistics in a DB and have client pull same data from the DB, but we'd like to avoid polling. Another - periodically at a given intervals the EXE would call the WebApp, passing the data - and WebApp would pass it to client via the same SignalR call. But are there better ways?
One architecture that I've used is a small monitoring collection service, with embedded monitoring clients in every monitored application, Asp.net, Windows desktop app, console app, Windows service, or otherwise.
The collection service is always running. A webapp then connects directly to the service and requests the state of all monitored apps.
Monitored apps run some small embedded client that feeds back application-specific metrics to the monitoring service. The client can either provide data on events or timers, or the monitoring service an ask for it on a timer itself.
With this, we have a unified monitoring architecture - everything that runs just talks to the monitoring service to send updates, and the health viewer clients just ask the service for data using a unified protocol.
It's basically the Application Server pattern applied to monitoring, and takes a couple cues from the design of SNMP.
Very new to SignalR, didn't realize it has multiple clients for different platforms. We will go with SignalR .NET client for all the apps - they will all talk to main SignalR hub directly invoking server-side methods, which in turn update monitoring page.
We have this Pub/Sub system that you subscribe to via a callback mechanism in C# to recieve events from various things that happen within the database. This subscription has a callback signature attached to it that allows for the Pub / Sub system to callback any subscribers it has and notify them of the change on that Callback thread.
We are taking our windows application and migrating it into a web application. In doing so, I need a way to update this Web Application (The clients) with information from this Pub / Sub. I want to use SignalR, but not sure where to host it. I assume if I host it on the same Web Application as the Client, it won't be able to subscribe to the pubsub due to it not being able to do background threading.
Currently, I have it in a Console application hosting the SignalR server on a specific port. Obviously this is for testing and not ideal for a larger scale.
My question is.. is it really safe to be hosting SignalR outside of IIS? should I put this in a Windows Service? Web Service somehow? Can it go in a Web Application somehow?
I'll try to make a long story short:
I want to call a method on a hub in a web application from a core assembly in my application. Reason being is that I have a number of applications that all eventually call into core and trigger events (think mobile web, admin site, api, etc). I want to notify users of the desktop site of events as they happen, using SignalR.
To spike this, I created a 4-project solution. A core project with the hub proxy. A web app with the hub. Another web app without the hub. And finally a console app.
If I call into core from the console app, and try to send a message to hub clients using the proxy, everything works great. However, if I try to call into core and use the proxy from one of the web apps, the execution hangs at the call to connection.Start():
var connection = new HubConnection("...");
var hub = connection.CreateProxy("Spike.Hub");
connection.Start().Wait();
Is the SignalR.Client stuff not meant to be used from within a web app's app domain? Why does it work as expected in the console app, but not from a web app?
Update: I hooked my spike into the SignalR source and when running from one of the web apps, execution hangs at line 130 of SignalR.Client.Connection. The _syncContext for such a connection is an instance of AspNetSynchronizationContext, and when calling its Post() method, everything stops.
There's a bug in the SignalR.Client and you found it :)
My web application is an SMS service that sends out SMS messages using an external library.
I would like to know if I can send a specific asp function using any scheduler method for asp.net?
Example would be like the web user is able to schedule a specific message to be sent everyday.
What I've found is mostly for scheduling specific webpages to run or process which is different.
To start:
Quartz.NET - Enterprise Job Scheduler for .NET Platform
Quartz.NET is a full-featured, open
source job scheduling system that can
be used from smallest apps to large
scale enterprise systems.
Combine Web and Windows Services to Run Your ASP.NET Code at Scheduled Intervals