AWS SDK for .NET
Developer Guide (Version v2.0.0)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.

Getting Started with the AWS SDK for .NET

To get started with the AWS SDK for .NET, complete the following tasks:

Create an AWS Account and Credentials

To access AWS, you need an AWS account.

To sign up for an AWS account

  1. Open http://aws.amazon.com, and then click Sign Up.

  2. Follow the on-screen 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 SDK for .NET, 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 SDK for .NET. 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 SDK for .NET. 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.

Install the .NET Development Environment

To use the SDK for .NET, you must have the following installed.

Requirements

  • (Required) Microsoft .NET Framework 3.5 or later

  • (Required) Microsoft Visual Studio 2010 or later

  • (Required) The SDK for .NET

  • (Recommended) AWS Toolkit for Visual Studio, a plugin that provides a user interface for managing your AWS resources from Visual Studio, and includes the SDK for .NET. For more information, see Using the AWS Toolkit for Visual Studio.

Note

We recommend using Visual Studio Professional 2010 or higher to implement your applications. It is possible to use Visual Studio Express to implement applications with the SDK for .NET, including installing the Toolkit for Visual Studio. However, Visual Studio Express supports only a limited set of features.

Install the AWS SDK for .NET

The following procedure describes how to install AWS SDK for .NET.

Note

If you installed the Toolkit for Visual Studio, you already have the SDK for .NET, so you can skip this step.

To install the SDK for .NET

  1. Go to http://aws.amazon.com/sdkfornet. Click the Download button in the upper right corner of the page. Your browser will prompt you to save the install file.

    Tip

    The AWS SDK for .NET is also available on GitHub.

  2. To begin the install process, open the saved install file and follow the on-screen instructions.

    Tip

    By default, the AWS SDK for .NET is installed in the Program Files directory, which requires administrator privileges. To install the AWS SDK for .NET as a non-administrator, specify a different installation directory.

  3. (Optional) You can install extensions for the SDK for .NET, which include a session state provider and a trace listener. For more information, see Install AWS Assemblies with NuGet.

To configure the .NET CLR

To ensure the best performance of your server-based applications on systems with multiple processors or processor cores, we recommend that you enable server mode garbage collection (GC). Note that without multiple processors or processor cores, server mode GC has no effect.

To enable server mode GC, add the following to your app.config file:

<runtime>
    <gcServer enabled="true"/>
    <gcConcurrent enabled="true"/>
</runtime>

Start a New Project

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 Program Files (x86)\AWS SDK for .NET\bin\Net45.

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

  1. In Visual Studio, on the File menu, select New, and then click Project to open the New Project dialog box.

  2. Select AWS from the list of installed templates and select the AWS Console Project project template. Enter a project name, and then click OK.

    New Project Dialog Box
  3. 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.

    Credentials Dialog Box
  4. Click OK to accept the configuration, which opens the project. Examine the project's App.config file, which will contain something like the following:

    <configuration>
        <appSettings>
            <add key="AWSProfileName" value="development"/>
            <add key="AWSRegion" value="us-east-1"/>
        </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 appSettings.

  5. Click F5 to 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.