I have created a C# console application that needs to run once every month. The company i work at uses Azure, so I wanted to use a Azure service to run the application. But I have a hard time finding the right service for the job. I have looked at Logic apps, but is unsure if that is the right solution.
Does anyone know a Azure service which is able to run a C# console application once every month?
Not sure how complex your console app is, I guess it just starts and does a simple task. This is what Function Apps are for. They consist of a single function that can be run on schedule, or triggered by a system event.
Here is MS Docu on how to run it on schedule: https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-scheduled-function
It does not answer your question directly (how to run a console app), but if you are asking about Azure, I'd say it's a good Azure way to achieve what you want, and is not very far from a pure console app. Azure will care about launching it and the environment.
Function Apps can also be tested locally run like a cosole app.
You can use Azure Automation Account for these needs.
It also allows you to run scheduled tasks directly on premisses.
Function app is definitely a better and more flexible solution.
You can use Function apps to run a console application (any exe for that matter).
Please check this code sample. It uses an HTTP trigger to kick off the execution but in your case you could use a Timer trigger.
If you want to skip the process of downloading the binary from an external location, you could even copy the exe file to your function app folder. The steps are here
Related
I'm looking to create a Function App in C# with a timer trigger which will occasionally (e.g. once per day) manipulate our Salesforce environment. Specific tasks may (will) include:
(Re)setting trace flags for Users and Apex Classes.
Downloading the debug logs so they can be persisted (and searched).
I'm hoping to do this without reinventing too many wheels.
As Sfdx Cli should be able to do these tasks from the command line, I'm wondering whether/how I can manipulate Sfdx from an Azure C# scheduled function app.
How can I make Sfdx available to whatever "serverless" server is hosting the Function App?
How can I tell the Function App where to find it on this server?
How can I tell the Function App to do something with it by providing some command, including arguments, as might be provided through a command line?
How can I capture any response(s) which may be provided as console/terminal output, that these response can be parsed?
When I use Sfdx Cli to download logs from Salesforce, how can I either store them somewhere (perhaps on blob storage instead of local file storage) or intercept them so the application might do something with the data?
What you can do is dockerize the function and then deploy it.
This will help you to run the console app in the function.
Also, you will get all the desired functionality of the function while the dockerization will help you run console app on it.
You have to bundle the console app with the function app.
refer the following documentation on deploying using docker.
I have to make a program that watches a location on a computer for files and then converts them when new files get put into a specific folder.
Now my question is what kind of Project would be most appropriate for this?
Is ASP.NET MVC Web Application a good choice or would I be better of doing a Windows Service or WCF Service or even Console App?
My app needs to run on the same server as another MVC app already runs, and I need to access some database to keep track of what files I have converted.
You could utilize Windows task scheduler to periodically run an exe file. In this case the project would be a console app.
A better solution would be to use Windows service. See comments from David & as.if.i.code (tnx btw, you learn something new every day :)
I'm doing my first steps on Microsoft IoT on a Raspberry pi 3.
I was able to deploy and run the application.
However, I need to run two application, one is going to write a file with events, and the other is going to pick up the batch and send it to Azure.
I was wondering what file location/ path should I use, as the App path changes with every new build.
Should I develop as a single app instead?
Kind Regards,
Juan
Not sure if it fits your scenario, but sounds like the purpose of a second app is to pick up some parameters and send to Azure. So, maybe it's time to consider using App Service.
In general, App service is a background task that runs in the backgound, with on-time event triggers. You can pass in parameters when your app triggers the service, and gets return data when necessary.
If hope it helps.
I have a service which should open an exe application ( C# Application ) based on certain conditions. When the service is started in debugging mode ( Visual studio ) it opens the application. But when it is installed as a service, it does not do so. It fails to open the application. Why is this happening?
What you're trying to do isn't directly possible under normal circumstances - simply launching an app in a new process from your Windows Service code is not going to interact with the GUI of the currently logged in user I'm afraid.
There are ways of communicating between a service and the GUI however.
This discussion might point you in the right direction.
Based on your comments, I think what you are really looking for here is a normal userspace application and a scheduler. You might want to use Windows' own scheduler to run the application every monday, if it is an always-on box, or place the application in Startup. When the application runs, it should check the current day of week, and if it is monday and the application has not previously run this day, the application should start. If not, you can safely terminate the application entirely.
Thanks for the answers! I found out a solution for it and im posting it here.
I created a dummy app which is hidden on startup and it does the exact same function that the service was intended to.
1.create a dummy app (copy paste code from service to form application)
Hide it after start up.
2.start the application right after installation.
3.add registry key so that it starts up after a system reboot.
in simple words, clone service behavior.
So, this question has been asked lots, and i have seen many different answers, but nothing finite or absolute for my scenario.
_
What I want to do:
We have a website, with a community of users.
In the admin section of the website, there are buttons to run the following functions:
Email all the users our weekly newsletter [Thursday 4pm],
message users that day's information [Daily 6pm],
post to facebook through facebook connect [Daily 8am and 6pm],
etc, etc. (There will be new requirements coming soon too, but they will follow the same principal)
_
All I want to do is to run these functions automatically, so a member of staff does not need to go to the website, login, then click each of the buttons at the set times.
That is, effectively, have the server click these buttons automatically, at the set times mentioned above.
_
I have seen suggestions for building a service with a timer built in, which will call each function, or use windows task scheduler, build an exe / com etc, but i get the gut feeling it should not be this complicated.
We have the code already written to actually do the tasks in a .net web page, and using some custom built classes etc.
I just do not know how to automatically call these functions at the desired times.
_
Server Info:
Dedicated server running Windows Web Server 2008 R2 (64bit)
Development Enviro:
Visual Studio 2010 SP1, using .NET 4.0
_
Thank you in advance for your help.
Kindest Regards,
Del
Splitting out the code into separate exes/dlls that can be called from the Windows task scheduler as well as your application is the way to go.
There's no sense in re-inventing a scheduler inside your application when one exists in the operating system you are running on. Particularly as your application is a web application which should be doing web things not server things.
The added advantage is that you have made your application more modular and easier to upgrade.
By definition, web servers respond to requests. This fundamental design manifests in all kinds of ways, such as application pools being shut down after a period of inactivity. For this reason, it is not a good idea to execute time-dependent code inside the context of a web server, because it is difficult to guarantee that the code will actually run (without jumping through a lot of hoops that have other negative side effects). Instead, an external time-dependent mechanism should send a request to the web server to execute these functions.
You said that you didn't want to use Windows Scheduler or write an external exe because "it shouldn't be this complicated"; but I don't see what's complicated about having a scheduled task call a web service.
Well, though I agree with other answers cheering for windows task scheduler and that website has nothing to do with scheduling tasks (it can be the source of input parameters, not the task runner itself), you could try using scheduling library like quartz.NET to schedule and run your necessary processes in the background.
Download cURL - a command-line HTTP request utility. Use this utility from task scheduler to call your web page / web service with the specific query string required to execute your functions.
http://curl.haxx.se/
This isnt very secure - anyone that knew the correct query string could cause these functions to execute - but it gives you the general idea. In my opinion its much safer to write a console app that uses your assemblies to directly execute your functionality. Call the console app from task scheduler.