Install .Net Core, SQL Server V-Next on Linux and deploy .Net core application and sql server database on Linux
1. Deploy .Net application and SQL
server database on linux
environment
Ajith Ramawickrama
Chief Technology Officer
FinTechnology Asia Pasific.
2.
3. Introduction
Microsoft has been working with Linux for a number of years in order
to facilitate their customers to run work loads in both Windows and
Linux platforms. Followings are the few achievements
Linux on your Datacenter – Hyper-V
Linux on Azure
.Net Core
Visual Studio Code – Official IDE for .Net core on Linux and OSX
SQL Server V-Next (Production release on mid 2017)
4. .Net Core
.Net Core is a cross platform, open source, general purpose , modular
application development framework developed by Microsoft. Unlike
other .Net framework, .Net core has built from the stretch using .Net
standards. It contains most of APIs as the .Net standard framework, but
.net core is a smaller set which includes runtime, framework, compiler
and tools components that support a variety of operating systems and
chip targets. .Net runs on Windows, Linux and OS-x operating systems.
6. Advantages of .Net core
Flexible deployment: Can be included in your app or installed side-by-side user- or
machine-wide.
Cross-platform: Runs on Windows, macOS and Linux
Command-line tools: All product scenarios can be exercised at the command-line.
Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET
Standard.
Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses.
Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support
Runs on Docker.
Comes with inbuilt web server Kerstral
7. Supporting Linux Systems
Ubuntu – 14.04,16.04,16.10
Red Hat Enterprise Linux
Linux Mint -17,18
Debian 8
Fedora
CentOS 7.1
Oracle Linux 7.1
Open SUSE
8. Install .Net core on Ubuntu 16.04 LTS
1) Preparing the system for installation
In order to apt-get feed that hosts the package you need Run following commands in the
console one after another
• 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
2) Install .Net Code SDK
Run Following command in order to install .Net Core SDK
sudo apt-get install dotnet-dev-1.0.4
9. Deploy FinAp Formula in Ubuntu 16.04
There are two types of deployment options available in .Net core
1) Framework dependent deployment
.Net core should be pre installed
Size of the deployment package is very small
Reduce the disk and memory usage of deployment server
2) Self contained deployment
Create deployment package including all framework dependencies and other third party
dependencies
No need to install .Net core on target server
Need to set target platform at the time of deployment package creation
Large deployment package
10. Framework dependent deployment
Go to your solution folder in windows command prompt
Run the command “dotnet restore” in order to make sure that all the dependencies are properly
restored
Navigate to ASP.Net application(web or web api) folder and run the command “dotnet build” to
build the solution
Run the command “dotnet publish -f netcoreapp1.1 -c Release” to create deployment package
Copy created package to Ubuntu PC
Go to the copied directory and run “dotnet executable-name.dll” in ubuntu terminal
11. SQL Server VNext
• SQL Server 2017 represents a major step towards making SQL Server
a platform that gives you choices of development languages, data
types, on-premises and in the cloud, and across operating systems by
bringing the power of SQL Server to Linux, Linux-based Docker
containers, and Windows.
• Newest version is SQL Server 2017 CTP 2.1. According to Microsoft
Production version to be released on mid 2017
• Currently Support Linux Versions
• Red Hat Enterprise Linux
• SUSE Linux Enterprise Server
• Ubuntu 16.04
• Docker Engine 1.8 +
12. Install SQL Server Vnext on Ubuntu 16.04
• Minimum System Requirements
• Memory- 3.25 GB
• File System- XFS or EXT4
• Disk Space - 1GB
• Processor Speed -1.4 Ghz
• Processor Cores – 2 cores
• Processor Type – X64 only
13. 1) Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
2) Register the Microsoft SQL Server Ubuntu repository:
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee
/etc/apt/sources.list.d/mssql-server.list
3) Install SQL Server
sudo apt-get update
sudo apt-get install -y mssql-server
4) Config SQL Server
sudo /opt/mssql/bin/mssql-conf setup
5) Check the status
systemctl status mssql-server
14. Install SQL tools on Ubuntu
1) Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
Register the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee
/etc/apt/sources.list.d/msprod.list
3) unixODBC developer package
sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev
4) Update MsSql tools
sudo apt-get update
sudo apt-get install mssql-tools
5) Set PATH variable
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
15. Restore SQL Server Backup On Ubuntu
• Take a backup of the database from Windows machine
• Transfer backup to Linux (VMWare Tools/PUTTY,SSH)
• Move the backup files to SQL directory
Enter Super user mode
sudo su
Create Backup Directory On /var/opt/mssql
mkdir -p /var/opt/mssql/backup
Move Backup files
mv /home/user1/AdventureWorks2014.bak
/var/opt/mssql/backup/
16. • Restore database
sqlcmd -S localhost -U SA
RESTORE DATABASE FinApCore
FROM DISK = '/var/opt/mssql/backup/backupName.bak'
WITH MOVE ‘FinApCore_Data' TO '/var/opt/mssql/data/FinapCore_Data.mdf',
MOVE ‘FinApCore_Log' TO '/var/opt/mssql/data/FinApCore_Log.ldf'
GO
17. Why we Need Reverse Proxy?
• Kestrel is the default web server for .net core which is serving
dynamic contents
• Reverse Proxy Allows Us to
• serving static content
• caching requests
• compressing requests
• SSL termination from the HTTP server
• IIS Works as the reverse proxy for windows and NginX or Apache
works as the reverse proxy for Linux