{"id":3861,"date":"2015-09-07T22:59:07","date_gmt":"2015-09-07T20:59:07","guid":{"rendered":"https:\/\/blog.redbaronofazure.com\/?p=3861"},"modified":"2015-10-29T12:35:37","modified_gmt":"2015-10-29T11:35:37","slug":"a-website-running-on-nano-server","status":"publish","type":"post","link":"https:\/\/blog.redbaronofazure.com\/?p=3861","title":{"rendered":"A website running on Nano Server"},"content":{"rendered":"<p>Nano Server is a slimmed down version of the coming Windows Server 2016 and in the last\u00a0post, created a VHD image with\u00a0Nano Server and startedit on Azure. This time I will deploy a website on the Nano Server using ASP.Net5, which is new in Visual Studio 2015.\u00a0Since Nano Server only contains CoreCLR and not the entire .Net Framework, the website will also have to do with CoreCLR and this is one of the features of ASP.Net5.<\/p>\n<p><strong>DNX &#8211; .Net Execution Environment<\/strong><\/p>\n<p>New in ASP.Net5 is DNX, or .Net Execution Environment. With it you can install versions of clr and coreclr and you can even create, pack, publish and run web applications. In the references, I have a \/\/build session by Scott Hanselman that you should watch.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/dnvm_list_install.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3761\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/dnvm_list_install.png\" alt=\"dnvm_list_install\" width=\"659\" height=\"406\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/dnvm_list_install.png 659w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/dnvm_list_install-300x185.png 300w\" sizes=\"(max-width: 659px) 100vw, 659px\" \/><\/a><\/p>\n<p>First you need to make sure that you have the CoreCLR version that we are going to use. Using the commands DNVM LIST and DNVM INSTALL you can\u00a0manage what runtimes you have locally. To get the webapp to run on the Nano Server, we must use coreclr with the x64 architecture, since that is the only supported options.\u00a0The coreclr runtimes are stored in your user profile folder &#8211; in my case c:\\users\\cljung\\.dnx.<\/p>\n<p>In the next post, I will use Mono and put an ASP.Net5 website on a Ubuntu Linux server.<\/p>\n<p><strong>Build the webapp in Visual Studio 2015<\/strong><\/p>\n<p>Creating a webapp that uses coreclr is easy if you are using VS2015. Select the Empty ASP.NET 5 Template, like below.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_NewWebApp1.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3841\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_NewWebApp1.png\" alt=\"VS_NewWebApp1\" width=\"786\" height=\"613\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_NewWebApp1.png 786w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_NewWebApp1-300x234.png 300w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/p>\n<p>From there on, right click on the project and select properties to set DNX target to the version of your CoreCLR with x64 architecture. Changing from .Net Framework to CoreCLR will give you yellow warning triangles on the References in VS2015 and to remove those you have to do Restore Packages. This could be done from the command line with the DNX command DNU RESTORE.\u00a0The restore packages procedure basically pulls down all NuGet packages needed for the project under the current platform and architecture.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_CoreCLR_RestorePackages.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3831\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_CoreCLR_RestorePackages.png\" alt=\"VS_CoreCLR_RestorePackages\" width=\"1020\" height=\"476\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_CoreCLR_RestorePackages.png 1020w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_CoreCLR_RestorePackages-300x140.png 300w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><\/a><\/p>\n<p>Last step is to Publish the application. Skip the Publish to Azure Website and set the profile for File System. Make sure that the DNX version is the correct (which it should be).<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_Publish.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3851\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_Publish.png\" alt=\"VS_Publish\" width=\"706\" height=\"558\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_Publish.png 706w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/VS_Publish-300x237.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/a><\/p>\n<p><strong>Publishing the website to Nano Server<\/strong><\/p>\n<p>The only option for deploying the website is file copy. There is no WebDeploy or similar. In fact, it is difficult just to unpack a zip file, since most Powershell scripts you&#8217;ll find on the internet uses the Windows Shell object\u00a0\u00a0&#8211; which doesn&#8217;t exist on the Nano Server. My deployment is done the simple way using Copy-Item from the local laptop, via the Powershell remote managament session, to the Nano Server on Azure. The $ip address in the script window is Azure&#8217;s public VIP for the VM. Copying is not fast and will take some time.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_deploy_to_nano.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3781\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_deploy_to_nano.png\" alt=\"PS_deploy_to_nano\" width=\"901\" height=\"612\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_deploy_to_nano.png 901w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_deploy_to_nano-300x204.png 300w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><\/a><\/p>\n<p>Before we start the website, the file hosting.ini needs to be edited. It contains\u00a0the local ip adress that the website should bind to. Default is localhost, but that will not work on Azure. You need to change that to the internal ip address the Azure VM has, ie the ip address you see with ipconfig.This is a bit of a hazzle if you redeploy since you have to repeat the process.<\/p>\n<p>You also need to add an Endpoint in Azure on the VM in the Azure Management Portal where you map public port 80 to private port 5000.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_hosting.ini_.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3801\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_hosting.ini_.png\" alt=\"PS_hosting.ini\" width=\"901\" height=\"612\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_hosting.ini_.png 901w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_hosting.ini_-300x204.png 300w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><\/a><\/p>\n<p><strong>Starting the website<\/strong><\/p>\n<p>Starting the website is done via running a small file called web.cmd, which was created during the Publish procedure in VS2015. The web.cmd file contains one line where in uses the DNX command to run the website. It points to details in the project.json that gives DNX instructions what &#8220;run&#8221; actually means. On a Ubuntu Linux server, the project.json file will contain details on how to launch the website in that environment.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_dnx_run_web.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3791\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_dnx_run_web.png\" alt=\"PS_dnx_run_web\" width=\"901\" height=\"612\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_dnx_run_web.png 901w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/PS_dnx_run_web-300x204.png 300w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><\/a><\/p>\n<p><strong>Website running on Nano Server<\/strong><\/p>\n<p>Below you see a screenshot of the ASP.Net5 website running on a Nano Server operating system in Azure on a A0\/X-Small shared core instance. I added some code to the start page to dig out a few\u00a0counters from the VM to show it&#8217;s environment.<\/p>\n<p>There are a few interesting facts to highlight:<\/p>\n<ul>\n<li>The physical RAM of a A0 instance is only\u00a0767 MB, which really isn&#8217;t a lot<\/li>\n<li>The C:\\Windows folder is only 584 MB. The difference in\u00a0footprint between Nano Server\u00a0and Windows is dramatically different. (C:\\Program Files exist but is 0MB)<\/li>\n<li>Out of that amount of RAM, the website only used a 58 MB working set. The DNX environment is lean environment that survives pretty good on the smalest VM Azure can provide,<\/li>\n<\/ul>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/Web_Runing.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-3811\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/Web_Runing.png\" alt=\"Web_Runing\" width=\"1160\" height=\"997\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/Web_Runing.png 1160w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/Web_Runing-300x258.png 300w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2015\/09\/Web_Runing-1024x880.png 1024w\" sizes=\"(max-width: 1160px) 100vw, 1160px\" \/><\/a><\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>Why this rant about Nano Server? Well, what I&#8217;ve showed here is part of the future, where you can build solution as small services\u00a0that are very lightweight and that runs in evnironments that are completly with out a UI.\u00a0If your service can leverage this technology you have the ability of keeping the item price low, which is key if you are going to have to scale up to several\u00a0thousands of VMs that work together.<\/p>\n<p>ASP.Net5 is an exciting new piece of technology since it has the ambition of\u00a0being leightweight and give you every ounce of performance. It is also a multiplatform technology which I will show you in the next post when we deploy an ASP.Net5 website on Ubuntu Linux using Mono.<\/p>\n<p><strong>References<\/strong><\/p>\n<p>\/\/build conference &#8211; Introducing ASP.NET 5, by Scott Hanselman and Scott Hunter<br \/>\n<a href=\"http:\/\/channel9.msdn.com\/Events\/Build\/2015\/2-687\">http:\/\/channel9.msdn.com\/Events\/Build\/2015\/2-687<\/a><\/p>\n<p>ASPNET vNext on Nano Server &#8211; Nano Server Team blog<br \/>\n<a href=\"https:\/\/channel9.msdn.com\/Series\/Nano-Server-Team\/ASPNET-vNext-on-Nano-Server\">https:\/\/channel9.msdn.com\/Series\/Nano-Server-Team\/ASPNET-vNext-on-Nano-Server<\/a><\/p>\n<p>ASP.Net5 on github &#8211; documentation and code (open sourced by Microsoft)<\/p>\n<p><a href=\"https:\/\/github.com\/aspnet\/home\">https:\/\/github.com\/aspnet\/home<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Be sure to check out the references in the previous post<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nano Server is a slimmed down version of the coming Windows Server 2016 and in the last\u00a0post, created a VHD image with\u00a0Nano Server and startedit on Azure. This time I will deploy a website on the Nano Server using ASP.Net5, which is new in Visual Studio 2015.\u00a0Since Nano Server only contains CoreCLR and not the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[91],"tags":[191,161],"_links":{"self":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts\/3861"}],"collection":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3861"}],"version-history":[{"count":0,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts\/3861\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}