Amazon's Elastic Compute Cloud (EC2) is Amazon's web service offering for compute services. Its offerings can be leveraged by developers who work on any popular platform.
Today, we will explore how .NET developers can leverage Amazon EC2.
To get started, Amazon offers SDK for Amazon Web Services. The SDKs are offered for both .NET (Windows) as well as Eclipse (Linux).
The AWS .NET SDK can be downloaded from http://aws.amazon.com/sdkfornet/ (it is also called AWS Tools for Windows)
The installation is pretty straightforward.
Click Next. When prompted about the EULA (End User License Agreement), mark the checkbox to accept the license agreement and click Next.
Choose the folder in which you want to install.
Click Install to begin the installation.
You will be prompted for admin credentials.
When Visual Studio is started for the first time after installation, you will notice a window titled "AWS Toolkit for Microsoft Visual Studio".
Click "Getting Started" on the window to configure Visual Studio with AWS credentials.
Here, you need to enter your user credentials (you will need both the access key id as well as secret access key.
Once the configuration is completed successfully, you will see the AWS Explorer on the left side of the IDE.
Create a new Amazon EC2 project by selecting the "AWS EC2 Sample" template under Visual C# -> AWS -> "Compute and Networking"
Leave the default as it is and click OK.
Look at the default code that is generated. This code creates PowerShell script that launches an EC2 instance.
Please note that I have commented out the code that is highlighted above.
Our test application is now ready. You can compile it and run it. If you are having trouble following along, you can download the code from here.
Debugging the Application
When you are run the application, the application will run and display output as under:
For the application to complete, you will need to stop the instance that has been created from the AWS Management Console. Once you stop the instance, the application continues and terminates:
In this article, we learned how .NET developers can start developing applications to use Amazon EC2. I hope you have found this information useful.