AWS Developer Tools Blog

GA Release of AWS SDK for .NET Version 2

We are excited to announce the General Availability (GA) release of AWS SDK for .NET version 2! This is the next major release of the SDK, which adds support for Windows Store, Windows Phone, and .NET Framework 4.5 platforms. You can download it here.

Improvements

  • One of the most exciting new features of version 2 is the ability to have Windows Store and Windows Phone 8 Apps use our SDK. Like other SDKs for these new platforms, all method calls that make requests to AWS are asynchronous methods.
  • Another big improvement we made to the SDK for asynchronous programming is that when you target Windows Store, Windows Phone 8, or .NET 4.5, the SDK uses the new Task-based pattern for asynchronous programming instead of the IAsyncResult pattern using pairs of Begin and End methods. Version 2 of the SDK also consists of a version compiled for .NET 3.5 Framework that contains the Begin and End methods for applications that aren’t yet ready to move to .NET 4.5.
  • The AWS SDK for .NET provides four distinct assemblies for developers to target different platforms. However, not all SDK functionality is available on each of these platforms. This guide describes the differences in what is supported across these platforms. We have also put together a migration guide that describes how version 2 of AWS SDK for .NET differs from the first version of the SDK and how to migrate your code to use the new SDK.
  • We have also added a new Amazon S3 encryption client in this SDK. This client allows you to secure your sensitive data before you send it to Amazon S3. Using the AmazonS3EncryptionClient class, the SDK automatically encrypts data on the client when uploading to Amazon S3, and automatically decrypts it when data is retrieved.

Breaking Changes

Below are the breaking changes in version 2 of the AWS SDK for .NET that you need to be aware of if you are migrating from version 1 of the SDK.

The region parameter is now mandatory

The SDK now requires the region to be explicitly specified through the client constructor or by using the AWSRegion setting in the application’s app or web config file. Prior versions of the SDK implicitly defaulted to us-east-1 if the region was not set. Here is an example of setting a region in the app config file so applications that are not explicitly setting a region can take this update without making any code changes.

<configuration>
  <appsettings>
    <add key="AWSRegion" value="us-east-1">
  </add></appsettings>
</configuration>

Here is an example of instantiating an Amazon S3 client using the new method on AWSClientFactory that accepts a RegionEndpoint parameter.

var s3Client = AWSClientFactory.CreateAmazonS3Client(accessKey,secretKey,RegionEndpoint.USWest2);

Fluent programming methods are no longer supported

The “With” methods on model classes that are present in version 1 of the SDK are not supported in version 2. You can use constructor initializers when creating new instances.

Here is an example that demonstrates this change. Calling the “With” methods using version 1 of the SDK to set up a TransferUtilityUploadRequest object looks like this:

TransferUtilityUploadRequest uploadRequest = new TransferUtilityUploadRequest()
    .WithBucketName("my-bucket")
    .WithKey("test")
    .WithFilePath("c:test.txt");

In version 2 of the SDK, you can instead use constructor initializers like this:

TransferUtilityUploadRequest uploadRequest = new TransferUtilityUploadRequest
{
    BucketName = "my-bucket",
    Key = "test",
    FilePath = "c:test.txt"
};

Resources

Here are a few resources that you will find handy while working with the new SDK.