Recently there have been questions from LightSpeed users asking if LightSpeed works with Azure and the answer is YES!.
But wait a moment, what do we really mean when we talk about “Azure”? The brand has been used to describe a whole platform of cloud technologies from Microsoft so it is important to break down how LightSpeed works with each aspect. This is an important point to keep in mind when evaluating any product that claims to work with Azure by the way!
SQL Azure is the database side of the fence. Many products can talk to SQL Azure quite happily because Microsoft made the smart move of using the SQL Server engine (with some modifications) rather than some hybrid new database type. This meant that we never had to actually make a change to LightSpeed to work with SQL Azure and because of that have been a bit slow to trumpet that LightSpeed worked happily with Azure.
Working against SQL Azure with LightSpeed really is just as simple as changing your connection string to point against your .database.windows.net host. Here is an example of running our LINQ unit tests for SQL Server against a local host:
and then against SQL Azure by changing the connection string:
The only difference is the latency involved, which reminds me not to run unit tests across the Internet again..
Windows Azure can be thought of as where your application executes from – be it a website, a console application, whatever. This, interestingly enough, is the part where things can get a bit hairy for supporting the Azure platform. Windows Azure runs in two trust modes – Full Trust and Windows Azure Partial Trust (a cut down version of Medium Trust that you may have used before) and herein lies the only real challenge with supporting the Azure platform.
At the time of writing, the Microsoft documentation states that the default mode is Full Trust which is not actually correct. By default Azure will be setup to run in the Azure Partial Trust state and if you deploy a normal LightSpeed solution to it you’ll run into a problem. Now, you could set it to Full Trust, but that’s not ideal in all cases and we did some work a while back to ensure that LightSpeed happily supports Medium Trust environments.
If you wish to deploy into Windows Azure Partial Trust here’s a quick list of what to do:
1. Build your LightSpeedContext in code, do not use an app.config or web.config for the configuration.
2. Configure the LightSpeedContext to run in Partial Trust mode:
LightSpeedContext.UseMediumTrustCompatibility = true;
3. All properties on your entities need to read/write. You can enable this in the designer using the following property (click somewhere on the background, not on an entity):
That’s it! You’re good to deploy to Windows Azure in Partial Trust, LightSpeed will chat happily with SQL Azure as if they were old friends and you can kick back with a brew :)