Getting Started with the AWS SDK for .NET
To get started with the AWS SDK for .NET, complete the following tasks:
To access AWS, you need an AWS account.
To sign up for an AWS account
- Open http://aws.amazon.com/, and then choose Create an AWS Account.
- Follow the instructions. Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone keypad.
AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to http://aws.amazon.com and clicking My Account/Console.
To use the the SDK, you must have a set of valid AWS credentials, which consist of an access key and a secret key. These keys are used to sign programmatic web service requests and enable AWS to verify that the request comes from an authorized source. You can obtain a set of account credentials when you create your account. However, we recommend that you do not use these credentials with the SDK. Instead, create one or more IAM users, and use those credentials. For applications that run on EC2 instances, you can use IAM roles to provide temporary credentials.
The preferred approach for handling credentials is to create a profile for each set of credentials in the SDK Store. You can create and manage profiles with the AWS Toolkit for Visual Studio, PowerShell cmdlets, or programmatically with the the SDK. These credentials are encrypted and stored separately from any project. You then reference the profile by name in your application, and the credentials are inserted at build time. This approach ensures that your credentials are not unintentionally exposed with your project on a public site. For more information, see Setting Up the AWS Toolkit for Visual Studio and Configuring AWS Credentials.
For more information about managing your credentials, see Best Practices for Managing AWS Access Keys.
To use the the SDK, you must have the following installed.
- (Required) Microsoft .NET Framework 3.5 or later
- (Required) Microsoft Visual Studio 2010 or later
- (Required) The the SDK
- (Recommended) AWS Toolkit for Visual Studio, a plugin that provides a user interface for managing your AWS resources from Visual Studio, and includes the the SDK. For more information, see Using the AWS Toolkit for Visual Studio.
NoteWe recommend using Visual Studio Professional 2010 or higher to implement your applications.
The following procedure describes how to install the AWS Tools for Windows, which contains the AWS SDK for .NET.
To install the the SDK
Go to AWS SDK for .NET. Click the Download button in the upper right corner of the page. Your browser will prompt you to save the install file.
The AWS SDK for .NET is also available on GitHub.
To begin the install process, open the saved install file and follow the on-screen instructions. Version 2 of the the SDK can be found in the
past-releasesfolder of the the SDK installation directory.
By default, the AWS Tools for Windows is installed in the Program Files directory, which requires administrator privileges. To install the AWS Tools for Windows as a non-administrator, specify a different installation directory.
(Optional) You can install extensions for the the SDK, which include a session state provider and a trace listener. For more information, see Install AWS Assemblies with NuGet.
If you have installed the Toolkit for Visual Studio on Visual Studio Professional, it includes C# project templates for a variety of AWS services, including the following basic templates:
- AWS Console Project
- A console application that makes basic requests to Amazon S3, Amazon SimpleDB, and Amazon EC2.
- AWS Empty Project
- A console application that does not include any code.
- AWS Web Project
- An ASP.NET application that makes basic requests to Amazon S3, Amazon SimpleDB, and Amazon EC2.
You can also base your application on one of the standard Visual Studio project templates. Just add
a reference to the AWS .NET library (
AWSSDK.dll), which is located in the
past-releases folder of the the SDK installation directory.
The following procedure gets you started by creating and running a new AWS Console project for Visual Studio 2012; the process is similar for other project types and Visual Studio versions. For more information on how to configure an AWS application, see Configuring Your AWS SDK for .NET Application.
To start a new project
In Visual Studio, on the File menu, select New, and then click Project to open the New Project dialog box.
Select AWS from the list of installed templates and select the AWS Console Project project template. Enter a project name, and then click OK.
Use the AWS Access Credentials dialog box to configure your application.
- Specify which account profile your code should use to access AWS. To use an existing profile, click Use existing profile and select the profile from the list. To add a new profile, click Use a new profile and enter the credentials information. For more information about profiles, see Configuring Your AWS SDK for .NET Application.
- Specify a default AWS region.
Click OK to accept the configuration, which opens the project. Examine the project's
App.configfile, which will contain something like the following:
<configuration> <appSettings> <add key="AWSProfileName" value="development"/> <add key="AWSRegion" value="us-west-2"/> </appSettings> </configuration>
The Toolkit for Visual Studio puts the values you specified in the AWS Access Credentials dialog box into the two key-value pairs in
Although using the
appSettingselement is still supported, we recommend that you move to using the
awselement instead, for example:
<configuration> <configSections> <section name="aws" type="Amazon.AWSSection, AWSSDK"/> </configSections> <aws region="us-west-2" profileName="development"/> </configuration>
For more information on use of the
awselement, see Configuration Files Reference for AWS SDK for .NET.
F5to compile and run the application, which prints the number of EC2 instances, Amazon SimpleDB tables, and Amazon S3 buckets in your account.
For more information about configuring an AWS application, see Configuring Your AWS SDK for .NET Application.