Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy

3,968 views

Published on

The .NET Platform is undergoing a revolution with a new modularized .NET Framework and CoreCLR, a new cross platform runtime. ASP.NET 5 gives .NET developers the ability to develop and run their applications outside of Windows. In this session we will explore how to develop and deploy ASP.NET 5 applications on Windows with AWS CodeDeploy and Linux with Docker. For Docker we will explore using Docker with both Elastic Beanstalk and EC2 Container Service.

Published in: Technology
  • Be the first to comment

(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy

  1. 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Norm Johanson and Steve Roberts October 2015 DEV302 Hosting ASP.NET 5 applications in AWS with Docker and AWS CodeDeploy
  2. 2. What to Expect from the Session • Learn about ASP.NET 5 development with AWS • Learn how to deploy ASP.NET 5-based applications • AWS CodeDeploy • Windows with IIS • Docker • Build and deploy as containers • Run on Linux • Deploy with AWS services: • AWS Elastic Beanstalk • Amazon EC2 Container Service (ECS)
  3. 3. Update on version 3 of the AWS SDK for .NET • General availability released July 28th • Fully modularized SDK • Separate NuGet package for each service • Depend on a common core package • Xamarin support • iOS & Android • High compatibility with version 2 • http://docs.aws.amazon.com/sdkfornet/v3/apidocs/v3- migration.html
  4. 4. What is ASP.NET 5? • Open source • Cross-platform • Modularized • Works on .NET 4.5.2, Mono, and the CoreCLR runtime • New project structure • New command-line tools • dnvm: Version manager for the runtime • dnu: Development utility, e.g. packaging • dnx: Builds and runs the application
  5. 5. Status of ASP.NET 5 • ASP.NET 5 is on Beta 7 • Microsoft roadmap for ASP.NET 5 is RC in November • 1.0.0 Q1 of 2016 • Supported in 3.2 beta versions of AWS SDK for .NET • 3.1 versions are the current stable versions
  6. 6. Coding differences for CoreCLR • Asynchronous service calls only • Credentials management • Encrypted SDK credentials store not currently supported • Supports the shared <home>.awscredentials text file • Environment variables • AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY • Use IAM roles for deployed applications
  7. 7. Demo: Pollster
  8. 8. Pollster architecture Web front end (ASP.NET 5 MVC WebApp) Poll Feed (MVC Web API) Vote Processor (MVC Web API) Poll Creator (MVC Web API) Scheduling Engine (Console Application) Code on GitHub at : https://github.com/awslabs/aws-sdk-net-samples
  9. 9. AWS services used • Amazon DynamoDB • Store Polls • Amazon Simple Workflow Service • Handle the scheduling • Amazon Simple Notification Service • Reporting poll results • Amazon CloudWatchLogs • Logging
  10. 10. Demo: Let’s take a look at the project
  11. 11. Deployment considerations • Application packaging • Deployment environment needs to support ASP.NET 5 • 5 different processes to deploy • Want to deploy services independently • Scaling the application
  12. 12. First up: AWS CodeDeploy • Deploy to Windows • Install into IIS • Bundle our runtime with the application • Deployment is fully scriptable • PowerShell or batch files
  13. 13. AWS CodeDeploy primitives • Application • Logical container for the application • Deployment group • EC2 instances • Deployment • Application bundle • appspec.yml
  14. 14. PollFeed’s appspec.yml version: 0.0 os: windows files: - source: destination: c:inetpubwwwrootPollFeed hooks: ApplicationStop: - location: .approotsrcPollFeedCodeDeployScriptsIIS_RemoveWebApp.ps1 timeout: 30 ApplicationStart: - location: .approotsrcPollFeedCodeDeployScriptsIIS_SetupWebApp.ps1 timeout: 30
  15. 15. Compute architecture Front end Feed Voter Create Scheduler EC2 instances CodeDeploy deployment group Load balancer Front end Feed Voter Create Scheduler Front end Feed Voter Create Scheduler
  16. 16. Compute Architecture (Alternative) Lower traffic services Load balancer Higher traffic services EC2 instances Front end Feed Voter Front end Feed Voter Front end Feed Voter Create Scheduler EC2 instances Create Scheduler
  17. 17. Demo: AWS CodeDeploy
  18. 18. What we learned: AWS CodeDeploy • Can still take advantage of IIS • Supports traditional .NET as well as CoreCLR • Each Pollster service can be deployed independently • Scaling • Add new instances to deployment group • Each instance runs all 5 Pollster services
  19. 19. Next up: Docker • Containerize application • Isolation • Control CPU and memory • Docker runs on Linux
  20. 20. Docker Crash Course • Image • Snapshot of your application • Container • Running instance of an image • Similar but more efficient than virtual machines • Reuse host resources until container changes them • Instant startup • Registry • Registry of images for machines running Docker to pull from • Public (Docker Hub) or private
  21. 21. Docker image layers for Pollster Debian Mono 4.0.1 ASP.NET 5 Pollster service
  22. 22. Creating Docker images for Pollster • Dockerfile • Defines the files included in the images • Defines which ports to expose • Commands to start application • Execute "docker build ..."
  23. 23. Demo: Creating Docker image
  24. 24. Using Docker with AWS Elastic Beanstalk • Single container • Suited to applications with just one process • Multicontainer • Suited to applications like Pollster that have multiple processes • Wraps EC2 Container Service and simplifies administration
  25. 25. AWS Elastic Beanstalk primitives • Application • Logical container for the application • Application version • Pointer to the application bundle in S3 • Environment • The AWS resources that run the application
  26. 26. Compute architecture Front end Feed Voter Create Scheduler Elastic Beanstalk environment Load balancer Auto Scaling group Front end Feed Voter Create SchedulerFront end Feed Voter Create Scheduler EC2 instances
  27. 27. Dockerrun.aws.json This is the application bundle • Defines the images to be deployed from registry • Defines the runtime configuration for the images • Environment variables • Memory • CPU • Port mapping
  28. 28. Demo: Docker with AWS Elastic Beanstalk
  29. 29. What we learned: Docker and Elastic Beanstalk • Simple to set up • Push images independently to the registry • All Docker containers are restarted during deployment • Scaling is similar to AWS CodeDeploy • Add another machine and all processes will start on new machine
  30. 30. EC2 Container Service (ECS)
  31. 31. EC2 Container Service primitives • Task definitions • Collection of container definitions • Each container has minimum CPU and maximum memory • Defines port mapping and environment variables • Service • Used for long-lived tasks like web services • Optionally associated with a load balancer • Cluster • EC2 instances running ECS agent • Runs tasks and services
  32. 32. Demo: ECS console
  33. 33. Compute architecture (simple) ECS cluster Load balancer EC2 Container Service (All 5 Pollster processes) EC2 instances
  34. 34. Compute architecture (advanced) Front-end Service (5 Tasks) Feed Service (3 Tasks) Vote Service (3 Tasks) Scheduler Service (2 Tasks) Creator Service (2 Tasks) EC2 instances ECS cluster
  35. 35. Deploying a new version • Build new image with new tag • Push image to registry • Update task definition to reference new image • Update service on cluster
  36. 36. Demo: Deploying a new version
  37. 37. What we learned: Docker and ECS • Redeployments only affect the tasks running that image • Lots of different scaling options • Control over how compute resources are divided • Trade simplicity for control • We control compute architecture vs. Elastic Beanstalk • Recommend CloudFormation for setup
  38. 38. What we learned in this session • ASP.NET 5 opens up new deployment possibilities • All options are equally valid • Depends on your needs • AWS CodeDeploy • Scriptable deployment with full access to Windows services • AWS Elastic Beanstalk multicontainer (Docker) • Easy way to get started Dockerizing your application • EC2 Container Service • Full control over compute architecture and container scaling
  39. 39. Links • GitHub for AWS SDK for .NET: https://github.com/aws/aws-sdk-net • GitHub for Pollster and setup scripts: https://github.com/awslabs/aws-sdk- net-samples • AWS .NET blog: https://blogs.aws.amazon.com/net/ • AWS CodeDeploy: http://aws.amazon.com/codedeploy/ • AWS Elastic Beanstalk: http://aws.amazon.com/elasticbeanstalk/ • Amazon EC2 Container Service: http://aws.amazon.com/ecs/
  40. 40. Thank you!
  41. 41. Remember to complete your evaluations!

×