Based on the Microsoft Azure Elastic Scale sample apps online I have been able to create my Shard Map Manager (SMM) and elastic pool databases in Azure. My architecture is separate database per tenant. I am using Entity Framework in my web application. I am using a byte[] hash as my Shard Key based on an alphanumeric customer name. The customer name is entered as part of customer login so I can determine the unique shard key at the time of login to be passed to the SMM.
My questions are:
1.) Since each tenant has its own database, do I still need to include the hashed customer name/shard Key in each row of the customer tables?
2.) I don't understand where the shard key information gets passed to the SMM during a call to the server. Is it within the context of the entity or does it need to be a part of the query itself? Any sample of this would be greatly appreciated!
You access the Shard Map Manager database when finding the connection string for a particular tenant. Once you have the connection string, you connect to a tenant-specific database. Inside the database you don't need to use the shard key at all.
The Elastic Database Tools library has an implementation of data dependent routing (DDR). But you might find it overkill for when you have a simple single tenant sharding pattern implementation. You can always just query the shard map database (or custom configuration store) at startup and load a
Dictonary<string,string>
to store the CustomerName -> ConnectionString lookup.