40
votes

We can obviously now deploy our asp.net core apps into docker container. I went through docs about 'how to do it' but i couldn't find some proper explanation about 'why to do it'?

Could anyone explain why would one choose deploying asp.net core app to docker container instead of azure app service?

5
not sure i underastand 'too broad' flag here. there are official terms for this kind of things on other fields like 'javascript fatigue', 'dependency hell', etc... here we could talk about 'cloud fatigue' where one has zillion of options and not clear explanations which ones are better and why. everyone talks about what's possible to be done (and that's clear) but not too much on why would one do it (or not).dee zg

5 Answers

14
votes

Obvious reason to favor docker image over app service would be portability. If you want to switch to other cloud platform from Azure, you simply need to deploy your preconfigured docker image to other platform's container management service and it will just work there, whereas if you want to move your app from app service to some equivalent service offering in some other cloud platform, you'll need to spend time learning about how it works and then configuring it all over again in the new place.

11
votes

Could anyone explain why would one choose deploying asp.net core app to docker container instead of azure app service?

All Azure Web App run in a secure environment called a sandbox. The sandbox mechanism aims to ensure that each app running on a machine will have a minimum guaranteed level of service; furthermore, the runtime limits enforced by the sandbox protects apps from being adversely affected by other resource-intensive apps which may be running on the same machine.

Since All Azure Web App run in the same type of sandbox. Azure Web App provide the multi features which related to deploying and monitoring your web application. For example Logging, Remote debugging, Kudu, Site extension etc.

Since All Azure Web App run in the same type of sandbox, The sandbox restrictions will affect your web application.

General Sandbox Restrictions

If the APIs or functions which used by your web app is not restricted by sandbox, you could choose Azure Web App to use the features/tools provided by Azure Web App. Otherwise, you could choose dock container.

6
votes

Although Docker support is getting better, developing locally with Docker has issues, for example with time sync like this https://github.com/docker/for-win/issues/3168. There is better support those days, for example "Azure Dev Spaces" which make it possible to run a microservice in a cluster not running locally, so it removed the requirement to run all needed images on your laptop. There are many benefits for simplify deployment and management once a cluster is configured, but still I do not enjoy developing for.

I personally do not favor Kubernetes (AKS), Docker Swarm, etc.. It requires a cluster configuration and I would only recommend it in a large microservice architecture where people do not want to use serverless architecture like Azure Functions, but that is not really the question here. Not that easy, how to handle certificates and port binding? Docker storage, ever used Docker Data Volumes? It is not very friendly. Monitoring could be improved, what if something goes wrong, where to find more information? I find it hard.

Azure Web Apps offer good integration with Azure DevOps, deployment slots, Application Insights, Application Identity! (called MSI). Automatic certificate renewal using App Service Certificates, custom domains and so many developer utilities, attaching visual studio as debugger is so easy. Using the App Service Editor you can try out modifications in for example the Web.Config without the need to re-image your Docker image.

In my opinion: If you want no vendor lock in then go for Docker images, else go for Azure Function App v2 or Azure Web Apps.

My favor #1: Serverless

  • Azure -> Function App v2 (nice with Eventgrid and Logic Apps)
  • Amazon -> AWS Lambda

My favor #2: PaaS

  • Azure -> Azure Web Apps
  • Amazon -> AWS Elastic Beanstalk

else Docker

  • Azure -> Azure Kubernetes Service
  • Amazon -> Amazon Elastic Container Service / Amazon Elastic Kubernetes Service / AWS Fargate

I would not go for IaaS any more even though it offers most control overall.

4
votes

Docker does not remove the need to deploy your app to cloud providers such as azure. Cloud providers provide you an infrastructure or a platform to deploy your apps. You need this if you don't have your own servers to deploy your application, regardless if you are using docker.

Docker makes the deployment of your apps more predictable and easier since it provides a lot of isolation between the app and the machine used to run the app.

It is very popular nowadays to use Docker and a cloud platform to deploy applications. When you use Docker, one will be confident that the same application image will be able to run on different platforms, and thus you will be able to switch between different providers(or even private servers) without having to modify you app.

0
votes

There's a million things to factor in when choosing one over the other. But just to mention one:

If you're considering using gRPC then at least at time of writing, Azure App Service is not an option. Refer to this GitHub Issue

AKS is a good workaround according to the GitHub issue. By the way, the word "workaround" is not intended to belittle AKS here. Both technologies have their merits.