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?

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

ssh: connect to host x.x.x.x port 22: Connection timed out

Did you just change some network configuration on your Ubuntu virtual machine and now you’re not able to connect? Here’s how you can fix the ssh connection.

how to fix – ssh: connect to host x.x.x.x port 22: Connection timed out


I spinned up an Ubuntu (18.04.3 LTS, Bionic Beaver) virtual machine on Azure for an experiment. I was setting up apache2 server (for a web server) and in the process I made some changes in network configuration (I literally allowed IPv4 & IPv6 in the firewall, that’s all). While making those changes I got a clear message on the screen that the current network may be unstable but it continued to work flawlessly until the connection was closed. The very next day and I wasn’t able to connect to the Ubuntu VM using ssh on the same IP/Port. Though the web server was responding well at port 80.

What I tried first?

I had forgotten the warning message I received earlier, about the network instability, while making the changes in network configuration and now I had this. So, at first I jumped on to Azure Portal and I tried restarting the virtual machine, it didn’t work. I removed and re-added the allow port 22 under the Networking tab, it also didn’t work.

How to fix “ssh: connection to host X.X.X.X on port:22”?

So, I did some digging on the internet and I found two lines of script required to fix the connection. It’s a firewall issue, it gets updated while changing the network configuration. Thankfully, Azure Portal offers a console to run shell scripts from the browser itself.

You can find the “RunShellScript” option under Operations > Run Command on the virtual machine’s setting blade. I believe all the cloud providers offer similar connectivity for the VMs using which you can connect to the VM using ssh or RDP for recovery purposes. Please refer to the snapshot below

RunShellScript from Azure portal

After I ran the two above lines, I tried to connect the virtual machine on the ssh and the connection was successful.

Edit: I later discovered that the commands in the browser console above can be run without sudo prefix.

You can later verify the status of the firewall using “sudo ufw status” on the same window.

Microsoft Azure offers a wide range of tools to troubleshoot network errors, check out the documentation for more details

This resolution may apply for other Linux OS as well but I haven’t verified. You may want to read more article Microsoft Azure on DevsDaily.

I welcome any suggestions or feedback to this post, Happy learning!

HTTP Error 500.0 – ANCM In-Process Handler Load Failure

With ASP.NET Core 2.2 support added to Azure Web Apps – it’s a bit tricky to host multiple applications using Virtual Directories. If you just publish your web apps using Visual Studio on different virtual, directories – not more than one will work at the time I’m writing this.

You need to make certain changes in order to get this working.

Let’s try publishing some core apps on Azure Web App in under virtual directories and see how it looks like. I’ve set up a Web App on Azure for this purpose with below configuration on Azure portal:

I’ve created an Empty ASP.NET Core Web App (Ver 2.2). My plan is to change the text and publish apps separately on the root directory, and on two different virtual directories, making three apps in total on one azure web app.


My plan is to the default “Hello World” text to “App1 on Virtual Directory” and “App2 on Virtual Directory” subsequently and publish each on a different virtual directory. I will have to map two folders as virtual directories in order to get them working which can be done either before or after publishing the applications.

Downloading the Publish Profile helps quick publishing of azure web apps.

I added two virtual apps to the main apps at “/app1” and “/app2” virtual paths. So we have three apps now. Next I will publish the apps on the two virtual directories changing the default text.

I published the default application in Root Directory and it started saying “Hello World”, then I published the same app with changed text on App1 virtual directory but it failed to start with the following error, Same response for App2 on the next virtual directory. :

HTTP Error 500.0 – ANCM In-Process Handler Load Failure

ASP.NET Core 2.2 and later has an In Process hosting model on IIS (set as default). In this model the app is hosted directly inside of an IIS Application pool (IISHttpServer Web Server), and it doesn’t proxy to an external dotnet.exe (instance running .NET Core native Kestrel Web Server).

.csproj file is where you can see the hosting model

Currently, only one app can run in one app pool (one azure app).


Host the apps as OutOfProcess model

In this case – all the apps are required to be hosted as OutOfProcess model. When you publish the application it generates the web.config file with all the set configuration.

Open the .csproj file and under Project > PropertyGroup > AspNetCoreHostingModel, change the value “InProcess” to “OutOfProcess”. Be careful with the casing here!

change “InProcess” to “OutOfProcess” in .csproj file

Note that all the apps has to be deployed in “OutOfProcess” model, otherwise no application (inside the given azure app) will run. This change has to be applied in all the projects you’re publishing under one azure app.

My apps start working as I change the hosting model from InProcess to OutOfProcess and publish them.

This way it enables us to host multiple applications inside a single Azure Web App.

Note, that OutOfProcess drastically reduces the throughput as it proxies the request between Kestrel Web Server running dotnet.exe and IIS Web Server.

Azure DevOps

Azure DevOps is a suite of services for Managing, collaborating, building and deploying code.

Azure DevOps Organizations are the starting point for Azure DevOps. You need a Microsoft account to sign-in. If you do not have one – sign up for a free account. Organizations are free up to 5 team members. An Organization can hold many projects.

Sign in and create your first Organization and add a project.

As you sign-in, it will create an Organization by default based on your login email. If you do not like it, feel free to change the Organization name by navigating to Organization Settings -> Overview. You can either keep the existing Url with the new organization name or change it along as well.

Once created, you will be navigated to your organization. The Url would be be like <your-organization-name>

Here’s the first screen inside a newly created organization:

For the demo purposes – I’ve added a “HelloWorld-Project” project inside “helloworld-demo” Organization.

Note: the screens are subject to change hence by the time you read this blog, it is possible that the option has changed it’s place.

You can set project visibility to be public or private, version control (Git or TFVC) and the Work Item Process template (Agile/CMMI or SCRUM) to manage the tasks across the project board. I will go with Git version control and Agile work item process.

You can manage teams and add members to it under Project Settings at the bottom in the left.

Azure DevOps offers a group of services facilitating everything required to manage, build, and deploy a project from start to finish. Following services are available under the Azure DevOps suite:

  • Azure Boards, for work management
  • Azure Repos, for social collaboration
  • Azure pipelines, for building and releasing the project
  • Azure Test Plans, for Manual Testing and Load Testing
  • Azure Artifacts, for sharing different packages

Watch this space for detailed articles on the Azure DevOps services in my upcoming blogs.

Thanks for reading 🙂

Do you think this post can be improved? Please leave a comment.