Reputation: 47
I have a Multi-tenant App (ASP.NET Web Forms) on Azure, a single SQL Azure DB stores membership and each tenant has a separate SQL Azure DB for their data. Initially with 10 tenants, each tenant with around 2,000 users, but this could increase up to 50 tenants.
Am I on the right track when it comes to authentication and connecting each user to the appropriate tenant DB...
1). User authenticates with Membership DB
2). Retrieve the users TenantID (which is stored as part of User Profile)
3). Select DB Connection string from cscfg file based on TenantID
4). Store Connection string in Session (AppFabric cache)
The above approach requires storing a separate connection string per tenant within the Azure Service configuration file, which could be up to 50? Is their a better way of doing this? For instance adding an additional table to the membership DB to store connection strings? What is best practice?
Your views and opinions would be greatly received.
Thanks in advance. Ben
Upvotes: 1
Views: 1996
Reputation: 1
I think there might be issues storing membership data into a central database. the data will grow along with the growth number of tenants. The database backup need extra step to include membership data as well. I will rather keep membership data into individual tenant DB. In terms of connection string, you can use table storage or a single central db to keep tenant information and related connection string. It is not recommended to store into cscfg file as this is dynamic based on number of tenants. Just my 2 cents.
Upvotes: 0
Reputation: 1611
Another option that you could look into would be Sharding with SQL Azure:
http://blogs.msdn.com/b/sqlazure/archive/2010/12/23/10108670.aspx
Then you wouldn't need all the databases and to worry about storing all those connection strings.
Upvotes: 1
Reputation: 71118
My team built a multi-tenant sample app that you can take a look at, to get ideas about identity management, database management, etc. It maps tenant to tenant database, and also supports multiple database servers to deal with 150-database-per-server limit.
You can grab the Cloud Ninja project here.
Upvotes: 2
Reputation: 4676
I don't think there's any major problem in your solution.Ref your concern about the connection string, maybe you can use some algorithm to calculate the tenant database base from the tenant name/id.
One thing for security, when you store tenant connecting string in session, you might need to encrypt or hash, to ensure the end user will not be able to know the connection string and hack into your system.
Upvotes: 0