Print Page | Close Window

Azure Deployment

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2592
Printed Date: 29-Jul-2026 at 7:31pm


Topic: Azure Deployment
Posted By: Andrew
Subject: Azure Deployment
Date Posted: 29-Mar-2011 at 2:48pm
I'm working on the deployment of a multi tenant appliaction.
The single tenant deployment is working already.
I followed the video from Ward Bell and Kim Johnson - thank you by the way!
 
Now I'm looking for a way to determine the tenant from the URL to set the right
connection string within the DynamicDataSourceKeyResolver.
Is there any existing idea to do that?
My favourite scenario would be mycompany.cloudapp.net/Customer1, mycompany.cloudapp.net/Customer2 ...
An redirect via CNAME within the DNS-Config could be another option: customer1.mycompany.net -> mycompany.cloudapp.net
I've made some testing but I don't get it work.
Hope you can help me!?
 
Thank you



Replies:
Posted By: Andrew
Date Posted: 29-Mar-2011 at 3:01pm
Just to be clear: My application is a Devforce-Silverlight-Application!


Posted By: kimj
Date Posted: 30-Mar-2011 at 10:02am
The DevForce support for a multi-tenant applications doesn't differ between Azure or other types of deployments.  Your DynamicDataSourceKeyResolver will receive a "data source extension" in its GetKey method, and the extension will represent the tenant (if you provided an extension to the EntityManager when creating the EM).  So if you create your EM with an extension of "Customer1" that will flow through to the DataSourceKeyResolver and let you build an appropriate connection string.
 
You don't actually need a DataSourceKeyResolver for multi-tenant applications, though, since DevForce will also expect the names of connectionStrings to contain the extension, for example "Northwind_Customer1", "Northwind_Customer2".
 
You can obtain the URL from the OperationContext.Current or HttpContext.Current, but DevForce resolves keys once only based on two pieces of information:  the key name and the extension.  So if you didn't use a data source extension and hoped to resolve the key name for each specific request this won't work.


Posted By: Andrew
Date Posted: 30-Mar-2011 at 5:08pm
Hi Kim,
 
I'm setting the dataSourceExtension when creating the EM like you proposed:
myManager = new MyEntities(dataSourceExtension: "Test");
The Tenant-Name is actually coming from an URL-parameter in the client app.
My problem is that the DataSourceKeyResolver doesn't have the keyExtension = "Test" in the GetKey method.
Do you have any idea why I get an empty string in keyExtension?
(DataSourceKeyResolver  has attribute [DataContract] belonging to serialization!)
 
Thanks
Andrew


Posted By: kimj
Date Posted: 30-Mar-2011 at 6:41pm

Check the debuglog on your server to see what it says regarding the EntityServer(s) it's started and is listening on.  The log will contain trace messages about what it thinks the data source extension is, and that extension should be passed to your resolver.   One thing to remember is that the resolver is essentially server-side - it should be deployed on your server and is generally not needed on your client at all (the exception is when returning an EntityCacheState from an RPC method). 

The log should contain messages similar to what's shown here:  http://drc.ideablade.com/xwiki/bin/view/Documentation/logged-info#HCommunications - http://drc.ideablade.com/xwiki/bin/view/Documentation/logged-info#HCommunications , with your "Test" extension reflected in the EntityServer service names.


Posted By: Andrew
Date Posted: 06-Apr-2011 at 11:52pm
Hi Kim,
 
yesturday I continued with the problem. After a long session with
re-constructing the whole application in a new solution I found out that there was a relict from
the first days of the DevForce 2010 release. I used a class that was derived from "ServiceProxyEvents"
to work around an issue whereby DevForce had set the the service endpoint address incorrectly.
After you fixed the problem I forgot to remove this one from my application.
Actually it prevented receiving a not empty keyExtension within DataSourceKeyResolver.
 
So, it was my fault.
 
Addtion to my initial question for all others who are interested in:
I extract the Tenant name from an URL-parameter and give it then to the EntityManager as dataSourceExtension:
Dictionary<stringstring> urlparams = HtmlPage.Document.QueryString as Dictionary<stringstring>;
string tenantName = string.Empty;
urlparams.TryGetValue("Tenant"out tenantName);
if (tenantName == null)
tenantName = string.Empty;
Thanks
Andrew
 
 
 


Posted By: kimj
Date Posted: 07-Apr-2011 at 8:24am
Thanks for the update, and for the tip on passing a tenant extension into your SL application!



Print Page | Close Window