Getting Started on Azure coming from a Google App Engine Dev Background
I've been doing most of my web development in Google App Engine because of AppScale. Yet, in order to compare clouds I've jumped into Azure. Here are my experiences to start and the notes I took while getting setup.
My debug web server kept using port 87 which was refused. There is a way to specify a fixed port by configuring the WebRole, but it did not used the port I specified, and stuck using port 87. Turns out its a Firefox issue. Always use IE when dealing with MS products. Lesson learned. The set port did work if I started the debug process from the project (right click, then click debug) rather than hitting the debug button.
Related link: http://stackoverflow.com/questions/2920610/visual-studio-2010-debug-in-a-fixed-portDeploying onto Azure was a bit confusing at first. It was not as straight forward as GAE's upload application. I had to create a certificate and then upload it to the web portal. When clicking on "help me set up my certificate", Visual Studios crashed. The exception only crashes VS if I have selected a certificate.
Getting started is not as easy if you don't already have Visual Studio. All my development has been on linux platforms, so installing the SDK alone took some time. I had to install about 4 different programs/packages to just get the development environment going. This includes MS Visual Studio, Internet Information Service 7.0, ASP.NET Application Dev components, and the Azure SDK. To use SQL Azure, I had to download SQL Server 2008. Good thing I have MS Academic Alliance, otherwise this would be costing me a small fortune. Seems like a steep cost for a dev who is just starting out, but great for someone who is already heavily into ASP.NET programming and has the tools set up. Setting up with GAE in comparison is much simpler for a dev who is getting their feet wet.
Their SSL cert was revoked while I was using Chrome as my browser. Switching to Windows and using Explorer instead worked. Opening links with firefox also did not work, even though they listed that they support firefox, chrome, and safari (I guess only if you're coming from windows as your OS). I clicked on getting some live chat help, but this too had the SSL problem. This got me kind of peeved, but I took some deep breaths and got over it. Maybe MS just doesn't want customers who come in using Linux. Here I am trying to sign up and give them money and they are making it difficult.
The SDK requires you to develop as an administrator in order to run and debug your site. After having created a new project and seeing the initial template come up, I went on to figure out how to handle different URIs on the server side and how to read POST arguments.
There are two types of roles in Azure, a WebRole which acts as a web front end, and a WorkerRole, which does background processing. I don't need any background processing so my application will only have a WebRole.
There are two configurations files which I would say is comparable to the app.yaml file in GAE: the ServiceConfiguration.cscfg file and the ServiceDefinition.csdef file. The ServiceConfiguration file is for specifying service endpoints (ports of services such as BlobStorage). ServiceDefinition is for defining WebRoles, WebWorkers, and settings for services such as BlobStorage.
Handling request.
The default page is Default.aspx. CSharp code can be put in place using <% %> tags. You specify labels and fill in their corresponding (automatically generated) code.
About the MS Tables.
Each entity has a primary key which is made up of a partition key and a row key. Parition keys are like root keys in AppEngine. They specify the entity boundary for transactions. The only types of transactions that are allowed are batch updates. This is very limited to what AppEngine offers. Implementing an atomic counter does not seem possible using Table transactions. Hence I must use SQL Azure.
SQL Azure is strongly typed and requires me setting up the table in advance using Server 2008.
Installing SQL Server 2008 was a pain. I ran into having a corrupt installer detailed by this link: http://tinyurl.com/2bjw3ly
I then tried to download and install SQL Server 2005 Express. This went smoother, but it made me install powershell as a prerequisite. In order to install PowerShell I had to download and run a Windows Validation tool. Powershell's installation started updating Windows, but at least this time it was automatic. Yay! After being able to connect to the DB I ran into the following problem:
I ran it again and this time it worked. I did nothing different, I'm guessing something was up on their end or my tools were misbehaving.
Once going the tutorial had some nifty things such as being able to create stored procedures, such as a loop for storing data, where I added 10k items into the table.
I created my tables with the following
CREATE TABLE Account(
MyRowID int IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
Balance int DEFAULT 100
)After seeing that they support php (I've done some work with LAMP sites), I started install php on Windows and read through this blog:http://www.joshholmes.com/blog/2010/02/10/helloworldazureinphp/ on setting up a php hello world application. Another blog went through more of a step by step at http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx. The example step-by-step code did not work for my Azure database, so I went back to writing my application in CSharp.
CREATE TABLE Account(
MyRowID int IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
Balance int DEFAULT 100
)After seeing that they support php (I've done some work with LAMP sites), I started install php on Windows and read through this blog:http://www.joshholmes.com/blog/2010/02/10/helloworldazureinphp/ on setting up a php hello world application. Another blog went through more of a step by step at http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx. The example step-by-step code did not work for my Azure database, so I went back to writing my application in CSharp.
The application I needed had a few paths (URIs) which in the webapp framework in python I can dictate the path to a handler. ASP.NET on the other hand I create a aspx file for each path. Each aspx file has a cs file associated with it. Any label created in that file has a corresponding function as previously mentioned.
There are actually a lot of good tutorials on msdev.com if you search for Azure. There is also a installable kit for learning the tools with labs and sample code. Documentation of setting up a site is very good with lots of videos, code samples, etc. Their support is excellent as well. After posted a question about my database/table creation issue they were very responsive to my questions.
My debug web server kept using port 87 which was refused. There is a way to specify a fixed port by configuring the WebRole, but it did not used the port I specified, and stuck using port 87. Turns out its a Firefox issue. Always use IE when dealing with MS products. Lesson learned. The set port did work if I started the debug process from the project (right click, then click debug) rather than hitting the debug button.
Related link: http://stackoverflow.com/questions/2920610/visual-studio-2010-debug-in-a-fixed-portDeploying onto Azure was a bit confusing at first. It was not as straight forward as GAE's upload application. I had to create a certificate and then upload it to the web portal. When clicking on "help me set up my certificate", Visual Studios crashed. The exception only crashes VS if I have selected a certificate.
The website wants the private key, and all I have is the cert which was created.
related link: http://msdn.microsoft.com/en-us/library/ff683676.aspx
Using power shell I was able to generate the pfx file.
Taken from: http://msdn.microsoft.com/en-us/library/ee758713.aspx This pfx file was successfully uploaded to Azure. I copied over my subscription id and hit OK. I then received a message saying the authentication failed. Then the damn thing crashed again. I used the second option and just packaged up the application. I uploaded two files, one the packaged app and the other the configuration file. Starting up the application takes some time compared to GAE.
Here is a video doing a walk through on uploading you application:
http://msdn.microsoft.com/en-us/vcsharp/ee830334.aspxUseful links and other ramblings:
Using power shell I was able to generate the pfx file.
$c = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("c:\mycert.cer") $bytes = $c.Export("Pfx","password")[System.IO.File]::WriteAllBytes("c:\mycert.pfx", $bytes)Here is a video doing a walk through on uploading you application:
http://msdn.microsoft.com/en-us/vcsharp/ee830334.aspxUseful links and other ramblings:
Example code on using the data reader (output of queries):
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspxBasic understanding of developing a website with ASP.NET:
http://webproject.scottgu.com/CSharp/Understandingcodebehind/Understandingcodebehind.aspxSample code for running procedures within a transaction:
http://www.facebook.com/note.php?note_id=445967632572
Note: They do not support distributed transactionsCreating a page which post data to another page:
http://forums.asp.net/p/1048041/1474374.aspx Sending a POST from PowerShell:
http://powershell.com/cs/blogs/tips/archive/2010/04/29/sending-post-data-via-powershell.aspx Best practices with sample code for using SQL Azure:
http://social.technet.microsoft.com/wiki/contents/articles/sql-azure-connection-management-in-sql-azure.aspx Straight forward setups of transactions for SQL in C#:
http://www.aspnettutorials.com/tutorials/database/sql-transaction-csharp.aspx While debugging I got
{"There is already an open DataReader associated with this Command which must be closed first."}.
I was using the same reader variable and not closing the previous reader. This was a quick bug to fix with the descriptive exception message and the online help.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspxBasic understanding of developing a website with ASP.NET:
http://webproject.scottgu.com/CSharp/Understandingcodebehind/Understandingcodebehind.aspxSample code for running procedures within a transaction:
http://www.facebook.com/note.php?note_id=445967632572
Note: They do not support distributed transactionsCreating a page which post data to another page:
http://forums.asp.net/p/1048041/1474374.aspx Sending a POST from PowerShell:
http://powershell.com/cs/blogs/tips/archive/2010/04/29/sending-post-data-via-powershell.aspx Best practices with sample code for using SQL Azure:
http://social.technet.microsoft.com/wiki/contents/articles/sql-azure-connection-management-in-sql-azure.aspx Straight forward setups of transactions for SQL in C#:
http://www.aspnettutorials.com/tutorials/database/sql-transaction-csharp.aspx While debugging I got
{"There is already an open DataReader associated with this Command which must be closed first."}.
I was using the same reader variable and not closing the previous reader. This was a quick bug to fix with the descriptive exception message and the online help.