<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>deploy asp.net core &#8211; ASP.NET Hosting Reviews and Guides</title>
	<atom:link href="https://topreviewhostingasp.net/tag/deploy-asp-net-core/feed/" rel="self" type="application/rss+xml" />
	<link>https://topreviewhostingasp.net</link>
	<description>ASP.NET Hosting &#124; Reviews &#124; Tips &#38; Tutorial</description>
	<lastBuildDate>Tue, 11 Apr 2017 04:19:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://topreviewhostingasp.net/wp-content/uploads/2017/01/cropped-trhaico-32x32.png</url>
	<title>deploy asp.net core &#8211; ASP.NET Hosting Reviews and Guides</title>
	<link>https://topreviewhostingasp.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Deploy ASP.NET Core Using Heroku</title>
		<link>https://topreviewhostingasp.net/deploy-asp-net-core/</link>
					<comments>https://topreviewhostingasp.net/deploy-asp-net-core/#respond</comments>
		
		<dc:creator><![CDATA[Jacques Hunt]]></dc:creator>
		<pubDate>Mon, 10 Apr 2017 04:26:25 +0000</pubDate>
				<category><![CDATA[Hosting Tips]]></category>
		<category><![CDATA[asp.net core hosting]]></category>
		<category><![CDATA[asp.net core tutorial]]></category>
		<category><![CDATA[ASP.NET Hosting]]></category>
		<category><![CDATA[deploy asp.net core]]></category>
		<category><![CDATA[deploy asp.net core use heroku]]></category>
		<category><![CDATA[heroku]]></category>
		<guid isPermaLink="false">https://topreviewhostingasp.net/?p=515</guid>

					<description><![CDATA[This post is about hosting ASP.NET Core applications on Heroku using Docker. Heroku is a cloud Platform-as-a-Service (PaaS) supporting several programming languages that is used as a web application deployment model. Heroku, one of the first cloud platforms, has been in development since June 2007, when it supported only the Ruby programming language, but now [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This post is about hosting ASP.NET Core applications on Heroku using Docker. Heroku is a cloud Platform-as-a-Service (PaaS) supporting several programming languages that is used as a web application deployment model. Heroku, one of the first cloud platforms, has been in development since June 2007, when it supported only the Ruby programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP, and Go. Heroku doesn’t support .NET or .NET Core natively, but recently they started supporting Docker. In this post we are using Docker to deploy my application to Heroku, there is build pack option is also available (Build Pack is the deployment mechanism which is supported by Heroku natively.), but there is no official build pack for .NET available yet.</p>
<p>Here is some details about the <a href="https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime">Dockerfile commands and runtime</a> from Heroku documentation. Few important points, which is required compared to dockerfile used in ASP.NET Core are.</p>
<ul>
<li>The web process must listen for HTTP traffic on $PORT, which is set by Heroku. EXPOSE in Dockerfile is not respected, but can be used for local testing.</li>
<li>CMD is required. If CMD is missing, the registry will return an error.</li>
</ul>
<p>For deployment you require two prerequisites.</p>
<ul>
<li><a href="https://devcenter.heroku.com/articles/heroku-cli">Heroku Command Line Interface</a></li>
<li><a href="https://download.docker.com/win/stable/InstallDocker.msi">Docker</a></li>
</ul>
<p>First you build the project, then you need to create the Docker image, and finally you need to publish the image to Heroku. I have created a MVC project using <span class="lang:default highlight:0 decode:true crayon-inline" style="color: #ff0000;">dotnet new</span>  command.</p>
<p>Once you created the project, you can build it using <span class="lang:default highlight:0 decode:true crayon-inline" style="color: #ff0000;">dotnet publish</span>  command.</p>
<pre class="lang:default decode:true">dotnet publish -c Release</pre>
<p>So your project will be compiled and output will be generated in the <span class="lang:default highlight:0 decode:true crayon-inline" style="color: #ff0000;">bin\Release\netcoreapp1.1\publish</span>  folder.</p>
<p>To deploy to Heroku, first you need to login to the container registry using <span style="color: #ff0000;"><span class="lang:default highlight:0 decode:true crayon-inline">heroku container:login</span> </span> command, once you login, you can build a docker image.</p>
<pre class="lang:default decode:true">docker build -t helloworld-aspnetcore ./bin/Release/netcoreapp1.1/publish</pre>
<p>Here is the Dockerfile we are using.</p>
<pre class="lang:default decode:true">FROM microsoft/dotnet:1.1.0-runtime



WORKDIR /app 

COPY . .



CMD ASPNETCORE_URLS=http://*:$PORT dotnet helloworld-aspnetcore.dll</pre>
<p>Since we are running the already published application, my base image is dotnet runtime. And we are using ASPNETCORE_URLS environment variable to bind the $PORT value from Heroku to Kestrel. Initialy we tried using the command line options but it was not working. And you need to copy the Dockerfile to the publish folder,otherwise the command will fail.</p>
<p style="text-align: center;"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-516" src="https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_1.png" alt="" width="884" height="532" srcset="https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_1.png 884w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_1-300x181.png 300w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_1-768x462.png 768w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_1-50x30.png 50w" sizes="(max-width: 884px) 100vw, 884px" /></p>
<p>Once you build the container, you need to tag it and push it according to this naming template. Here is the commands.</p>
<pre class="lang:default decode:true">docker tag helloworld-aspnetcore registry.heroku.com/helloworld-aspnetcore/web</pre>
<p>In this helloworld-aspnetcore is my app name. You can create apps either using the Web dashboard or using Heroku CLI &#8211; <span class="lang:default highlight:0 decode:true crayon-inline" style="color: #ff0000;">heroku create</span>  is the command to create an app using CLI. Once you tag it, you need to push the image to Heroku registry, here is the command.</p>
<pre class="lang:default decode:true">docker push registry.heroku.com/helloworld-aspnetcore/web</pre>
<p>This might take some time depends on the image size and your network bandwidth. Since we already hosted, we are pushing the Web application only.</p>
<p style="text-align: center;"><img decoding="async" class="alignnone size-full wp-image-517" src="https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_2.png" alt="" width="884" height="532" srcset="https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_2.png 884w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_2-300x181.png 300w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_2-768x462.png 768w, https://topreviewhostingasp.net/wp-content/uploads/2017/04/image_2-50x30.png 50w" sizes="(max-width: 884px) 100vw, 884px" /></p>
<p>Now you can browse the app using <a href="https://helloworld-aspnetcore.herokuapp.com/">https://helloworld-aspnetcore.herokuapp.com/</a> url, if deployment was successful and Kestrel started, you will see an ASP.NET MVC Home Page. If you are viewing an application error page, you need to look into the logs from Heroku.</p>
<p>Also make sure you’re running a dynos in Heroku, otherwise your app won’t work. You can create and use it from Resources menu.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://topreviewhostingasp.net/deploy-asp-net-core/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
