This is detailed step-by-step guide on how to install yaf.net on Windows Azure (SQL Azure).
Disclaimer: you will scream like a girl when you manage to install yaf.net on SQL Azure!
Recently I installed yetanotherforum.net on Windows Azure. This process wasn’t straightforward at all, so I decided to write detailed post on how to do it. You can skip the next section and go directly to “The Solution” section if you want to start immediately without reading boring technical background.
“YetAnotherForum.NET (YAF) is the Oldest, Most Mature, and Feature Rich Open Source (FREE) Discussion Forum for sites running ASP.NET. 100% written in C#…” but unfortunately it is not compatible with SQL Azure.
There is a short official manual here, but it contains only general steps. Questions on Internet forums show that I’m not alone experiencing difficulties with deploying yaf.net to SQL Azure.
The incompatibility is in two areas:
- Standard ASP.NET Membership scripts to initialize membership database are not compatible with SQL Azure, you need updated ones.
- Each table in SQL Azure database must have clustered index. Some yaf.net tables don’t have such index.
Fortunately, you don’t have to manually edit SQL scripts to adopt them to SQL Azure.
Here starts detailed step-by-step manual on how to install yaf.net on Windows Azure website with SQL Azure databases.
I assume that you are familiar with Windows Azure and know how to create website or database. If not, don’t be scared, it’s as easy as few mouse clicks.
So let’s go!
- First of all, you need to create two empty SQL Azure databases. Let’s call them yafmembership and yafnet. First database would store forum members’ information. Second one would store forum data: posts, topics etc. Also add your computer’s IP address to the SQL Azure firewall rules to access these databases from your PC.
- Run Azure specific ASP.NET Membership scripts to setup membership. Please download fixed scripts here KB2006191 – Updated ASP.NET scripts for use with SQL Azure. After that go to the Windows Azure management portal and run these 7 scripts over the yafmembership database.
The order of running scripts is important! Here is the right order:
- Now create empty database “yafnet” on your local computer. I used SQL Server Express 2008 R2 for this purpose.
- Prepare yaf.net to run on your local PC. You can use Visual Studio, Web Matrix, IIS or IIS Express, at your preference.
- Now quite complicated step: you need to modify db.config and web.config files.
Let’s start with easy one – db.config. Add two connection strings: one for yafnet local database and one for membership Azure database. You can download modified config file here.
Now the web.config:
- Change default membership and roles provider to the AspNetSqlMembershipProvider and AspNetSqlRoleProvider accordingly.
- Set connection string name for these providers to the yafnetmembership connection string name.
- Generate and paste machine key. You can bing or google on how to do it.
The recommended web.config file with my adjustments is in the archive above too.
- Run yaf.net locally and go through the installation wizard. Important: do not check the use “full text” index on the database step and make sure “upgrade BBCodes….” Option is unchecked too. And very important: don’t click the “finish” button on the last step! Just close your browser and shutdown local yaf.net website.
- Now it’s time to modify db.config file and change yafnet connection string to use SQL Azure yafnet database.
- Download SQL Azure Migration Wizard to migrate local yafnet database to the SQL Azure yafnet database. This wizard will recreate all database objects (tables, stored procedures etc.) and will automatically make necessary changes to make them SQL Azure compatible (will add clustered indexes in our case, e.g.). Moreover, it will automatically copy tables’ rows into the Azure tables.
- OK, we’re almost ready. Now create Windows Azure website (if you didn’t it yet) and copy all the yaf.net files to the website from your local yaf.net installation.
- Add these two databases as linked resources to this website: this will automatically generate hidden firewall rules on SQL Azure server.
- And finally that is it! Open your website (forum) and enjoy :). Last thing: remove your local IP address from the SQL Azure firewall rules.
You can check the result here: http://forum.legitlog.com/.
Let me know in comments whether it worked for you or not, I’ll try to help.
Thanks to http://yafnet.codeplex.com/wikipage?title=Install%20YAF%20with%20Windows%20SQL%20Azure and http://lluisfranco.com/2011/05/18/using-asp-net-membership-in-sql-azure/ who pointed me in right direction.