The next revolution in the software industry will be SaaS cloud-based applications. In 2020, you will see many SaaS applications coming out on the market. Nowadays, there are many technologies available that make building SaaS applications easier. The recent release of the cross-platform ASP.NET Core 3.1, which is battle-tested and performs on par with other technologies, is an ideal choice to build a SaaS application if you are already familiar with .NET.

In this post, you will find some useful tips and libraries that will help you get a head start on your SaaS application using ASP.NET Core and Azure.

Setting up a project structure

First, to start your application, set up a project structure. There are some good projects and architectural references that I listed in my previous blog. Some top project templates to look at when starting a project are:

Also, I suggest watching this video on clean architecture by Jason Taylor.

Multitenancy

The next important step in building a SaaS application is to handle multitenancy, the serving of multiple tenants using a single instance of an application. To handle multitenancy, there are several open-source libraries available that will provide boilerplate code. Some of the top libraries in this category are:

You can also check out blog posts on multitenancy by Ben Foster or Gunnar Peipman. These blogs will help you in setting up multitenancy in your project.

Error logging

Error logging is also one of the important things to include in your project. There are several open-source libraries available, some of the top libraries in this category are:

Health checks

Health checks are used to monitor an application. When you are developing a system with microservice architecture, this is one of the important things to consider. ASP.NET Core provides inbuilt health check options, and if you need a UI for monitoring the health of your microservices, then check out this library AspNetCore.Diagnostics.HealthChecks.

Authentication

ASP.NET Core now ships with IdenityServer4. This library provides most authentication-related functionalities. Check out this project, JPProject.IdentityServer4.AdminUI, which demonstrates many features of identity server. Also, you can check out blog posts by Scott Brady, as he writes useful, informative posts about Identity Server.

Authorization

Authorization is important in an application. There are different types of authorization techniques:

Role-based authorization

Policy-based authorization

Based on your application, select the one that best suits your needs. I recommend you check out this blog post on a better way to handle authorization in ASP.NET Core.

Feature management

In a SaaS application, you may have different pricing plans for products. Depending on the pricing plan, some features will be shown or hidden. Microsoft Feature Management is handy for implementing pricing plan-based features. Check out blogs by Andrew Lock related to Microsoft.FeatureManagement.

Security

Web applications are prone to vulnerabilities, so you must pay attention to the security of your application by adding strong authentication, authorization, encryption, and security headers. Some informative posts and resources related to security are:

Validation

ASP.NET Core provides built-in attribute-based validations. But if you need a cleaner way to write validation, then do check out the Fluent Validation library.

Caching

Caching helps in improving the performance of an application and is one of the areas that needs to be considered, especially in a multitenant application. There are two types of caching:

In-memory caching

Distributed caching—Redis is preferred for SaaS applications

If you are using Redis for caching, then this library will help you: StackExchange.Redis.

Microservice communication

In microservices, there needs to be reliable intercommunication among APIs. There are two types of communication:

HTTP-based

gRPC

If you are using HTTP-based communication, then check out the Polly library.

API gateway and reverse proxy

In microservice applications, you will need an API gateway to serve as a front-end for the back-end. Two popular libraries are:

You can also use Ngnix or the Azure API gateway for this purpose.

Documentation

There are several libraries available for documentation. Some of the top open-source libraries in this category are:

Scheduler

To run background jobs for your application, there are some good libraries:

You can also build background jobs using .NET Core Worker services and host in Azure as a Web Jobs.

Testing

Automated testing is one of the important areas to consider. There are different types of automated testing available:

In Entity Framework Core, an in-memory database was introduced that helps make testing for database logics easier without the overhead of actual database operations.

There are some good libraries available that will help you in writing unit testing:

A few more useful libraries:

Code quality analyzers and linting

Code quality static analyzers tools help in writing code with proper standards and in maintaining quality. There are several open-source analyzers available in .NET Core. You can find the top 10 analyzers in this article. This process can be integrated in continuous integration using Cake Script.

Front-end

Three popular front-end frameworks are Angular, React, and Vue. There is a long-running debate on which is better. In my opinion, Angular is good for building enterprise applications, even though it has a steep learning curve. Angular is a complete framework that has several functionalities built into its framework, unlike React or Vue. As I said, superiority is debatable based on your expertise and needs. You can choose any one of them and do well.

Database

There are two popular databases available in Azure

MS SQL—Elastic Pool

Cosmo DB—NoSQL database

If you are going to use database-per-tenant architecture, then MS SQL Elastic Pool is a better choice. You can add up to 500 databases in one elastic pool, so it’s cost-effective. There are other storage models as well in SaaS, and which you choose depends on your application needs. A reference for other models can be found on this Microsoft page.

Deployment

For deployment of an application, there are several options available. The best option is to deploy on the cloud, which allows you to scale, monitor, and load-balance your application. There are several ways to do this

Deploy app in Azure App Service for Linux, containers, or Windows.

Deploy app in Azure Kubernetes or Google Kubernetes.

Deploy in VMs.

The simplest of all these is to deploy in the Azure App Service. You can find a guide on how to do that in this article. Azure App Service supports scaling up to 20 instances with its Traffic Manager. If your app needs more scaling options, then Kubernetes is best.

Azure service

There are several Azure services available for SaaS application development. Some of the most commonly used services are:

A directory of Azure Services can be found on the Azure site.

Conclusion

I hope these tips and libraries will help you get a head start on your SaaS application. You can also check out the Azure Application Architecture Guide.

Syncfusion also provides several controls for Angular, React, Vue, and ASP.NET Core that will further ease your development of a SaaS application. For example, Syncfusion provides 70+ high-performance, lightweight, modular, and responsive ASP.NET Core UI controls such as DataGrid, Charts, and Scheduler. You can use them to improve your application development.

Please share your feedback in the comments section. You can also contact us through our support forum, Direct-Trac, or feedback portal. We are waiting to hear your feedback!