Saturday, May 20, 2017

Install .NET Core on Linux (Ubunut) and deploy ASP.NET Core RESTful service



Once ASP.NET Core rest service is compiled, below are the steps to setup Linux (Ubuntu) and deploy .net core service code.

Note: My setup pulls published code from S3 bucket on AWS. I provided links to sample code and conf files for your reference in the comments

Here is the bash script to install .NET Core on Ubuntu and setup .net sample rest service.

#!/bin/bash
#! Install dotnetcore

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update -y
sudo apt-get install dotnet-dev-1.0.1 –y   #!Finished installation of dotnetcore

sudo apt install awscli –y #! Install aws cli command tool

sudo apt-get install unzip –y #! Install unzip library

sudo apt-get install supervisor –y #! Install supervisor service which starts service and monitors
cd /home/ubuntu/
mkdir code
cd code/
aws s3 cp s3://dotnetonlinux/publish.zip publish.zip #! Download code from s3 onto server
cd /var/
mkdir dotnetcore
cd dotnetcore/
cd /home/ubuntu/code/
unzip publish.zip -d /var/dotnetcore/ #! Unzip code to var/dotnetcore folder
#!Run this manually.
#!This requires sudo su permissions...

service supervisor stop #! Start supervisor service
cd /etc/supervisor/conf.d

aws s3 cp s3://dotnetonlinux/dotnetcore.conf dotnetcore.conf #! Download conf file from s3. 



No comments:

Post a Comment