Continuous Deployment

12

Click here to load reader

description

An overview of continuous deployment using AppVeyor as a CI system and AWS. The tools can be re-purposed to any CI system (i.e. TeamCity)

Transcript of Continuous Deployment

Page 1: Continuous Deployment

Continuous DeploymentGIT to AWS and everything in between.

Page 2: Continuous Deployment

The CI Server – Github to Build

The CI Server has a project that is connected to a Github repo (1:1 Mapping)

Each Github repo has a single Solution file (.sln) with multiple projects

(.csproj)

The CI Server will watch the repo for changes pushed to master and trigger a

build automatically

Page 3: Continuous Deployment

The CI Server – Build to NuGet

Each build in the CI Server will have logic to generate NuSpec file for libraries

and websites (an existing NuSpec will override the default generation logic)

The NuSpec file will be ‘pack’ed into a NuGet package for each website,

library, and declared NuSpec file

Each NuPkg (package) created will be ‘push’ed to the NuGet Gallery

Library packages will be consumed from gallery while developing code to

share functionality

Website packages will be downloaded and configured on new ‘computers’ in

AWS

Page 4: Continuous Deployment

AWS – Instance Configuration Example

Page 5: Continuous Deployment

AWS – AMI Configuration

Page 6: Continuous Deployment

AWS –Instance Creation Powershell

Page 7: Continuous Deployment

Creating a new ‘computer’ in AWS

Two components:

Configuration file

Powershell script to create and configure the EC2 instance

One command will create and fully configure a new instance:

.\AWS-CreateDeployedInstance.ps1 -Credentials $creds -Region 'us-east-1' -

ConfigXml './AWS-Config.xml' -InstanceName 'MyComputersNameInConfig‘

The application(s) that are to be deployed must exist in the NuGet Gallery

and be specified in the Configuration file

Page 8: Continuous Deployment

AWS – New Instance Steps (AWS API)

The new instance will be created with the specified AMI (finding latest if

applicable; i.e. latest Windows 2012 R2 AMI from Amazon…)

The new instance will be named

The new instance get the specified EBS Volumes (disk drives) and name them

The new instance will get the specified Elastic IP attached if applicable

The new instance will get configured with certain necessary components (i.e.

IIS, ASP.NET) and Choclatey NuGet packages (i.e. Chrome, 7-Zip) using

Instance Creation Powershell

Page 9: Continuous Deployment

AWS – Instance Configuration Steps

(WinRM – Remote Powershell Commands)

When the new instance is running we will install and configure the specified

software (NuGet packages in the private gallery)

The commands will be executed via WinRM as remote commands to the new

instance

Any necessary support configuration will be installed (i.e. https certificates)

Once the packages are downloaded the appropriate mappings in IIS

Page 10: Continuous Deployment

Overview – Code to AWS

New

Instance

DEPLOYMENT POWERSHELL SCRIPT (LOCALLY RUN)

• Terminate existing and creates EC2 instance (uses

AWS API)

• Restart computer to finalize creation tasks

• Invoke remote deployment logic to configure

machine with necessary software

BUILD PROCESS

• Creates new build agent in Azure

• Fetch source from Github

• Build dlls and packages

• Push packages to NuGet Gallery

• Run StyleCop

• Run Unit Tests

NuGet Packages are pulled

Page 11: Continuous Deployment

Overview –

Detailed Deployment

New

Instance

DEPLOYMENT POWERSHELL SCRIPT (RUN LOCALLY)

• Terminate existing EC2 instance if necessary (uses AWS API)

• Creates EC2 instance (uses AWS API), with user data

INSTANCE CREATION POWERSHELL (USER

DATA)

• Install common dev tools via Choclatey

• Rename computer

• Setup WinRM for remote management

• Enable Powershell script execution

DEPLOYMENT POWERSHELL SCRIPT (CONTINUED)

• Names instance and EBS volumes

• Configures EIP if applicable

• Wait for WinRM availability

• Restart computer to finalize creation

• Wait for WinRM availability

• Invoke remote deployment logic

New

Instance

WINRM INVOKED POWERSHELL

• Install IIS and ASP.NET

• Install Certificate (passed through WinRM)

• Download application from NuGet Gallery

• Create AppPool in IIS

• Create Site in IIS pointed to download

user data

Invoke WinRM deployment

Wait for AWS to recognize instance

Page 12: Continuous Deployment

Resources

Author: Lawson Caudill – http://www.getthinktank.com

Powershell tools available at:

http://www.naosllc.com

https://github.com/NaosFramework/