Share via


RIA and SQL Azure

In my first post on RIA and Azure, I showed how to create and modify a RIA business application to run on Windows Azure. In this post, I will cover roughly the same thing but I’ll adjust some of the steps to get the application running using both Windows and SQL Azure.

Prepare SQL Azure for a Business Application

If you want to create a RIA Services business application that uses the default authentication, you’ll need to configure your SQL Azure databases for ASP.NET membership, roles, and profiles. The instructions on how to do this are detailed in this KB article. Jim has also provided some great tips for running the scripts.

The scripts you’ll need to run are all found in the ‘InstallAspSchema’ download. In the default case, you’ll only need to run the following scripts.

  1. InstallAzure.sql [master]
  2. InstallCommon.sql [aspnetdb]
  3. InstallMembership.sql [aspnetdb]
  4. InstallRoles.sql [aspnetdb]
  5. InstallProfile.sql [aspnetdb]

 

Creating a Business Application for the Cloud

These steps show how to create a business application project targeted at the cloud and ready for local development. Steps 2 and 3 can also be followed to modify a preexisting business application for the cloud. This section is the same as the one from the previous post.

  1. Create a new business application using the ‘Silverlight Business Application’ template
  2. Add a new Project to the solution using the ‘Windows Azure Cloud Service’ template
    1. In the wizard, select ‘OK’ without adding any roles
  3. From the Cloud Service project ‘Roles’ folder, add a Web Role Project from the solution and select the Web project you want to target at the cloud


Preparing a Business Application for Deployment

At this point, you should be able to run the application in the Azure development fabric. To prepare the application to run in the cloud, there are only a couple other updates that must be made.

  1. For each RIA Services assembly referenced by the Web project, open the Properties window and set Copy Local to True
  2. Update the connection string(s) used by the ASP.NET membership, role, and profile providers

The easiest way to do this is to update the “LocalSqlServer” connection string used by the default providers. For the connection string, just use the value available on the SQL Azure Database Summary page (I’ve added whitespace below for readability).

   <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer"
         connectionString="Server=tcp:servername.database.windows.net;
                           Database=aspnetdb;
                           User ID=username@servername;
                           Password=myPassword;
                           Trusted_Connection=False;
                           Encrypt=True;"
         providerName="System.Data.SqlClient"/>
  </connectionStrings>

At this point you should be able to deploy your business application to Windows Azure and have the default authentication run against the database you created on SQL Azure.

Comments

  • Anonymous
    June 09, 2010
    thanks thats exactly what I wanted to know!