Running a .NET core application in an Azure Container Instance

  • Per second billing
  • No need to maintain a server (or cluster)
  • Docker for Windows (I used the Docker Toolbox since I could not install Hyper-V on my machine)
  • A .NET Core console application
  • An Azure subscription
  • A Docker account

Step 1: Turn your .NET core console application into a Docker image

FROM microsoft/dotnet:2.0-sdk AS build-env 
WORKDIR /app # copy everything else and build
COPY /OMT.Core/. ./OMT.Core/
COPY /OMT.TaskRunner/. ./OMT.TaskRunner/
RUN dotnet restore ./OMT.TaskRunner/OMT.TaskRunner.csproj
RUN dotnet publish ./OMT.TaskRunner/OMT.TaskRunner.csproj -c Release -o out # build runtime image
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=build-env /app/OMT.TaskRunner/out ./
ENTRYPOINT ["dotnet", "OMT.TaskRunner.dll"]
docker build -t omt.taskrunner .
docker run omt.taskrunner:latest

Step 2: Push your Docker Image to a private repository

docker tag omt.taskrunner:latest marcmathijssen/omt
docker push marcmathijssen/omt:latest

Step 3: Schedule Azure Container Instances using Azure Logic Apps

  • Easy deployment: Just build & push the container. The Azure Logic App will download the new image the next time it runs
  • Pay what you use: Currently I pay average € 0,18 per month for my container that runs for a few minutes per day. These costs will increase as my app gets more users (or the other way around :-))

--

--

--

.NET developer living in The Netherlands. I write stories because it helps me sharing and remembering knowledge.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS 373 Spring 2022: Kyle Kamka

Gossamer Update: September 2020

CS373 Fall 2020: Harrison Gross Week 5

Beginner’s Guide to Task Automation: Automate Repetitive Tasks and Scale Your Business

The Death of the Dumb Pipe !

How to replace null values with average values in Power BI

Odoo 12 Accounting Module Installation using Docker

Swift forEach Caveat

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Marc Mathijssen

Marc Mathijssen

.NET developer living in The Netherlands. I write stories because it helps me sharing and remembering knowledge.

More from Medium

Access DynamoDB from Lambda (.Net, C#)

How To Deploy ASP .NET Core APIs To Kubernetes

How to convert DateTime objects to Python-friendly ISO8601 strings in C#

Build .Net Core REST API and Angular Application using Docker