Apr 17, 2018 - Demo #2 â Command line dotnet build to ACCS. 1 ... Cross-platform (eg Linux, Mac, Windows) ... NET Core
Move Your .NET Core Applications to Linux in the Cloud Using Docker Christian Shay Product Manager Oracle April 17, 2018
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
2
Program Agenda 1
Intro to .NET Core and Docker
2
Tools of the Trade (stuff you want to download)
3
Demo #1 – Visual Studio to Docker Hub to Linux
4
Demo #2 – Command line dotnet build to ACCS
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
.NET vs .NET Core .NET Core/ASP.NET Core
• Cross-platform (eg Linux, Mac, Windows) • Works well with Docker containers. • Higher performance • Permits side-by-side .NET versions per application.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
4
.NET and .NET Core Why stick with .NET
• Your app uses .NET technologies that aren't available for .NET Core. – ASP.NET Web Forms – ASP.NET Web Pages – Windows Presentation Foundation (WPF) and Windows FormsWCF services – Workflow-related services
• Your app uses third-party .NET libraries or NuGet packages not available for .NET Core. • You are building Windows desktop apps
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
5
Porting from .NET to .NET core • Windows Compatibility Pack – Nuget Package that adds 20,000 APIs to .NET Core
• .NET Standard – Applications targeting .NET Standard also run on .NET core
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
6
Docker • Docker is an open-source platform based on Linux and Windows containers – Designed for developing, shipping and running apps leveraging container tech
• Unlike a VM which provides hardware virtualization, a container provides operating-system-level virtualization by abstracting the “user space” – Containers *share* the host system’s kernel with other containers.
• Containers are lightweight (when compared to VMs) – No need to install Guest OS – Less CPU, RAM, Storage required – Start up and shut down very quickly Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
7
Tools of the trade AKA Stuff you’ll want to download
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted
8
Visual Studio 2017
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
9
.NET Core Command line tools (dotnet SDK) Download here: https://bit.ly/2H7xElO
• Runs on multiple platforms (Windows, Mac, and Linux) dotnet new web -n mywebapp dotnet add package Oracle.ManagedDataAccess.Core -v 2.12.0-beta2 dotnet build dotnet publish -c Release -r linux-x64 dotnet mywebapp.dll Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
10
Docker for Windows CE/ Docker for Linux CE • Docker for Windows CE installation instructions: – https://dockr.ly/2oiWxxH
• Docker for Linux installation instructions – https://dockr.ly/2H3ydgl
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
11
Docker command line $docker images $docker login $docker pull christianshay/testsimple:latest $docker run --env-file env.list -p 11000:80 christianshay/testsimple:latest
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
12
Docker Registries (Docker Hub) • Cloud-based registry service which allows you to push and pull docker images very efficiently – You don’t have to reupload and redownload duplicated material
• https://hub.docker.com/
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
13
SSH To connect to your linux machines in the cloud or elsewhere
• Putty • Cygwin • or (eventually) Windows 10 OpenSSH client
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
14
SimpleWebApp Available on GitHub @ https://bit.ly/2HsAP6Q string conString = Environment.GetEnvironmentVariable("CONNECTSTRING"); using (OracleConnection con = new OracleConnection(conString)){
using (OracleCommand cmd = con.CreateCommand()){ await context.Response.WriteAsync("Connecting...... " + "\n"); con.Open(); await context.Response.WriteAsync("Employee First Names in Department 50: " + "\n"); cmd.CommandText = "select first_name from employees where department_id = :id"; while (reader.Read()) {
await context.Response.WriteAsync("Employee First Name: " + reader.GetString(0) Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
15
Demos • Demo #1: Build ASP.NET Core app with Visual Studio – Visual Studio will build ASP.NET core app, create docker image, deploy to Docker Hub – I’ll pull docker image into Linux in the cloud and then run it
• Demo #2: Build ASP.NET Core app with dotnet sdk command line – Deploy to Application Container cloud service which loads it into docker
• Demo #3 : (if time allows): Run the ASP.NET core app on Linux without docker
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
16
My Cloud Resources • Oracle Linux running on Oracle Cloud Infrastructure compute • Application Container Cloud Service • Oracle Database as a service
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
17
Let’s get our hands dirty! (Demo time!) Subtitle
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted
18
For those reading at home… Demo #1 – VS Build and Deploy to Docker on Linux Commands I used in my demo
• 1) VS: Create new asp.net core app with Linux Docker enabled • 2) Paste Startup.cs from the OracleCodeBoston github • 3) Add Oracle.ManagedDataAccess.Core from nuget • 4) Add CONNECTSTRING= to docker compose override yml • 5) Build/Debug in VS • 6) Publish to dockerhub • 7) Log into dockerhub and obtain tag • 8) Connect to Linux: ssh -i d:/privatekey.key opc@myLinuxIP Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
19
For those reading at home… Demo #1 Commands I used in my demo
• 10) sudo docker login 11) sudo docker pull christianshay/testsimple:tagfromearlierstep 11.5) paste env.list from github into a file on the linux instance • 12) sudo docker run --env-file env.list -p 11000:80 christianshay/testsimple:tagfromearlierstep • 13) open second ssh session: ssh -i d:/private.pub opc@myLinuxIP
• 14) from this session: curl 0.0.0.0:11000
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
20
For those reading at home… Demo #2 – Application Container Cloud Service Commands I used in my demo
• 1) dotnet new web -n myapp • 2) Paste Startup.cs from github • 3) Edit Program.cs from github to add .UseUrls("http://0.0.0.0:"+ Environment.GetEnvironmentVariable("PORT")) in BuildWebHost • 4) dotnet add package Oracle.ManagedDataAccess.Core -v 2.12.0-beta2 – Version number may have changed over time (not required once no longer prerelease)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
21
For those reading at home… Demo #2 Commands I used in my demo
• 5) dotnet build • 6) dotnet publish -c Release -r linux-x64 • 7) Zip up files – (Do not add any additional folders at top of zip structure) • 8) edit Deployment.json from github with DLL name and CONNECTSTRING environment variable • 9) Connect to Application Container Cloud Service and provide zip file, Deployment.json and Manifest.json
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
22
For those reading at home… Demo #3 – Linux bare metal (no docker) Commands I used in my demo
• 1) scp -i private.pub publish.zip opc@mylinuxIP:/home/opc • 2) ssh -i d:/private.pub opc@mylinuxIP • 3) unzip publish.zip • 4) sudo dotnet linuxbaremetal.dll • 5) ssh -i d:/private.pub opc@OracleLinuxIP • 6) curl 0.0.0.0:5000
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
23
Additional Oracle .NET Resources OTN otn.oracle.com/dotnet Twitter twitter.com/OracleDOTNET YouTube youtube.com/OracleDOTNETTeam Email
[email protected]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |