ASP.NET Core deployment options

29
Deploying ASP.NET Core Applications Ken Cenerelli Microsoft MVP @KenCenerelli #ASPNETCore, #DetroitDevDay

Transcript of ASP.NET Core deployment options

Page 1: ASP.NET Core deployment options

Deploying ASP.NET Core Applications Ken Cenerelli

Microsoft MVP

@KenCenerelli#ASPNETCore, #DetroitDevDay

Page 2: ASP.NET Core deployment options

ABOUT ME

Twitter: @KenCenerelliEmail: [email protected]: kencenerelli.wordpress.comLinkedIn:

linkedin.com/in/kencenerelli

Content Developer / Programmer Writer

Microsoft MVP - Visual Studio and Development Technologies

Microsoft TechNet Wiki Guru Co-Organizer of CTTDNUG Technical reviewer of multiple books

CTTDNUG

Ken Cenerelli

2

Page 3: ASP.NET Core deployment options

ASP.NET Core (previously ASP.NET 5)

A new open-source and cross-platform framework for building

modern cloud-based Web applications using .NET

Page 4: ASP.NET Core deployment options

ASP.NET Core in a Nutshell

.NET Framework .NET Core Platform for .NET applications on Windows Cross-platform, modular libraries &

runtime optimized for server and cloud workloads

ASP.NET 4.6(System.Web)

MVC ASP.NET Core MVC

ASP.NET Core 1.0(Microsoft.AspNetCore)

Web API

WebForms

Page 5: ASP.NET Core deployment options

ASP.NET Core featuresHostingKestrel, StartupMiddlewareRouting, authentication, static files, diagnostics, error handling, session, CORS, localization, customDependency InjectionConfigurationLoggingApplication frameworksMVC, Identity, SignalR (future)

Page 6: ASP.NET Core deployment options

Getting from development to production

Development

Production

Page 7: ASP.NET Core deployment options

Getting started with .NET Core (dev builds)Install the .NET Core SDKGetting started: dot.net Latest dev build: https://github.com/dotnet/cli

Try out ASP.NET Core sampleshttps://github.com/aspnet/cli-samples

Page 8: ASP.NET Core deployment options

ASP.NET Core deployment in 3 easy steps:1. Restore package dependencies2. Publish your application3. Deploy to a production environment

Page 9: ASP.NET Core deployment options

ASP.NET Core during development.NET Core SDKIncludes .NET Core runtime (CLR) and tools needed to buildInstalled to a common location

Project codeProject.json, source code, static content, dynamic views, configuration

Package dependenciesInstalled centrally in your user profile (using dotnet restore)

Page 10: ASP.NET Core deployment options

ASP.NET Core in production.NET CoreInstalled centrally – just the stuff needed to run apps

Published applicationSingle folder with everything you need to run: built binaries, dependencies, etc.

Page 11: ASP.NET Core deployment options

Publish – prepare your app for deploymentRun dotnet restoreInstall package dependencies

Run dotnet publishCollect app and dependencies into a single self-contained directory structure

Run dotnet <app-assembly>.dll to run your appThe dotnet command from your .NET Core installation should be on the path

Page 12: ASP.NET Core deployment options

Publishing

Page 13: ASP.NET Core deployment options

Self-contained appsApp carries everything with it that it needs to run.NET Core doesn’t need to be pre-installedUseful for constrained environments

Runs like a normal native executableBuilt for a specific platform runtime (Windows, Linux distro, etc.)

Note: self-contained apps are significantly larger and startup may be slow due to JIT time

Page 14: ASP.NET Core deployment options

Self-contained

Page 15: ASP.NET Core deployment options

Publishing for the full .NET FrameworkTarget the full .NET Framework (net4xx)

Runs like a native .exe

All of your existing .NET dependencies work

Page 16: ASP.NET Core deployment options

Target .NET Framework

Page 17: ASP.NET Core deployment options

Microsoft.AspNetCore.Server.Kestrel

Page 18: ASP.NET Core deployment options

Hosting in productionBuilt-in web server (Kestrel)Kestrel is not yet hardened for internet facing trafficRun Kestrel behind a mature reverse proxy IIS, Nginx, Apache, etc

Internet

Kestrel

Proxy Kestrel

Kestrel

Page 19: ASP.NET Core deployment options

Publishing to IISInstall the new ASP.NET Core ModuleNative IIS module that forwards request to your applicationSupports forwarding client certs, Windows auth, IIS sub applications, app offline, logging

Setup module in web.configNew iis-publish tool will handle this for you

Point IIS at your app content rootStatic files will only be served from the web root (wwwroot)

Setup IIS integration for your ASP.NET Core hostwebHostBuilder.UseIISIntegration()

Page 20: ASP.NET Core deployment options

Publishing to IIS

Page 21: ASP.NET Core deployment options

Publishing to AzurePublish directly to Azure from Visual StudioUses WebDeployAutomate deployments using generated scripts

Use Kudu/VSTS to do continuous deploymentKudu deploy script in place for ASP.NET 5 RC1

Page 22: ASP.NET Core deployment options

Publish to Azure

Page 23: ASP.NET Core deployment options

Publishing to Linux with DockerASP.NET Core images on Docker Hubhttps://hub.docker.com/r/microsoft/aspnetcore

Docker for Windows/MacEasily build, assemble and deploy Docker based appshttps://www.docker.com/products/docker

Visual Studio Tools for Docker – PreviewEasily build images and to deploy to a Docker hosthttps://aka.ms/dockertoolsforvs

Deploy to Azure Container Service Create container hosting solutions using Apache Mesos or Docker Swarmhttps://aka.ms/azurecontainerservice

Page 24: ASP.NET Core deployment options

Docker

Page 25: ASP.NET Core deployment options

Public Cloud Other CloudsOn PremisesPrivate cloud

Lifecycle Mgmt

Independent Scaling

Independent Updates

Always On

Availability

ResourceEfficient

Stateless/Stateful

Azure Service Fabric

ASP.NET Core

Page 26: ASP.NET Core deployment options

ASP.NET Core deployment in 3 easy steps:1. Restore package dependencies2. Publish your application3. Deploy to a production environment

Page 27: ASP.NET Core deployment options

ResourcesCode: https://github.com/aspnet/homeDocs: http://docs.asp.netSamples and code: https://github.com/aspnet

Page 28: ASP.NET Core deployment options

Credit: https://www.flickr.com/photos/slightlyblurred/9235803926/

Page 29: ASP.NET Core deployment options

QUESTIONS?

@KenCenerelli