The other day I watched The Great Escape. In one segment they brew up a batch of potato moonshine. I was reminded of the husky, breathy “Wow” in the taste testing scene when I visited Amazon’s Amazon Web Services offering. It’s like jumping in to a stream with hip waders and discovering that you need taller waders.
Amazon has so many services that I’m going to just skim the surface here. It would take a few weeks to cover everything Amazon offers. This article will be about Amazon RDS which in itself offers flavors for MS SQL Server, Oracle and MySQL. You can even use MS SQL Express! In this article, my objective was simply to deploy, into Amazon Web Services, a version of the sample ASP.NET MVC application, NerdDinner in order to discover how easy it would be. I will also cover the use of Amazon’s Elastic Beanstalk
There is a video offering on Amazon’s web services site covering putting a version of Nerd Dinner up on AWS. It feels like a good idea to step through that process in a written out tutorial fashion.
First a caution
Every cloud offering I’ve found requires you to establish an account. That account must be backed by a payment method and it is possible to inadvertently incur charges. It was explained to me like renting a hotel room. Whether you stay in the room or sleep elsewhere the room is still charged to you. On the good side, most services provide a means for developers and first time uses to test things. With Amazon it’s called a “Free Usage Tier”, which is available to all new users and some existing users. So read the fine print if you want to avoid incurring charges for ANY of the cloud offerings.
I’m not going to walk you through the sign up process. The screens are self-explanatory. The payment method that you choose will be charged a dollar for each service you sign up for, but the dollar will be refunded. It’s Amazon’s method of assuring you are who you say you are. Also, if you have an existing Amazon account then you can use that account.
Sorta – I wrote the introductory part of this article before I did much exploring in the AWS world. What I’ve found is like silent but deadly. I can’t believe how a service of this magnitude has remained off my radar for this long. It is – to be absolutely true – part of the perception of Amazon as an online bookstore. It turns out they may well be bigger than any other cloud offering. My first impression was that they had a single data center. As it turns out they have (at the time of writing) 7.
- US East (Northern Virginia)
- US West (Oregon)
- US West (Northern California)
- EU (Ireland)
- Asia Pacific (Singapore)
- Asia Pacific (Tokyo)
- South America (Sao Paulo)
You can draw your own conclusions about the distribution of these centers, but it seems that they do a very good job of covering the major population areas correctly.
My first impression was – ah, AWS has 19 products or services they offer but then I started digging. Here’s a more or less simplified list:
- Amazon Elastic Compute Cloud (EC2) the basic compute capacity.
- Amazon Elastic MapReduce to process “vast amounts of data.”
- Auto Scaling
- Elastic Load Balancing
- Content Delivery
- Amazon CloudFront allows distribution of content globally with low latency.
- Amazon Relational Database Service (RDS) MySQL, Oracle and MS SQL Server including Express
- Amazon DynamoDB fully-managed NoSQL database service (blob?)
- Amazon SimpleDB managed NoSQL database (tables?)
- Amazon ElasticCache in-memory cache in the cloud (queues?)
- Deployment & Management
- AWS Identity and Access Management (IAM)
- Amazon CloudWatch provides monitoring for cloud services
- AWS Elastic Beanstalk to deploy and manage cloud applications
- AWS CloudFormation to create and manage a collection of resources
- Application Services
- Amazon CloudSearch
- Amazon Simple Workflow Service (SWF)
- Amazon Simple Queue Service (SQS)
- Amazon Simple Mail Service (SES)
- Amazon Route 53 whoa – DNS management!
- Amazon Virtual Private Cloud (VPC) yup
- AWS Direct Connect to establish a direct connection from your premises to the cloud.
- Payment & Billing
- Amazon Flexible Payment Service (FPS) you’ll know if you’ve ever used Amazon OneClick
- Amazon DevPay hum – a way for developers to collect for their AWS offerings?
- Amazon Simple Storage Service (S3)
- Amazon Elastic Block Storage (EBS)
- AWS Import/ExportAWS Storage Gateway
- AWS Premium Support
- Web traffic
- Alexa Web Information Service
- Alexa Top Sites
- Amazon Mechanical Turk (temp workers!!!)
That’s about 30 services under the Amazon Web Services banner and many have additional entries. Actually, looking at some web content, one person says “82 (services) in 2011 alone”.
Here’s the screen you get when you first visit AWS Web Services.
Once you’ve signed up and received your verification emails, the next step is to download the appropriate SDK for your development purposes. I chose to download the SDK for.NET for this article.
Once you have the SDK simply install it. One of the results will be new projects available in Visual Studio 2010. The templates are for C# only as far as I can tell.
Let’s play around
The whole AWS thing is so involved it’s scary. I’ve been messing with it for a few days now just to get a feel. I’ve signed up for my account and done all of the necessaries to get to the web page illustrated here.
Besides the Home tab, you should see 19 additional tabs representing the services available. Left click the ‘Elastic Beanstalk‘ tab to get the following screen.
I’ve preselected the 64bit Windows Server 2008 R2 running IIS 7.5 because I’m familiar with it. I suspect that the results here make little difference. I’ve also left Launch a sample application checked because I really just want to see what’s going to happen. So click the Launch Application button to get the following screen.
I had done this once so some of the messages apply to a previously terminated app. You can click the arrow to the left of the Environment Details to follow the progress. Spinning up the application will take a few minutes so be patient.
Click the URL to launch the application and you should see this.
In the third item under ‘What’s Next?‘, I’m going to walk through the NerdDinner application. I’m not sure at this point what added value I’ll provide but maybe it will force you to jump in the water. By now your hip waders should be tall enough.
Before you start be sure Elastic Beanstalk is supported in the zone you select. As of this writing I know that the US East (Virginia) zone is available. If you choose a zone that doesn’t support the Elastic Beanstalk you won’t get it as a deployment option later.
Building and deploying the Nerd Dinner application
I used the steps in the following Amazon documentation and found myself struggling in a few places. The instructions are fairly clear but in some instances they seem to gloss over some steps that are not as intuitive as they might be.
Getting the source code
You can download the Nerd Dinner source from here:
It’s a zip file. I extracted it to my Visual Studio 2010 “my documents” under Projects. Once you’ve extracted it, open Visual Studio 2010 and open the project solution file. My suggestion is that you should use this link for your basic instructions.
I will try to cover all of the steps, but it’s nice to have two outlooks.
To script the NerdDinner database
- In Server Explorer, right-click ‘Data Connections’, and then click ‘Add Connection’.
- In the ‘Add Connection’ dialog box, click ‘Change‘, and then click ‘Microsoft SQL Server Database File’. Click ‘OK‘.
- Click ‘Browse’that is next to the ‘Database file name’ box, and select the NerdDinner.mdf file located in the NerdDinner/App_Data directory. Click ‘Open‘.
- In Server Explorer, right-click NerdDinner.mdf, and click ‘Publish to provider’.
Note that the database you just selected is pre-selected.
- In the Database Publishing wizard, click ‘Next’ twice. On the ‘Select an Output Location’ page, note the path and file name in the ‘File name’ box. You will need this for later.
- Click ‘Finish’ twice to so as to accept all defaults in the wizard.
I know – all of this to set up a SQL database script. This can be more easily accomplished using Red Gate SQL Packager. SQL Packager has to be one of the niftiest creations on the planet!
Launching an AWS RDS database
In the AWS Explorer, expand the Amazon RDS entry and right-click ‘DB Instances’.
…then select ‘Launch DB Instance’. If you want to stay in the Free Tier, then select the Microsoft SQL Server Express Edition. The entries look similar, so choose correctly.
In the following dialog, a Micro instance is probably going to be all you’ll need for testing.
I’ve used mostly the same values as Amazon’s walkthrough. I used awsuser as the Master User Name and my password as the password.
Selecting defaults in most of the following dialogs is okay. Clicking Launch will start building the db and this will take some time. Double click demodband you will see the status registering a yellow dot followed with “creating.” Be patient – this really does take minutes.
Once it’s ready then you should see a Status of “Available”. And in case no one picked it up I blew it and built this on US West (Oregon) instead of US East so I had to do it over.
Once finished, the right-click the db instance and select ‘Create SQL Server database’.
In this dialog the system tries to determine your CIRD/IP.
Once the connection is established you can move on to creating your db.
Clicking OK will build the requested database.
Updating the Nerd Dinner connection string
In the Server Explorer select the rds.demodb.mydb entry.
In the Properties window copy the Connection String.
Now I found this a little counter-intuitive. You need to copy the connection string to the highlighted area here. And Holy Batman it gets worse. I spent a few days and AWS tech support came to the rescue. I left out an " – so here’s how the entire line should look.
res://*/Models.NerdDinner.msl;provider=System.Data.SqlClient;provider connection string=
Initial Catalog=mydb;User id="awsuser;Password=**********">"" providerName="System.Data.EntityClient" />
With your password substituting for the *******. I truly hate connection strings!
This is the NerdDinnerEntities string and I’ve turned it in to 3 lines so you can see where to paste the connection string you just copied. You can just scroll to the end of the string to do the paste. Finally save the modified file. I’m not really sure that this works but it doesn’t error out.
Load NERDDINNER.MDF.sql that you saved earlier into Visual Studio and click the Connect icon on the toolbar.
In the AWS Explorer double-click the demodb and make a copy of the endpoint.
In the ‘associate Properties‘ window, copy the Endpoint.
In the connection dialog, paste the endpoint into the Server name box and also fill in the other entries appropriately.
Once you are connected, you select the appropriate database and click the execute button. If the script succeeds then you should see Command(s) completed successfully in the bottom window.
Now close the Nerddinner.MDF in Server Explorer.
A little sidetrack
Among many other things, I have SQL Server 2012 installed. When using the instructions provided by Amazon, I ended up with my Visual Studio 2010 using SQL Management Studio 2012; I think it may have not done things right. To remedy that problem I used SQL Server Management Studio 2008 R2. I connected to my AWS database using the endpoint and ran the NERDDINNER.MDF.sql script against the mydb database by copying it to a new script instance and executing it.
Deploying Nerd Dinner using the Elastic Beanstalk
First, a deep bow to all of you who have gotten this far. It’s not that AWS is difficult but it is so rich it requires a considerable amount of perseverance. Let’s finish this up so that you can deploy your first real application to the Elastic Beanstalk. I will not be expecting the Nerd Dinner site to work – I just want to see a ‘Status: Environment is healthy‘. So firstly, right-click the NerdDinner item in the Solution Explorer to get this context menu, and then click ‘Publish to AWS‘.
The result should be the following dialog box. Note again that this is being done on the East US zone and thus includes the Elastic Beanstalk.
Click the AWS Elastic Beanstalk entry to get the following.
You can leave the defaults and click ‘Next‘.
Enter a name and an Environment URL. I’ve used matching entries though I’m not sure whether that’s required. Be sure to click the ‘Check availability…‘ button to see if the URL is available, and then click ‘Next‘.
Here, simply check the box for your Database and click ‘Next‘.
Once here, you can look over your selections and then click ‘Deploy’. You will see the following as the Elastic Beanstalk begins the deployment operation. Notice the Status entry of Launching.
Once complete, you should see the following screen.
Again wait for the ‘Status: Environment is healthy‘, at which point you can click the URL to launch the Nerd Dinner site on Amazon Web Services.
What a hoot!
I had concluded that my deployment was a failure but on further reading and inspection we have NOT implemented the registration and logon part or the app. So when you try to logon you get this screen.
Notice the recommendation to use a third party account. Since I have a Google account I chose to logon using that. You can also run the application locally going against the AWS database, so there are lots of options. It’s not all duck soup but AWS has many options available for running your applications
Fill in the details for your dinner and save it.
Now proceed on over the SQL Server Management Studio (You can also use Visual Studio) and see that your data has been saved on the AWS database (click through for full details).
When I first tried to run the Nerd Dinner site it displayed correctly which was, after all, the whole point of this exercise but it didn’t WORK quite as it was supposed to. I had, at this stage, successfully deployed a site to the AWS Elastic Beanstalk and learned a whole lot along the way.
It took a few days and very frustrating days at that but I did finally get Nerd Dinners deployed and working. It turns out (and I’ve corrected this in the connection string information supplied earlier) that I’d left out a ". Once I corrected the connection string everything fell into place. It was like slogging through sludge, but I hope it helps others.
Oh and by this time you should have hip waders like those used by the guys in the cranberry bog commercials!