How to configure Serverless Azure SQL for Multiple ASP.NET Core web sites with EF Core

Siegfried Heintze 1,861 Reputation points
2021-04-10T21:59:39.36+00:00

I'm planning on hosting single instances of multiple (two for starters) ASP.NET/EF Core Web Sites in Azure Kubernetes and they need databases for persistence. These websites will be code first and not share any data structures. All of these sites will use Azure AD B2C for authentication/authorization. I'll be using multi-instance replica sets for brief demos only.

Normally using on premises SQL server I would just use the TSQL command "CREATE DATABASE" and create a couple of databases for each web site:
(1) services.AddDistributedSqlServerCache
(2) Entity Frame Work domain objects defined in C#

Ah, lets see, did I forget any other databases I might need?

Well I just learned that additional azure serverless SQL databases are not free: azure-sql-single-database-or-elastic-pool.html (I had assumed they were).

Until I can get some funding, I want to minimize my monthly azure bill (perhaps at the expense of performance)... These sites will be just proof of concept and have very little traffic.

So what options do I have? Can I get away with a single database? If so, will the "dotnet ef" tools let me do migrations for each site independently and share a single common database?

What about using the same database for different sites calling AddDistributedSqlServerCache? Can they share?

I was going to ask how to choose elastic pool v single but I see on page 26 of Practical Azure SQL Database for Modern Developers that elastic pool is not an option for serverless.

Wow! I just discovered that I can try cosmos for free! Unfortunately, I don't see cosmos on the list of candidate caches for distributed caching in ASP.NET Core. Does comos have a SQL emulation feature that would allow me to use the function AddDistributedSqlServerCache for free with Cosmos until I get get some funding?

Thanks

Siegfried

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
Azure SQL Database
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,203 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,662 questions
{count} votes

1 answer

Sort by: Most helpful
  1. David Browne - msft 3,771 Reputation points
    2021-04-11T13:54:16.617+00:00

    If you can tolerate the time it takes for a serverless database to start, then you can configure them to auto-shutdown when not in use. Or you can simply install SQL Express on Kubernetes: https://learn.microsoft.com/en-us/sql/linux/tutorial-sql-server-containers-kubernetes?view=sql-server-ver15