@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
Multitenant web applications with
ASP.NET Core
Gunnar Peipman
ASP.NET/IIS MVP
gunnarpeipman.com
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
Many thanks to our sponsors & partners!
GOLD
SILVER
PARTNERS
PLATINUM
POWERED BY
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• What is multitenancy?
• Hosting models
• Concepts
• Demos
• Q&A
Agenda
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Presentation page: bit.ly/aspnetcoremultitenant
• Source code: bit.ly/aspnetcoremultitenantsrc
• My blog: gunnarpeipman.com
Support materials
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
WHAT IS MULTITENANCY?
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
The term "software multitenancy" refers to a software architecture in
which a single instance of software runs on a server and serves multiple
tenants.
A tenant is a group of users who share a common access with specific
privileges to the software instance.
With a multitenant architecture, a software application is designed to
provide every tenant a dedicated share of the instance - including its
data, configuration, user management, tenant individual functionality
and non-functional properties.
„Multitenancy“, Wikipedia
What is multitenancy?
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
HOSTING MODELS
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
All resources are shared between tenants
Shared model
Tenant 1 Tenant 2
App
hosting
Storage
Tenant 3 Tenant 4
App
hosting
Storage
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
Some resources are shared between tenants
Hybrid model
Tenant 1 Tenant 2
App
hosting
StorageStorage
SQL
database
CDN Cache
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
No shared resources
Dedicated model
App
hosting
Storage
Data
Tenant 1
App
hosting
Storage
Data
Tenant 2
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Customer provided environment
• Multi-instance, not multitenant hosting
• Usually special case
On-premises
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
CONCEPTS
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Tenant definition
• Tenant provider
• Missing tenant middleware
• Multitenant DbContext
Concepts
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Data structure that defines tenant technically
• Used by multitenant application
• Provided to application externally
Tenant definition
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Detects current tenant
• Provides other parts of
application with tenant
information
• Multiple
implementations
Tenant provider
ITenantProvider
DbTenantProvider FileTenantProvider
BlobTenantProvider HttpTenantProvider
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Request middleware
• Handles missing tenants
• Usually redirects to some page
• Don’t throw nasty errors
Missing tenant middleware
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Provides correct cache key for model caching
• Defensive CRUD operations
• Checks for cross-tenant operations
• Database provider agnostic
Multitenant DbContext
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
DEMO
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
• Presentation page: bit.ly/aspnetcoremultitenant
• Source code: bit.ly/aspnetcoremultitenantsrc
• My blog: gunnarpeipman.com
Support materials
@ITCAMPRO #ITCAMP18Community Conference for IT Professionals
Q & A

Multi-tenant web applications with ASP.NET Core