Install YAF.NET on Windows Azure (SQL Azure): the Complete Guide

This is detailed step-by-step guide on how to install on Windows Azure (SQL Azure).

Disclaimer: you will scream like a girl when you manage to install on SQL Azure!

Recently I installed 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.

The Problem

“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 to SQL Azure.

The incompatibility is in two areas:

  1. Standard ASP.NET Membership scripts to initialize membership database are not compatible with SQL Azure, you need updated ones.
  2. Each table in SQL Azure database must have clustered index. Some tables don’t have such index.

Fortunately, you don’t have to manually edit SQL scripts to adopt them to SQL Azure.

The Solution

Here starts detailed step-by-step manual on how to install 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!

  1. 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.
  2. 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:
    1. InstallAzure.sql
    2. InstallCommon.sql
    3. InstallMembership.sql
    4. InstallPersonalization.sql
    5. InstallPersonalization.sql
    6. InstallRoles.sql
    7. InstallWebEventSqlProvider.sql
  3. Now create empty database “yafnet” on your local computer. I used SQL Server Express 2008 R2 for this purpose.
  4. Prepare to run on your local PC. You can use Visual Studio, Web Matrix, IIS or IIS Express, at your preference.
  5. 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:

    1. Change default membership and roles provider to the AspNetSqlMembershipProvider and AspNetSqlRoleProvider accordingly.
    2. Set connection string name for these providers to the yafnetmembership connection string name.
    3. 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.

  6. Run 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 website.
  7. Now it’s time to modify db.config file and change yafnet connection string to use SQL Azure yafnet database.
  8. 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.
  9. OK, we’re almost ready. Now create Windows Azure website (if you didn’t it yet) and copy all the files to the website from your local installation.
  10. Add these two databases as linked resources to this website: this will automatically generate hidden firewall rules on SQL Azure server.
  11. 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:

Let me know in comments whether it worked for you or not, I’ll try to help.

Thanks to and who pointed me in right direction.

2 thoughts on “Install YAF.NET on Windows Azure (SQL Azure): the Complete Guide

  1. TylerW

    Dunno if you’re still reading this, but when publishing websites (at least from VS2012) it indicates that Azure no longer supports ASP.Net SQL Providers and instead only supports the new ASP.NET Universal Providers as seen at

    I noticed your forums are still up, and I’m assuming you’re still using Azure to host them. Did you have to do any conversion to keep the site working? Do you know if these instructions are still valid then?


Leave a Reply

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

You are commenting using your 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