SQL Azure and Asp.NET Forms authentication

Posted: May 26, 2013 in .NET, Windows Azure

Today i was helping a MSP with some of his ASP.NET project problems. One off the bigger problems he had was how to quickly bring some kind of authentication/ authorization to his WebApp.

So i had spend some time explaining and showing how to use this fantastic ASP.NET feature. After a while i receive a new call from my friend asking why he couldn’t do what he had seen with me.

I ask him what’s the problem he are running in to? If it was something with the creation of user’s or the membership  part of the solution?

He had answer that the problem was on the database creation part,

And he had email me the screen shoot of the problem

errorAfter some time trying to understand what was the problem that takes the sql form register fail ( you can run the wizard of creation the authentication database by using the command C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regsql.exe ), i’ discover that was a difference between what my friend was doing and what we had done together.

The difference was that José was using SQL Azure as the database backend. When using SQL AZURE as the database of ASP.NET forms authentication the way we prepare the database is different. When preparing the database in a on premises situation you use the following command

aspnet_regsql -S [your server name].database.windows.net -d [your database name] -U [your user name]@[your server name] -P [your password] -A mr

This make a call to the visual studio creation wizard, that is not prepared for the azure databases, so in cases where you have SQL Azure as the Database Engine of your forms authentication database you should download a special tool to your intent, this tool can be found at , http://archive.msdn.microsoft.com/KB2006191/Release/ProjectReleases.aspx?ReleaseId=3539 after unziping the tool you run the command:

aspnet_regsqlazure -s [your server name].database.windows.net -d [your database name] -u [your user name]@[your server name] -p [your password] -a mr

And you are ready to develop your asp.net forms authentication solution using azure as the database engine.

ps:

If you need to know more about forms authentication in asp.net go to:

http://www.asp.net/web-forms/videos/authentication/using-basic-forms-authentication-in-aspnet

http://msdn.microsoft.com/en-us/library/ff649314.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s