There is a good chance you might have stumbled upon the new Windows Azure Release that we made on June 6th. Scott Guthrie’s Post quite summarizes the overall new features.
One of my favorite features is the Windows Azure Websites and the ability to do publish files to Azure using your FTP Client.
Windows Azure Websites offers low cost (free upto 10 websites) web hosting where you can deploy any website that can run on IIS 7.0, quickly.
The earlier releases of Azure SDKs and the Azure platform support .NET 3.5 & above for running your applications. This was a constraint for many since there are/were a lot of ASP.NET 2.0 applications built over time and simply to put it on Azure, many of you were skeptical to migrate it to .NET 4.
Windows Azure Websites offer the flexibility of running IIS 7.0 supported .NET Versions which means you can run .NET 1.1, 2.0, 3.5 and .NET 4. Not just that! You can also run classic ASP Applications.
Windows Azure Websites don’t need you to go through the complexity of adding the Cloud Project Template and then publishing the Configuration Files. Lets take a step by step understanding of Websites and publishing using FTP.
I downloaded the Club Website Starter Kit from http://www.asp.net/downloads/starter-kits/club
It also requires a database and I downloaded the SQL Scripts and created a SQL Server Database called Club.
This installs a Web Site Project Template. Note that I am running Windows 8 Release Preview and Visual Studio 2012 RC. After installing the template, select File – New – Website and don’t forget to choose the Framework version as .NET 2.0
You can see the “Club Website Starter Kit” . Once you select the Website gets created. You would encounter a warning indicating that the Club Website Starter Kit uses SQL Express and the recommended database is LocalDB Express. Click ok to continue. Once the Website is created open up the Web.config and locate the “ClubSiteDB” connection string. By default, it points to a SQL Express Database. Instead configure it to use your local SQL Server.
Also, open up Global.asax and comment out the following line
if (!Roles.RoleExists("Administrators")) Roles.CreateRole("Administrators");
There seems to be an issue in the code that doesn’t create the role.
Post that, hit CTRL+F5 and you should be able to see the Website Running, as below
So, now we have the Club Starter Kit site up running locally.
Moving to Azure
Visit http://manage.windowsazure.com/ and sign up for a trial account. This allows you to host up to 10 websites for free and a host of other benefits. The free Websites can be extended to an year without any charge. Once you have signed up, sign in to the portal using the Live ID used for sign up.
After signing in, you would be presented with the “All Items” listing page which lists, Websites, Cloud Services, Databases etc., If this is the first time, you wouldn’t find anything.
Click on the “Websites” link from the left menu. Click on “New” in the bottom and it should show up a dialog. In the same, select Website and click on “Quick Create” and in the URL Textbox, specify “MyFirstDemo” and click the “Create Web Site” link below.
It should take a few seconds to create the Website. Once the Website is created, click on the listing and it should open up the Dashboard. Since we haven’t done anything yet, there shouldn’t be any statistics
Click on the “Download publish profile” link in the right bottom. This file has the FTP publishing settings.
Also, if you scroll down you can see the FTP URL for this site. It should typically start ftp://waws-xxxx-xxx-xxxx
In the downloaded publish profile file, you can also find the ftp URL. Pick the following from this file
publishUrl (the 2nd one, the one that features after publishMethod =”FTP”) and the userName and userPWD that follows.
Note that we have everything required to publish the files. But since the Club Starter Kit uses Databases, we need to have the Database running on SQL Azure.
Go back to the Main Menu and click on “New” in the bottom but this time select “SQL Database” and provide “Club” as Database name for “Quick Create”
If this is the first time a Server would be created. Otherwise, it would pickup the existing server name.
Once the database is created, you can use the SQL Azure Migration Wizard http://sqlazuremw.codeplex.com/ and provide the credentials to connect to local database and then the SQL Azure database for migrating the “Club” database. The migration wizard UI hasn’t changed much and is the same as explained by me in one my posts earlier http://geekswithblogs.net/ranganh/archive/2009/09/29/taking-your-northwind-database-to-sql-azure-and-binding-it.aspx
Once the database is migrated, come back to the main screen and click on the Database base in the Azure Management Portal. It opens up the dashboard of the database. Click on “Show connection Strings” and it would popup a list of connection string formats. Choose the ADO.NET connection string and after editing the password with the password that you provided when creating the database server in the Azure Portal, paste it into the config file of the Club Starter Kit Website. Just to reiterate, the connection string key is ClubSiteDB.
Try running the Website once to ensure that the application though running locally could connect to the SQL Database running on Azure.
Once you are able to run the website successfully, we are all set to do the FTP Publishing.
Download your favorite FTP tool. I use http://filezilla-project.org/
In the Host Textbox, paste the FTP URL that you picked up from the publish profile file and also paste the username and password. Click on “QuickConnect”. If everything is fine, you should be able to connect to the remote server. If it is successfully connected, you can see the wwwroot folder of the Website, running in Azure
Make sure on the “Local Site” in the left, you choose the path to the folder of your Website. Open up the Website folder on the left such that it lists all the files and folders inside. Select all of them and click select “Upload” or simply drag and drop all the files to the root folder that is listed above.
Once the publishing is done, you should be able to hit the SiteURL that you can find the dashboard page of the website. In our case, it would be http://MyFirstDemo.azurewebsites.net
That’s it, we have now done FTP publishing in Azure and that too we are running a .NET 2.0 Website on Azure.
Cheers !!!