How to run Console Applications on Azure Pipelines

Learn how to run console apps on Azure DevOps without hosting!

I came across multiple similar questions on StackOverflow for running a Console Application on Microsoft Azure. Answers mostly suggesting running the console app on WebJobs. Here I’m sharing another way of running console apps on Microsoft Azure DevOps, with Azure Pipelines.

[Azure]: Run your console app on Azure Pipelines

If you have a subscription to Azure DevOps, you will be able to run your console app. Upload your console app and create a pipeline to run a script. Add the command and necessary arguments if any and run the pipeline.

Note: At the time of writing this post I'm not sure of any downside of this approach, will update here if I find one.

What did I do?

Search and buy domains from Namecheap. Lowest prices!

In Azure DevOps, under one of demo Organizations I created a test project (“TestProject”), and initialized the empty repository with file.

empty repository initialized with file

Created a new C# Console App Project in Visual Studio 2019. “HelloWorld-Console”.

HelloWorld-Console app

Published the executable. While publishing, I changed the deployment mode to “Self-contained” and enabled “Produce single file” option. It produced 2 files in the publish folder:

  • HelloWorld-Console.exe, and
  • HelloWorld-Console.pdb

publish options
publish output

since .pdb file file contains debugging info, I had my concerns only with the executable (.exe) file.

I tried uploading the file in the Azure DevOps repository directly from the browser but the browser has a limitation of 20 MB max per file. So I chose to upload it using the git tools.

I cloned the repository on my machine, copied the executable (.exe) in the repository from the publish folder, staged the changes, committed and pushed it to remote repository.

Uploading the Console App to Azure DevOps repository

Finally, I setup a pipeline with a “Command Line Script” task to run the executable. Since it’s a Windows executable file, I set the Agent specification to “Windows-2019”.

In the “Script” block I just entered the file name of console app as it didn’t require any additional parameter to run.

Pipeline with “Command Line Script” task
Agent Specification set to “Windows-2019” for the pipeline

The pipeline ran just fine and I could see the output from the console app in the logs: ?

Command Line Task output in the pipeline log

In the pipeline, I extended the command to save the console app output to a text file. I added one more task to publish the output file in artifacts directory. I kept the artifact’s name as “pipeline-run-$(Build.BuildNumber)” in order to have different folder for every run, containing the output text file.

Extended the Command Line Script’s script to save the output in helloworld-output.txt

added “Publish Pipeline Artifact” task to publish the console app output file in Artifacts folder.

Now for every run of the pipeline, I could see an artifact produced, containing the output text file.

successful run with an artifact
the output text file contains the expected “Hello World!”

So, with that I’m wrapping this post but you can always extend the pipeline with tasks to share the console app’s output to email, or other channels. This way you can run your console apps without an App Service/WebJob/Azure Functions. The Azure DevOps platform will run the console app for you for free I guess, until they start charging. ?

Further, you can extend the pipeline with scheduled trigger to run it on scheduled time as well.

? Did I miss anything or you have any feedback? Please help me fix it by dropping a line at, thanks!

Happy Learning!
/Sunny Sharma

Shared Hosting with Namecheap. Free .Website domain & WhoisGuard

Leave a Reply

Your email address will not be published. Required fields are marked *