{"id":35298,"date":"2019-02-27T10:17:39","date_gmt":"2019-02-27T17:17:39","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/premier-developer\/?p=35298"},"modified":"2019-02-21T13:50:29","modified_gmt":"2019-02-21T20:50:29","slug":"enterprise-application-modernization-using-windows-containers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/enterprise-application-modernization-using-windows-containers\/","title":{"rendered":"Enterprise Application Modernization using Windows Containers"},"content":{"rendered":"<p>App Dev Manager <a href=\"https:\/\/www.linkedin.com\/in\/farah-deendar-05b2a16\/\">Farah Deendar\u00a0<\/a>explores first steps of application modernization through simple containerization.<\/p>\n<hr \/>\n<p>As an Application Development Manager, I often have conversations with my enterprise customers around application modernization, its synonymy with containers and microservices and what is the best way to modernize line of business applications. Many enterprise organizations today have numerous desktop applications that are CRUD based and call for modernization without necessarily needing to re-architect these LOB legacy apps. Web Apps on traditional .NET framework, ASP.NET web forms, MVC or WCF apps are common examples. If you have an existing .NET enterprise application that could use CI\/CD but not necessarily any immediate rearchitecting efforts containerizing your application is the way to go. Although the role of <a href=\"https:\/\/www.infoq.com\/articles\/ddd-in-practice\">Domain Design Modeling<\/a> and use of <a href=\"https:\/\/martinfowler.com\/articles\/microservices.html\">Microservices<\/a> is vital to modernizing Enterprise Architecture and applications, it does not always make business sense to rearchitect a legacy application.<\/p>\n<p>The focus of this blog is to help developers in the enterprise to containerize existing .NET Framework applications\/services that currently need to run on Windows. I will be using <a href=\"https:\/\/youtu.be\/Ryx3o0rD5lY\">Windows Containers<\/a> for the rest of this blog. The windows containers can be run at scale with<a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/run-docker-with-azure-container-instances\/\"> Azure containers<\/a> as an option with many benefits. If you don\u2019t want to move to the cloud, you can apply these approaches on-premises, too.<\/p>\n<p>Steps to containerize a windows Desktop application:<\/p>\n<ol>\n<li>Pre-requisites for a working Environment:\n<ol>\n<li>Windows 10 Enterprise\/Pro with Hyper-V enabled<\/li>\n<li><a href=\"https:\/\/hub.docker.com\/editions\/community\/docker-ce-desktop-windows\">Docker for Windows<\/a>. The full list of pre-req\u2019s is available <a href=\"https:\/\/docs.docker.com\/docker-for-windows\/install\/#what-to-know-before-you-install\">here<\/a>.<\/li>\n<li>Command Shell or PowerShell for windows<\/li>\n<li>Visual Studio 2017, ASP.NET\/MVC\/WCF app\nNote: To get things working via Windows, select the option \u201cSwitch to Windows\u00a0containers\u201d in the Docker tray icon. See below:\n<img decoding=\"async\" width=\"340\" height=\"410\" class=\"wp-image-35299\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/a-screenshot-of-a-cell-phone-description-automati.jpeg\" alt=\"A screenshot of a cell phone Description automatically generated\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/a-screenshot-of-a-cell-phone-description-automati.jpeg 340w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/a-screenshot-of-a-cell-phone-description-automati-249x300.jpeg 249w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/>\nNote: Docker for Windows after install defaults to Linux containers.<\/li>\n<\/ol>\n<\/li>\n<li>Asp.net Desktop application:\nFor the purposes of this blog, the containerization sample ASP.NET application used is available <a href=\"https:\/\/docs.microsoft.com\/en-us\/virtualization\/windowscontainers\/quick-start\/building-sample-app\">here<\/a>.\nYou can use your existing .net app in place of this sample and follow the steps provided in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/virtualization\/windowscontainers\/quick-start\/building-sample-app#getting-started\">sample<\/a> and\/or below:<\/li>\n<li>Containerize your application.\n<ol style=\"list-style-type: lower-alpha\">\n<li>Navigate to your local project directory and create the docker file. The key to containerizing your application is building your <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\">Dockerfile<\/a>.\nA docker file is a text document that contains all the commands to build your container image. More details on Dockerfile are available <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\">here<\/a>.\nBelow PowerShell command you will use to create the dockerfile in your project root folder:\n<code>New-Item C:\/YourProjLocation\/Dockerfile -type file<\/code><\/li>\n<li>Next you will add logic to your Dockerfile that declares which base image you will use to build your container.\nSee writing to your <a href=\"https:\/\/docs.microsoft.com\/en-us\/virtualization\/windowscontainers\/quick-start\/building-sample-app#writing-our-dockerfile\">Dockerfile<\/a> as an example or below\n<strong>PowerShell Command:<\/strong>\n<code>FROM microsoft\/aspnetcore-build:1.1 AS build-env<\/code>\n<code>WORKDIR \/app<\/code>\n<code>COPY *.csproj .\/<\/code>\n<code>RUN dotnet restore<\/code>\n<code>COPY . .\/<\/code>\n<code>RUN dotnet publish -c Release -o out<\/code>\n<code>FROM microsoft\/aspnetcore:1.1<\/code>\n<code>WORKDIR \/app<\/code>\n<code>COPY --from=build-env \/app\/out .<\/code>\n<code>ENTRYPOINT [\"dotnet\", \"MvcMovie.dll\"]<\/code><\/li>\n<li>Now you will tell docker to build your app and run the container.\n<strong>PowerShell command:<\/strong>\n<code>docker build -t myapp<\/code>\n<code>docker run -d -p 5000:80 --name myapp myasp<\/code>\nNote: Your powershell console\u2019s current working directory needs to be pointing to where your dockerfile resides.\n<img decoding=\"async\" width=\"919\" height=\"1126\" class=\"wp-image-35300\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-113.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-113.png 919w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-113-245x300.png 245w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-113-768x941.png 768w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-113-836x1024.png 836w\" sizes=\"(max-width: 919px) 100vw, 919px\" \/><\/li>\n<li>Get the IP address of your running container using the command below\n<strong>PowerShell Command<\/strong>\n<code>docker inspect -f \"{{ .NetworkSettings.Networks.nat.IPAddress }}\" myapp<\/code>\n<img decoding=\"async\" width=\"1549\" height=\"60\" class=\"wp-image-35301\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-114.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-114.png 1549w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-114-300x12.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-114-768x30.png 768w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/02\/word-image-114-1024x40.png 1024w\" sizes=\"(max-width: 1549px) 100vw, 1549px\" \/><\/li>\n<li>Copy the IP address to your local web browser. You have successfully containerized your ASP.NET application!<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h3><strong><u>Resources to help Scale your containers on premises<\/u><\/strong><u>:<\/u><\/h3>\n<p>Docker hosts with <a href=\"https:\/\/www.youtube.com\/watch?v=_Rt1OpdrkeA\">Windows Containers on Windows Server 2016<\/a>. VMs\/Servers can be on-premises. For your orchestration needs <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/service-fabric\/service-fabric-deploy-anywhere\">Azure Service Fabric<\/a> can be on-premises as well as Kubernetes can be on-premises.<\/p>\n<h3><strong><u>Resources to help Scale and run your Containers in the Cloud:<\/u><\/strong><\/h3>\n<h4>Containerizing monolithic applications in Azure<\/h4>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/microservices-architecture\/architect-microservice-container-applications\/containerize-monolithic-applications\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/microservices-architecture\/architect-microservice-container-applications\/containerize-monolithic-applications<\/a><\/p>\n<h4>Azure Service Fabric<\/h4>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/service-fabric\/service-fabric-containers-overview\">https:\/\/docs.microsoft.com\/en-us\/azure\/service-fabric\/service-fabric-containers-overview<\/a><\/p>\n<h4>Container Orchestration in the Cloud<\/h4>\n<p>Container orchestrators are assigned a pool of servers (VMs or bare metal servers), commonly called a \u201ccluster,\u201d and \u201cschedule\u201d deployment of containers onto those servers. Some orchestrators go further and configure networking between containers on different servers, while some include load balancing, container name resolution, rolling updates and more. Some are extensible and enable application frameworks to bring these additional capabilities. While a deeper discussion on orchestration solutions might require a whole other post on its own, here\u2019s a quick outline a few of the technologies, all supported on top of Azure:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.docker.com\/docker-compose\">Docker Compose<\/a> enables the definition of simple multi-container applications. <a href=\"https:\/\/www.docker.com\/docker-swarm\">Docker Swarm<\/a> manages and organizes Docker containers across multiple hosts via the same API used by a single Docker host. <a href=\"https:\/\/azure.microsoft.com\/blog\/2015\/02\/26\/sunny-and-swarmy-in-azure\">Swarm and Compose come together to offer a complete orchestration technology built by Docker<\/a>.<\/li>\n<li><a href=\"http:\/\/mesos.apache.org\/\">Mesos<\/a> is an orchestration and management solution that actually predates Docker, but has recently added support for Docker into its built-in application framework Marathon. It is an open and community-driven solution built by <a href=\"https:\/\/mesosphere.com\/\">Mesosphere<\/a>. We recently demonstrated integration with <a href=\"https:\/\/mesosphere.com\/blog\/2015\/04\/29\/mesosphere-dcos-debuts-on-microsoft-azure\/\">Mesos and DCOS on Azure<\/a>.<\/li>\n<li><a href=\"http:\/\/kubernetes.io\/\">Kubernetes<\/a> is an open-source solution built by Google offering container grouping into \u201cPods\u201d for management across multiple hosts. <a href=\"https:\/\/azure.microsoft.com\/blog\/2014\/07\/10\/azure-collaboration-with-google-and-docker\/\">This is also supported on Azure<\/a>.<\/li>\n<li><a href=\"https:\/\/deis.com\/\">Deis<\/a> is an open source PaaS platform to deploy and manage applications integrated with Docker. <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/virtual-machines-deis-cluster\/\">We have an easy way to deploy a Deis cluster on Azure<\/a>.<\/li>\n<\/ul>\n<p>Premier Support for Developers can help with your organizational readiness and deployment of Enterprise Application Modernization. For more information go <a href=\"https:\/\/www.microsoft.com\/en-us\/enterprise\/services\/support\">here<\/a> or please contact <a href=\"https:\/\/www.linkedin.com\/in\/farah-deendar-05b2a16\/\">Farah Deendar<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enterprise organizations today have numerous simple CRUD based applications that call for modernization without necessarily needing to re-architect the legacy apps. If you have an existing .NET app that could use CI\/CD but not necessarily any immediate rearchitecting efforts, this blog is for you. <\/p>\n","protected":false},"author":582,"featured_media":37840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,55],"tags":[67,2,29,3],"class_list":["post-35298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-web","tag-asp-net","tag-containers","tag-docker","tag-team"],"acf":[],"blog_post_summary":"<p>Enterprise organizations today have numerous simple CRUD based applications that call for modernization without necessarily needing to re-architect the legacy apps. If you have an existing .NET app that could use CI\/CD but not necessarily any immediate rearchitecting efforts, this blog is for you. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/35298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=35298"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/35298\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37840"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=35298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=35298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=35298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}