How to using ASP.NET Membership Service with SQL Azure

ASP.NET membership gives you the built-in way to validate and store user credentials. It helps you manage user authentication in your web sites. ASP.NET membership also can be integrated with ASP.NET role management to provide authorization services for your sites, and integrated with user profile to provide application-specific customization that can be tailored to individual users.

ASP.NET membership not only run on standard ASP.NET websites (WebForm or MVC) but it also can be used for Silverlight application and WCF RIAs Services.

ASP.NET membership storing membership information (user names, passwords, …) in MS SQL Server, Active Directory, or an alternative data store. For configuring your SQL Server database that used for ASP.NET membership, you can use  aspnet_regsql tool.

The aspnet_regsql tool works well with your local SQL Server database, but when you use this tool to try to configure your database on SQL Azure, you will receive an error as an image below.

image

The reason is MS SQL Azure is a cloud-based relational database platform built on SQL Server technologies. The aspnet_regsql tool works well for your local SQL Server database with sql scripts are located in .NET framwork directory. However, SQL Azure databases doesn’t support some of statements used in these sql  script.

To configure your SQL Azure databases for working with ASP.NET membership, role manager, profiles, personalization and SQL Web event provide features, you can download the modified sql scripts from codeplex at here http://go.microsoft.com/fwlink/?LinkId=169672

After downloaded, connect to your SQL Azure database for beginning configure

  • Modify database name in InstallAzure.sql and execute this script for creating new database.
  • Switch to database which has been created from the previous step.
  • Execute scripts in InstallCommon.sql
  • Execute corresponding scripts from sql file for features
    • InstallMembership.sql for Membership
    • InstallPersonalization.sql for Personalization
    • InstallProfile.sql for Profile
    • InstallRoles.sql for Roles
    • InstallWebEventSqlProvider.sql for SQL Web Event Provider

And the last step is you have to modified your connectionString in your web.config file. And now you can use built-in tool to manage membership, roles, …

image

Published 08-24-2010 1:20 AM by Duy Nguyen
Filed under: ,
Powered by Community Server (Non-Commercial Edition), by Telligent Systems