Hosting in Amazon Cloud
Do you have a ASP.NET site and want hosting it in Amazon Cloud? The tutorial is exactly about it.
Cloud Computing is for every person for every day
Cloud Computing opens new opportunities both for business and for any person solving their particular tasks. The current series of articles has a goal to show that any person can use almost unlimited resources exactly for the price of using these resources. I don't need Bugatti Veyron Grand Sport to get the nearest supermarket or even the work (although I wish I drove such car to my work several times), so I have a car a bit simpler. Of course I cannot make such Grand Sport from my car for a couple of hours, and pay for these hours only. But I can use Cloud resources for a couple of hours and pay for these hours only.
Let's come back to the earth. I have a small project. The project is to make a site. There is no problem to create a site in Visual Studio. It's been required - it's done. Then it's time to upload and show to a customer.
Where is your hosting, Mr. Customer?
Is it going to be ready to the release time?! But the release time is a time for a release version, not for beta! So I need a hosting for a very short period... What could I do?! - I'm asking pensively and looking in the window. There is a cloud in the window. Of course! It solves the problem!
I don't think my case is extra-ordinary. Below there is a set of simple steps to solve such task by means of Amazon EC2.
Get a site ready. It's assumed I have a site ready. I use a demo page "Hello Cloud" here (why don't really say hello to the Cloud?).
Use a tool. I use EC2Studio add-in for Microsoft Visual Studio. I find convenient to have the development and deployment environments in one place. If you don't have it yet, you can download it from the site www.ec2studio.com. It's free. The installation is very simple. Only path is necessary there.
When add-in is installed EC2Studio functionality is it's available under "Tools" menu item of main menu in Microsoft Visual Studio.
Get Cloud Credentials. As you probably understand I use the Amazon Cloud. If you don't sign up there, you can do it on the site http://aws.amazon.com/. Once you sign up you can use it immediately.
Set the Credentials in EC2StudioTo use the tool the credentials (AWS Account Number, AWS Access Key and AWS Secret Key) should be defined during the first start or in the Options (Tools menu again).
Deploy the Site
Check the Result
- Add permissions into the security group. The Security Groups (they are available from the menu Tools) are necessary for granting an access to users by protocols. To have access to the site the protocol HTTP with port 80 is required. I think access from all IPs is ok for the site (0.0.0.0/0 - means all IP addresses).
- Find a necessary AMI with IIS. I use ec2-public-windows-images/SqlSvrExp2003r2-i386-Win-v1.07.manifest.xml (http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1799 here. You can use filter to find it by the image location or by image id ami-db20c3b2 (in us region) or ami-de517aaa (in eu region). Open EC2 Images in Tools menu to work with AMI.
- Launch Image (by the context menu) with the necessary group.
- Generate key pairs file (for the first time usage of the region, you do not have to generate key pairs each time when you are launching image). The key pair file is necessary to get administrative password when the instance is started.
If you already have key pairs generated first available key pair will be selected automatically or you can select it manually at advanced tab of Launch Instance Configuration dialog.
Also you can take a look at available Key Pairs in Key Pairs menu item of EC2Studio menu
OK, the Instance instance is starting...
- Waiting until the instance becomes running after pending and starting. It could take 10-15 minutes to run an instance.
- Get an Administrator Password (by the context menu). It becomes available after several minutes after running an instance (before the message about the instance configuration is shown).
- Start Console (by the context menu). User is Administrator, Password is the received password.
Copy files there. II use the default C:\Inetpub\wwwroot folder to place my files there (The easy way to copy files to a Remote Desktop is to map local disks during start Remote Desktop. See http://technet.microsoft.com/en-us/library/bb457106.aspx section "File system redirection " for details).
- Check the result locally there
- Check the result remotely (use the Copy Public DNS Name to clipboard from the Instance context menu to get DNS). Get the public DNS and use it in the URL.
15 minutes later.
Here is your site, Mr. Customer! Do you like it?
I also like it so much. By the way the site is in the Cloud now.
Yes, our company is highly advanced in new technologies usage. It's our way to solve problems.
Every problem leads to a good solution. Every cloud has a silver lining.
*Don't forget to Terminate Instance after you finish using it!