2. About me
• Michael Melusky (@mrjavascript)
• Lives in Harrisburg, PA
• Software Developer for Audacious Inquiry in Baltimore, MD
• College Professor (Penn State / Franklin and Marshall)
• BBQ and Lawn Care
• XBOX One
• Regular speaker at Philly.NET events (Code Camps and Monthlies)
3. What are we talking about tonight?
• “Dot Net”
• Amazon AWS and Microsoft Azure
• Serverless Computing
• AWS Lambdas and Azure Functions
• Docker
• Kubernetes
• Container Registries (ACR and ECR)
• Containers as a Service with Amazon ECS and Microsoft AKS
4. Amazon v. Microsoft
• I’m not here to cheerlead for either Microsoft or Azure
• If you are tasked with the decision of migrating from a hosted region
to the cloud
• Please don’t use this talk as sole factor in your decision
• This decision takes significant research
• Weighing pros and cons
5. Themes for Tonight
• Serverless Architecture
• Being able to deploy a product without having to worry about
underlying infrastructure
• Portability
• If you ever need to migrate from Amazon to Microsoft or vice versa…
• How difficult will that be?
7. Dot Net
• I spoke here (at Code Camp) back in November
• Showcased containerization of numerous technologies (Java, Python
et al.)
• Focusing solely on “Dot Net” this evening
• What is Dot Net?
8. Dot Net
• Software Framework from Microsoft
• You can use it for building any type of app
• Mobile, Web (MVC), Micro-Service
• Two flavors:
• .NET Framework
• .NET Core
• What is the difference between each?
9. .NET Framework
• Framework from Microsoft
• Runs primarily on Windows systems
• Does not run on Linux
• Latest version is 4.8 (April 2019)
• Does not support C# 8.0
10. .NET Core
• Framework from Microsoft
• Cross-platform (can run on Windows, Linux and Mac
OSX)
• Current version is 3.1
• C# 8.0 is supported!
14. Traditional
“Web Deploy”
• Traditionally we can deploy a .NET
Core application to IIS server
• Right click on project and “deploy”
• How else can we deploy?
• Where can we deploy to?
16. Cloud Providers
• Tonight we’re going to look at two cloud providers
• Amazon and Microsoft
• Amazon AWS
• Microsoft Azure
17. Amazon AWS
• On-demand cloud computing platform
• Servers in 22 geographic regions
• 60+ managed services
• Managed services such as services for
queueing, relational database services,
caching
• Two managed services we are
interested in for tonight:
• AWS Lambdas
• Containerization Services
18. Microsoft Azure
• Cloud computing platform
• Servers available in 52 geographic
regions
• Multiple managed services very similar
to AWS
• Such as Cosmos DB, Azure Cache, Azure
Search, et al
• Of note for tonight:
• Azure Functions
• Azure Container Services
20. Functions
• Relate an input to an output
• Examples:
• X^2 (squaring)
• X^3 + 1
• Trigonometric functions (sin, cos, tan)
21. How does this relate to Azure and AWS?
• Both cloud providers offers “functions”
• Allows you to run a “quick piece of code” on Microsoft/Amazon’s
hardware
• Azure Functions: runtime cannot exceed 5 minutes
• AWS Lambdas: runtime cannot exceed 15 minutes
• Let’s look at both providers
23. Creating Azure Function
• Let’s implement the previous
example with an Azure Function
• Can write the function in a variety
of languages
• Let’s use .NET Core
• Install “Azure Development”
option with Visual Studio
• ** DEMO **
24. Creating AWS Lambda
• Now let’s do the same with AWS!
• Like Azure, many languages are supported (Java, Python, etc.)
• Like before, let’s use .NET Core
• The Visual Studio project templates come from AWS Toolkit for Visual
Studio: https://aws.amazon.com/visualstudio/
• ** DEMO **
26. What’s the difference between the two?
• We implemented the same function for different cloud providers
• Both are .NET Core implementations
• Looking at the code can the AWS Lambda run in Azure Functions?
• And vice versa?
27. Functions in Cloud Providers
• Functions/Lambdas are provider dependent
• Hypothetically consider the case of an AWS customer
• With 100+ Lambdas
• Requirement to migrate the cloud infrastructure to Azure
• How will the lambdas transfer?
• (Spoiler alert: rewrite)
28. “Functions as a Service” (FaaS)
• Both AWS Lambdas and Azure Functions fall under the “Functions as
a Service” model (FaaS)
• Developers simply write the code and run the application
• Don’t have to worry about the infrastructure management
29. Acronyms
• IaaS – Infrastructure as a Service
• Caas – Containers as a Service
• PaaS – Platform as a Service
• FaaS – Functions as a Service
31. Benefits of Serverless Computing
• As a developer (that’s you), don’t need to worry about the following:
• Security updates
• Anti-virus software
• Operating System Updates
• Hardware Upgrades
• You simply write, deploy and run code!
32. Serverless Computing
• Since we identified that the servers are managed by the cloud
provider
• What do we know about the underlying infrastructure?
• Mostly abstracted, but we can assume:
• Linux!
• (Azure has Windows in Preview discussion coming soon)
33. Linux
• Since these host servers run Linux,
the code we write needs to run on
this operating system
• Main reason why we want .NET
Core!
• .NET Core is cross platform
(Windows, Mac OSX, Linux)
• You can’t write AWS Lambdas
using .NET Framework 4.8
34. TL;DR; version
• As developers, we like Serverless Computing
• If we’re working with .NET Core deployment is a breeze
• Only downside so far?
• Lambdas and platforms are provider dependent
• Is there a solution where we have serverless benefits but also cloud
provider independence?
36. Azure Service Fabric
• Platform as a Service (PaaS) from
Microsoft
• Allows you to build and deploy
micro-services with ease
• Runs in containers
• Facilitates solutions for
communication between micro-
services
• Also facilitates container
orchestration
37. Building a Backend
• Choice for building a backend API for front end apps
• Technically you can run your backend API in AWS Lambda
• Not necessarily purpose of Lambda, meant for quick, serverless code
invocations
• Can use Azure Service Fabric for the backend
• Main downside of Azure Service Fabric?
• You are locked in with Azure
• Is there a portable alternative?
39. Docker
• Docker is software which provides
the concept of application
containerization
• Uses OS virtualization under the
hood
40. Containerization?
• A technique which allows you to deploy distributed applications
without launching a virtual machine for each app!
• Each application (or instance of the application) is isolated from each
other
• All code and resources and configuration needed to run the
application is part of the container
• Containers differ from virtual machines
42. Docker
• Can install the Docker Engine from Docker Hub
• Docker Desktop is available for Mac OSX and Windows
• With Docker for Windows, Windows 10 Professional is required
• Virtualization is needed
44. Docker Images
• Docker Containers are instances of Docker Images
• So for us to run our applications in the Docker Engine, we will need to
build a Docker Image (coming soon)
• For now let’s look at the Docker Command Line Interface (CLI)
• As well as some common commands
45. “docker images”
• Will show all “top level” images
• Included in response is the tag, the size, creation date
46. “docker ps”
• Lists all running containers
• If you want to see all containers (e.g. stopped containers)
• docker ps –a
47. Running a Docker Image
• docker run
• Allows you to run container using an image
• docker stop
• Allows you to stop a particular container
49. Building the .NET Core Image
• To run the .NET Core application
in Docker we need to build an
image to run on the Docker
engine
• For building images, we are
required to provide a Dockerfile
50. Dockerfile
• A Dockerfile is a file that lists instructions needed for building a image
• Based off a source image
• You can run OS commands in the Dockerfile as well (move, copy, et
al.)
• You can also expose any port numbers your application uses
51. Dockerfile ports
• Generally for web applications we expose either 80 or 8080
• We can also expose the secure ports if we want as well (443 and
8443)
• Docker allows you to port forward from a source port
• For instance if you want to expose 5050 as your external port and
route to the internal (exposed) port 80, Docker allows this
• Incredibly useful for cloud providers where AWS/Azure will assign
these ports dynamically at runtime
52. Dockerfile and .NET Core
• Let’s build our application for Docker
• That is produce an image using a Dockerfile
• And then run the image on the Docker engine
• ** DEMO **
54. Docker and .NET
• With the Docker image we just build, we build for .NET Core
• With this .NET Core image, the image can run on any host operating
system (Windows, Linux, et al.)
• What about .NET Framework (4.X)?
• Yes, you can containerize a .NET Framework application!
• However this image can only run on Docker Engine on Microsoft
Windows hosts
56. Containers as a Service (CaaS)
• We saw Functions as a Service earlier tonight
• Do cloud providers have the same ability except being able to run
Docker containers on demand?
• Yes!
58. Kubernetes (K8S)
• Open-source container
orchestration software
• Will monitor the health of the
containers
• If a container dies, Kubernetes will
restart the container
59. Kubernetes
• Used in many applications
• For instance, Red Hat’s OpenShift platform is based on Kubernetes
• The Telcom industry uses it for cable management and routing!
• Both Microsoft and Amazon offer managed services for Kubernetes
clusters
• Amazon offers EKS (Elastic Kubernetes Service)
• Azure offers AKS (Azure Kubernetes Service)
60. Wait…
• The Meetup.com description for this event
• Listed “No Kubernetes Required!”
• Unfortunately, we will be using some K8 tonight
• At least with Azure
62. Containers as a Service (CaaS)
• Both Amazon and Microsoft offer the managed service for running
your containers
• Both Microsoft and Amazon offer two different managed services for
each
• One managed service is based on proprietary technology
• The other managed service is based on K8
• Let’s look in the console for each
• ** DEMO **
63. Containers and Cloud Providers
Provider Managed Service Service Type Notes
Amazon
Elastic Container
Service (ECS)
Proprietary
Elastic Kubernetes
Service (EKS)
Kubernetes
Microsoft
Azure Container
Service (ACS)
Proprietary End of life
1/31/2020
Azure Kubernetes
Service (AKS)
Kubernetes
64. About Me
• I personally use AWS for both full time job and side projects
• ECS is used actively in each
• When preparing this session, I emailed a Microsoft Developer
• I was able to contact someone on the Azure Product Team
• Azure team member was confused about this presentation, and told
me to learn Kubernetes
• Microsoft is sunsetting (end of month) Azure Container Services (ACS)
and is mandating customers migrate to Azure Kubernetes Services
(AKS)
65. Amazon and ECS
• What I also found out from this exchange
• Amazon considers ECS a legacy product
• Eventually customers will presumably need to migrate to EKS
• If Microsoft’s decision is any predictor of future events
67. Plan for Tonight
• Originally was planning to show both ECS and ACS
• Technically I can still demonstrate ACS since it’s available for one
more week
• But there would be more value doing the same demonstration using
AKS
68. Amazon AWS - ECS
• Proprietary solution from Amazon to
dynamically run and orchestrate
Docker containers
• You can specify how many instances
of the application you want to run
• ECS will automatically scale up and
down the instances based on load
• Make sure your code can run in
parallel and be careful about mutual
exclusion and locking!
69. Amazon AWS ECS
• For running Docker images in the cloud
• Amazon needs to be able to pull your image from a repository
• You have a few options
• If your image is public, you can simply push to Docker Hub
• However most code is proprietary, and the general public shouldn’t
be allowed to pull the image
71. Amazon ECR
• Elastic Container Registry
• Managed service from Amazon to
store Docker images (as well as
their tags)
• Microsoft offers a similar
managed service
• Azure Container Registry (ACR)
72. Pushing to container registry
• To push to ECR
• (1) Build the image (using docker build)
• (2) Obtain credentials from Amazon (with docker login command)
• (3) Optionally tag the image (otherwise latest is default tag)
• (4) Push the Image to ECR (or ACR) using docker push
• ** DEMO **
74. Amazon ECS tasks
• With ECS, each instance of the Docker image is based off an ECS Task
• An ECS task specifies:
• Which Docker image is used
• How much memory each instance
• How much vCPU should be allocated
• Let’s create our ECS task for the .NET Core application
• ** DEMO **
76. Running the task in ECS
• With our ECS task created, now we can create the service in ECS
• When we do this, we need to specify the Docker Engine the task will
run against
• Amazon gives you two options
• Docker Engine on an EC2 instance you provide (virtual machine)
• AWS Fargate (serverless!)
77. AWS Fargate
• Serverless approach for running Docker
images
• Containers run on Amazon’s underlying
Docker Engine
• Under the hood: LINUX
• With regards to .NET, .NET Core will work
with Fargate since it’s cross platform
• .NET Framework 4.8 WILL NOT WORK with
Fargate since that requires Windows
Docker Engine
• You can use ECS with .NET Framework but a
backing Windows EC2 instance is needed!
78. AWS Fargate
• Let’s create a service now in ECS for our task
• And run our .NET Core application in AWS Fargate
• ** DEMO **
80. Similarities to AWS
• As mentioned earlier, Microsoft is ending Azure Container Services
(ACS)
• We need to spin up a Kubernetes cluster in AKS
• There are some similar steps however
• Let’s push our Docker image to Azure Container Registry (ACR)
• Let’s then deploy our image into AKS (using their serverless runtime
called Azure Container Instances or ACI)
• ** DEMO **
82. Serverless Matrix
Provider Managed Service Type Host OS Notes
Amazon
AWS Lambda FaaS Linux
ECS/EKS Fargate CaaS Linux Fargate support for
EKS added 12/2019
Microsoft
Azure Functions FaaS Linux
AKS with Container
Instances
CaaS Linux and Windows Windows is in
Preview
83. Next Steps for Me
• Since I use AWS
• Spin up EKS cluster for personal micro-services
• Test and eventually cut over from ECS
• But will bite the bullet and learn Kubernetes
86. Thank you for Coming
• Visual Studio Solution (code) is on Github
• https://github.com/mrjavascript/phillynet_jan2020
• Slides on SlideShare
• @mrjavascript