SlideShare a Scribd company logo
Building 12 Factor Apps
with .NET Core.
Serhiy Kalinets
Steer73
About Me
17 years in the business
In .NET since 2005
Love to code
Technical Architect
@ Steer73
@skalinets 2
@skalinets 3
Facebook Groups
Lviv .NET User Group
.NET Core Ukrainian User Group
Kiev ALT.NET
@skalinets 4
Monolith vs Microservices
@skalinets 5
Here comes .NET Core
@skalinets 6
Why Cloud Ready Apps?
Cost-effective
Failure-resilient
@skalinets 7
Why Cloud Ready Apps?
Reuse of existing infrastructure
Works for non-cloud apps as well
@skalinets 8
Pets vs Cattle
@skalinets 9
12 Factor Apps
Use declarative formats for setup automation, to
minimize time and cost for new developers joining the
project;
@skalinets 10
12 Factor Apps
Have a clean contract with the underlying operating
system, offering maximum portability between
execution environments;
@skalinets 11
12 Factor Apps
Are suitable for deployment on modern cloud
platforms, obviating the need for servers and systems
administration;
@skalinets 12
12 Factor Apps
Minimize divergence between development and
production, enabling continuous deployment for
maximum agility;
@skalinets 13
12 Factor Apps
Can scale up without significant changes to tooling,
architecture, or development practices.
@skalinets 14
I. Codebase
One codebase tracked in revision control,
many deploys
@skalinets 15
I. Codebase
A codebase is any single repo
A deploy is a running instance
of the app
The codebase is the same
across all deploys
@skalinets 16
II. Dependencies
Explicitly declare and isolate dependencies
@skalinets 17
II. Dependencies
Use a package manager
Never rely on implicit existence of system-wide
packages
Do not rely on the implicit existence of any system tools
@skalinets 18
Package Manager: Paket
Supports Nuget feeds
Manages transient dependencies, locks out versions
Considered to be faster than Nuget but in some cases is
slower
@skalinets 19
III. Config
Store config in the environment
@skalinets 20
III. Config
An app’s config is everything that is likely to vary
between deploys
Does not include app internal config (routes, mappings
etc.)
@skalinets 21
Config litmus test
An app has all config correctly factored out of the code
is when
The codebase could be made open source at any
moment, without compromising any credentials.
@skalinets 22
Configuration Files
Avoid using appsettings.<env>.json. The only feasible
use is to store your local dev stuff
Transformations during deployment requires additional
setup and is error prone
Set of different configs per env scales badly
@skalinets 23
Vendor Specific Configuration Source
E.g. App settings, Key Vault in Azure
Can simplify deployment and operations
Violate 12 factor apps (vendor lock)
@skalinets 24
Environment variables
Easy to manage by devops
Cannot be checked to source code
OS / Platform agnostic
Scale up smoothly
@skalinets 25
.NET Core Configuration
WebHost.CreateDefaultBuilder() contains
AddJsonFile(…,"appsettings.json", …)
AddUserSecrets()
AddEnvironmentVariables()
AddCommandLine()
@skalinets 26
User Secrets
cli tool Micosoft.Extensions.SecretManager.Tools
dotnet user-secrets set "foo" "boo“
@skalinets 27
.NET Tips
Use configuration objects as sessions
Define baseline config in appsettings.json
Override with env variables, app settings, user secrets
@skalinets 28
IV. Backing services
Treat backing services as attached resources
@skalinets 29
IV. Backing services
A backing service is any service the app consumes over
the network as part of its normal operation
Locally managed services should not be distinguished
from third party services
@skalinets 30
@skalinets 31
V. Build, release, run
Strictly separate build and run stages
@skalinets 32
Codebase Deployment Stages
Build
Release
Run
@skalinets 33
Build
Converts a code repo into an executable bundle known
as a build
Might (and should) include running tests, code analysis
etc.
@skalinets 34
Tools: FAKE (F# Make)/ Cake
Build as a code (C# or F#), not XML or boxes with
arrows
Versioned. If new features need build procedure
update, we just update and commit the build script
No coupling to CI tool, can be run from anywhere,
including devs’ machines
@skalinets 35
Release
A unique ID should be assigned to each release
Releases are immutable, any change to environment
should be done with a new release
Use tools like Octopus / Jenkins Blue Ocean / VSTS etc.
@skalinets 36
Run
Handled by process managers / orchestrator, not
humans
Should have as few moving part as possible
@skalinets 37
VI. Processes
Execute the app as one or more stateless
processes
@skalinets 38
VI. Processes
Should be stateless and “share nothing”
Bundle assets during the build
No shared memory / disks
No sticky sessions
@skalinets 39
VII. Port binding
Export services via port binding
@skalinets 40
VII. Port binding
The twelve-factor app is completely self-contained and
does not need web or other host
Web server functionality is exposed by binding to a
port
@skalinets 41
Port binding in .NET
WebHostBuilder().UseKestrel()
@skalinets 42
VIII. Concurrency
Scale out via the process model
@skalinets 43
VIII. Concurrency
Processes are a first class citizen
Using the unix process model for running service
daemons
Processes are managed by process managers /
orchestrators
@skalinets 44
@skalinets 45
IX. Disposability
Maximize robustness with fast startup and
graceful shutdown
@skalinets 46
IX. Disposability
Strive to minimize startup time to provide more agility
for the release process, scaling up and robustness
Shut down gracefully when receive a SIGTERM signal
from the process manager
@skalinets 47
During Shutdown
Web processes should not accept new request during
shut down, finish current ones
Worker processes should return unprocessed item
back to the queue
@skalinets 48
X. Dev/prod parity
Keep development, staging, and production
as similar as possible
@skalinets 49
Gaps between dev and prod
The time gap: Code that takes days, weeks, or even
months to go into production
The personnel gap: Developers write code, ops
engineers deploy it
The tools gap: Developers use other stack than is on
producttion
@skalinets 50
Minimizing Gaps
The time gap: write code and deploy it to prod in hours
or minutes
The personnel gap: developers are involved in
deploying and monitoring their code in prod
The tools gap: use the same services on dev and prod
@skalinets 51
X. Dev/prod parity
All environments should have the same topology
Size might differ (for cost efficiency)
Use chocolatey / docker for running backing services
locally
@skalinets 52
XI. Logs
Treat logs as event streams
@skalinets 53
XI. Logs
Logs provide visibility into the behavior of a running
app
Stream of aggregated, time-ordered events collected
from the output streams of all running processes and
backing services
@skalinets 54
XI. Logs
A twelve-factor app never concerns itself with routing
or storage of its output stream
Write logs to stdout instead
Execution environment captures, routes and stores
logs
@skalinets 55
Logging tips (not 12 factor apps )
Use structured logging (Serilog)
In simple setups it’s might be OK to route logs from the
app (Serilog AppInsights sink)
Don’t save logs to your database
@skalinets 56
XII. Admin processes
Run admin/management tasks as one-off
processes
@skalinets 57
XII. Admin processes
Examples: EF migrations with dotnet ef
Should be bundled with release
Source versions should match
@skalinets 58
Thanks!
kalinets@gmail.com
@skalinets
https://skalinets.github.io
@skalinets 59

More Related Content

PPTX
Power platform Bootcamp Bulgaria 2021 - Power Platform Security
PDF
Hexagonal Architecture.pdf
PDF
Training Webinar: Top front-end techniques for OutSystems
PDF
Sketching With SolidWorks
PPTX
The 4-Layer Architecture in Practice
PPTX
Customer engagement solution architecture and Dynamics 365 Portals
PPTX
Power Apps Accessibility.pptx
PPT
ansys presentation
Power platform Bootcamp Bulgaria 2021 - Power Platform Security
Hexagonal Architecture.pdf
Training Webinar: Top front-end techniques for OutSystems
Sketching With SolidWorks
The 4-Layer Architecture in Practice
Customer engagement solution architecture and Dynamics 365 Portals
Power Apps Accessibility.pptx
ansys presentation

What's hot (14)

PDF
Adobe Analytics
PPTX
Process planning activities
PPTX
Ppt on catia
PPTX
SOLIDWORKS VOCATIONAL TRAINING PROJECT
PPTX
Introduction to Fusion 360
PDF
Microsoft Dynamics 365 Business Central - ITA
PDF
Preparing, Piloting & Paths to Success with Microsoft Copilot
PDF
Autodesk Fusion 360: The Power of CAD in the Cloud
PPSX
Agile, User Stories, Domain Driven Design
PDF
Training Webinar: Fitting OutSystems applications into Enterprise Architecture
PPTX
laser engineered net shaping (lens) of mechanical engineering
PPTX
Introduction to Microsoft Power Platform (PowerApps, Flow)
PPTX
Unit 4-ME8691 & COMPUTER AIDED DESIGN AND MANUFACTURING
PDF
Fusion 360 training course
Adobe Analytics
Process planning activities
Ppt on catia
SOLIDWORKS VOCATIONAL TRAINING PROJECT
Introduction to Fusion 360
Microsoft Dynamics 365 Business Central - ITA
Preparing, Piloting & Paths to Success with Microsoft Copilot
Autodesk Fusion 360: The Power of CAD in the Cloud
Agile, User Stories, Domain Driven Design
Training Webinar: Fitting OutSystems applications into Enterprise Architecture
laser engineered net shaping (lens) of mechanical engineering
Introduction to Microsoft Power Platform (PowerApps, Flow)
Unit 4-ME8691 & COMPUTER AIDED DESIGN AND MANUFACTURING
Fusion 360 training course
Ad

Similar to Building 12 factor apps with ASP.NET Core, Сергій Калинець (20)

PDF
PDF
PPTX
Microservices
PPTX
Docker12 factor
PPTX
The twelve factor app
PDF
Cloud-Native Fundamentals: An Introduction to 12-Factor Applications
PDF
The twelve factor app
PDF
Rappel 12 facteurs.pdf
PDF
The 12 Factor App
PPTX
Build 12-Factor apps with Docker
PDF
15-factor-apps.pdf
PDF
The Twelve Factor Apps
PDF
Twelve factor apps
PDF
12 factor app
PDF
The Twelve Factor App
PDF
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
PPTX
12 Factor App Methodology
PPTX
Hello cloud 6
PPTX
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
PPTX
12 Factor App
Microservices
Docker12 factor
The twelve factor app
Cloud-Native Fundamentals: An Introduction to 12-Factor Applications
The twelve factor app
Rappel 12 facteurs.pdf
The 12 Factor App
Build 12-Factor apps with Docker
15-factor-apps.pdf
The Twelve Factor Apps
Twelve factor apps
12 factor app
The Twelve Factor App
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
12 Factor App Methodology
Hello cloud 6
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
12 Factor App
Ad

More from Sigma Software (20)

PPTX
Fast is Best. Using .NET MinimalAPIs
PPTX
"Are you developing or declining? Don't become an IT-dinosaur"
PPTX
Michael Smolin, "Decrypting customer's cultural code"
PPTX
Max Kunytsia, “Why is continuous product discovery better than continuous del...
PPTX
Marcelino Moreno, "Product Management Mindset"
PDF
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
PPTX
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
PPTX
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
PPTX
Stoyan Atanasov “How crucial is the BA role in an IT Project"
PPTX
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
PPTX
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
PPTX
VOLVO x HACK SPRINT
PPTX
Business digitalization trends and challenges
PPTX
Дмитро Терещенко, "How to secure your application with Secure SDLC"
PPTX
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
PDF
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
PDF
Training solutions and content creation
PDF
False news - false truth: tips & tricks how to avoid them
PPTX
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
PPTX
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...
Fast is Best. Using .NET MinimalAPIs
"Are you developing or declining? Don't become an IT-dinosaur"
Michael Smolin, "Decrypting customer's cultural code"
Max Kunytsia, “Why is continuous product discovery better than continuous del...
Marcelino Moreno, "Product Management Mindset"
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
Stoyan Atanasov “How crucial is the BA role in an IT Project"
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
VOLVO x HACK SPRINT
Business digitalization trends and challenges
Дмитро Терещенко, "How to secure your application with Secure SDLC"
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
Training solutions and content creation
False news - false truth: tips & tricks how to avoid them
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Introduction to Artificial Intelligence
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
AI in Product Development-omnex systems
PDF
How Creative Agencies Leverage Project Management Software.pdf
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Odoo POS Development Services by CandidRoot Solutions
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Introduction to Artificial Intelligence
wealthsignaloriginal-com-DS-text-... (1).pdf
Softaken Excel to vCard Converter Software.pdf
AI in Product Development-omnex systems
How Creative Agencies Leverage Project Management Software.pdf

Building 12 factor apps with ASP.NET Core, Сергій Калинець

  • 1. Building 12 Factor Apps with .NET Core. Serhiy Kalinets Steer73
  • 2. About Me 17 years in the business In .NET since 2005 Love to code Technical Architect @ Steer73 @skalinets 2
  • 4. Facebook Groups Lviv .NET User Group .NET Core Ukrainian User Group Kiev ALT.NET @skalinets 4
  • 6. Here comes .NET Core @skalinets 6
  • 7. Why Cloud Ready Apps? Cost-effective Failure-resilient @skalinets 7
  • 8. Why Cloud Ready Apps? Reuse of existing infrastructure Works for non-cloud apps as well @skalinets 8
  • 10. 12 Factor Apps Use declarative formats for setup automation, to minimize time and cost for new developers joining the project; @skalinets 10
  • 11. 12 Factor Apps Have a clean contract with the underlying operating system, offering maximum portability between execution environments; @skalinets 11
  • 12. 12 Factor Apps Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; @skalinets 12
  • 13. 12 Factor Apps Minimize divergence between development and production, enabling continuous deployment for maximum agility; @skalinets 13
  • 14. 12 Factor Apps Can scale up without significant changes to tooling, architecture, or development practices. @skalinets 14
  • 15. I. Codebase One codebase tracked in revision control, many deploys @skalinets 15
  • 16. I. Codebase A codebase is any single repo A deploy is a running instance of the app The codebase is the same across all deploys @skalinets 16
  • 17. II. Dependencies Explicitly declare and isolate dependencies @skalinets 17
  • 18. II. Dependencies Use a package manager Never rely on implicit existence of system-wide packages Do not rely on the implicit existence of any system tools @skalinets 18
  • 19. Package Manager: Paket Supports Nuget feeds Manages transient dependencies, locks out versions Considered to be faster than Nuget but in some cases is slower @skalinets 19
  • 20. III. Config Store config in the environment @skalinets 20
  • 21. III. Config An app’s config is everything that is likely to vary between deploys Does not include app internal config (routes, mappings etc.) @skalinets 21
  • 22. Config litmus test An app has all config correctly factored out of the code is when The codebase could be made open source at any moment, without compromising any credentials. @skalinets 22
  • 23. Configuration Files Avoid using appsettings.<env>.json. The only feasible use is to store your local dev stuff Transformations during deployment requires additional setup and is error prone Set of different configs per env scales badly @skalinets 23
  • 24. Vendor Specific Configuration Source E.g. App settings, Key Vault in Azure Can simplify deployment and operations Violate 12 factor apps (vendor lock) @skalinets 24
  • 25. Environment variables Easy to manage by devops Cannot be checked to source code OS / Platform agnostic Scale up smoothly @skalinets 25
  • 26. .NET Core Configuration WebHost.CreateDefaultBuilder() contains AddJsonFile(…,"appsettings.json", …) AddUserSecrets() AddEnvironmentVariables() AddCommandLine() @skalinets 26
  • 27. User Secrets cli tool Micosoft.Extensions.SecretManager.Tools dotnet user-secrets set "foo" "boo“ @skalinets 27
  • 28. .NET Tips Use configuration objects as sessions Define baseline config in appsettings.json Override with env variables, app settings, user secrets @skalinets 28
  • 29. IV. Backing services Treat backing services as attached resources @skalinets 29
  • 30. IV. Backing services A backing service is any service the app consumes over the network as part of its normal operation Locally managed services should not be distinguished from third party services @skalinets 30
  • 32. V. Build, release, run Strictly separate build and run stages @skalinets 32
  • 34. Build Converts a code repo into an executable bundle known as a build Might (and should) include running tests, code analysis etc. @skalinets 34
  • 35. Tools: FAKE (F# Make)/ Cake Build as a code (C# or F#), not XML or boxes with arrows Versioned. If new features need build procedure update, we just update and commit the build script No coupling to CI tool, can be run from anywhere, including devs’ machines @skalinets 35
  • 36. Release A unique ID should be assigned to each release Releases are immutable, any change to environment should be done with a new release Use tools like Octopus / Jenkins Blue Ocean / VSTS etc. @skalinets 36
  • 37. Run Handled by process managers / orchestrator, not humans Should have as few moving part as possible @skalinets 37
  • 38. VI. Processes Execute the app as one or more stateless processes @skalinets 38
  • 39. VI. Processes Should be stateless and “share nothing” Bundle assets during the build No shared memory / disks No sticky sessions @skalinets 39
  • 40. VII. Port binding Export services via port binding @skalinets 40
  • 41. VII. Port binding The twelve-factor app is completely self-contained and does not need web or other host Web server functionality is exposed by binding to a port @skalinets 41
  • 42. Port binding in .NET WebHostBuilder().UseKestrel() @skalinets 42
  • 43. VIII. Concurrency Scale out via the process model @skalinets 43
  • 44. VIII. Concurrency Processes are a first class citizen Using the unix process model for running service daemons Processes are managed by process managers / orchestrators @skalinets 44
  • 46. IX. Disposability Maximize robustness with fast startup and graceful shutdown @skalinets 46
  • 47. IX. Disposability Strive to minimize startup time to provide more agility for the release process, scaling up and robustness Shut down gracefully when receive a SIGTERM signal from the process manager @skalinets 47
  • 48. During Shutdown Web processes should not accept new request during shut down, finish current ones Worker processes should return unprocessed item back to the queue @skalinets 48
  • 49. X. Dev/prod parity Keep development, staging, and production as similar as possible @skalinets 49
  • 50. Gaps between dev and prod The time gap: Code that takes days, weeks, or even months to go into production The personnel gap: Developers write code, ops engineers deploy it The tools gap: Developers use other stack than is on producttion @skalinets 50
  • 51. Minimizing Gaps The time gap: write code and deploy it to prod in hours or minutes The personnel gap: developers are involved in deploying and monitoring their code in prod The tools gap: use the same services on dev and prod @skalinets 51
  • 52. X. Dev/prod parity All environments should have the same topology Size might differ (for cost efficiency) Use chocolatey / docker for running backing services locally @skalinets 52
  • 53. XI. Logs Treat logs as event streams @skalinets 53
  • 54. XI. Logs Logs provide visibility into the behavior of a running app Stream of aggregated, time-ordered events collected from the output streams of all running processes and backing services @skalinets 54
  • 55. XI. Logs A twelve-factor app never concerns itself with routing or storage of its output stream Write logs to stdout instead Execution environment captures, routes and stores logs @skalinets 55
  • 56. Logging tips (not 12 factor apps ) Use structured logging (Serilog) In simple setups it’s might be OK to route logs from the app (Serilog AppInsights sink) Don’t save logs to your database @skalinets 56
  • 57. XII. Admin processes Run admin/management tasks as one-off processes @skalinets 57
  • 58. XII. Admin processes Examples: EF migrations with dotnet ef Should be bundled with release Source versions should match @skalinets 58