AWS SDK for .NET Developer Guide Version v2.0.
AWS SDK for .NET Developer Guide AWS SDK for .NET: Developer Guide Copyright © 2015 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. The following are trademarks of Amazon Web Services, Inc.
AWS SDK for .NET Developer Guide Table of Contents AWS SDK for .NET Developer Guide ................................................................................................ 1 How to Use This Guide ........................................................................................................... 1 Supported Services and Revision History .................................................................................. 2 About Amazon Web Services .............................................
AWS SDK for .NET Developer Guide Amazon Simple Notification Service (Amazon SNS) ................................................................. Programming Models .................................................................................................. Amazon Simple Queue Service (Amazon SQS) ....................................................................... Programming Models ..................................................................................................
AWS SDK for .NET Developer Guide How to Use This Guide AWS SDK for .NET Developer Guide The AWS SDK for .NET is a single downloadable package that includes Visual Studio project templates, the AWS .NET library, C# code samples, and documentation. The AWS SDK for .NET makes it easier for Windows developers to build .
AWS SDK for .NET Developer Guide Supported Services and Revision History Programming with the AWS SDK for .NET (p. 8) The basics of how to implement applications with the SDK for .NET that applies to all AWS services. This chapter also includes information about how to migrate code to the latest version of the SDK for .NET, and describes the differences between the last version and this one. Programming with AWS Services (p. 41) A set of tutorials, walkthroughs, and examples of how to use the SDK for .
AWS SDK for .NET Developer Guide Create an AWS Account and Credentials Getting Started with the AWS SDK for .NET To get started with the AWS SDK for .NET, complete the following tasks: Tasks • Create an AWS Account and Credentials (p. 3) • Install the .NET Development Environment (p. 4) • Install the AWS SDK for .NET (p. 4) • Start a New Project (p. 5) Create an AWS Account and Credentials To access AWS, you need an AWS account. To sign up for an AWS account 1. 2. Open http://aws.amazon.
AWS SDK for .NET Developer Guide Install the .NET Development Environment 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.
AWS SDK for .NET Developer Guide Start a New Project 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.
AWS SDK for .NET Developer Guide Start a New Project 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 (p. 8). • Specify a default AWS region. 4.
AWS SDK for .NET Developer Guide Start a New Project Note Although using the appSettings element is still supported, we recommend that you move to using the aws element instead, for example: For more information on use of the aws element, see Configuration Files Reference for AWS SDK for .NET (p. 18). 5.
AWS SDK for .NET Developer Guide Configuring Your Application Programming with the AWS SDK for .NET This section provides general information for developing software with the AWS SDK for .NET. For information about developing software with the AWS SDK for .NET for specific AWS services, see Programming with AWS Services (p. 41). Topics • Configuring Your Application (p. 8) • Asynchronous APIs (p. 26) • Migrating Your Code to the Latest SDK (p. 33) • Platform Differences (p.
AWS SDK for .NET Developer Guide Configuring AWS Credentials Another way to configure an application is to edit the appSettings element in the project's App.config or Web.config file. The following example specifies the AWSRegion (p. 16) and AWSLogging (p. 15) parameters. These settings take affect only after the application has been rebuilt.
AWS SDK for .NET Developer Guide Configuring AWS Credentials IAM credentials are easier to revoke if they are compromised and you can apply a policy to each user that restricts them to a specified set of resources and actions. • The preferred approach for managing credentials is to put a profile for each set of IAM user credentials that you want to use in the SDK Store (preferred) or a credentials file. You can then reference a particular profile programmatically or in your application's App.config or Web.
AWS SDK for .NET Developer Guide Configuring AWS Credentials Using a Credentials File You can also store profiles in a credentials file, which can also be used by the other AWS SDKS, the AWS CLI, and AWS Tools for Windows PowerShell. To reduce the risk of accidentally exposing credentials, the credentials file is stored separately from any projects, usually in the user's home folder. However, the profiles are stored in plaintext, so a credentials file is not as secure as the SDK Store.
AWS SDK for .NET Developer Guide Configuring AWS Credentials Specifying a Profile Profiles are the preferred way to use credentials in an application running locally. You can store profiles in the SDK Store or in the credentials file. You don't have to specify where the profile is stored. Just reference the profile by name, and the SDK for .NET retrieves the corresponding credentials, as described in the previous section.
AWS SDK for .NET Developer Guide AWS Region Selection Although you can reference a profile programmatically by using Amazon.Runtime.StoredProfileAWSCredentials, we recommend that you use the aws element instead. The following example references a profile named development and uses it to create an AmazonS3Client object. AWSCredentials credentials = new StoredProfileAWSCredentials("development"); IAmazonS3 s3Client = new AmazonS3Client(credentials, RegionEndpoint.
AWS SDK for .NET Developer Guide Additional Application Parameters AmazonEC2Config config = new AmazonEC2Config(); config.ServiceURL = "https://us-east-1.amazonaws.com"; Amazon.Runtime.AWSCredentials credentials = new Amazon.Runtime.StoredPro fileAWSCredentials("profile_name"); AmazonEC2Client ec2 = new AmazonEC2Client(credentials, config); You can also specify the region using the RegionEndpoint class.
AWS SDK for .NET Developer Guide Additional Application Parameters Alternatively, you can set the AWSEndpointDefinition key in the section: Alternatively, to set the endpoint definition file with the SDK for .NET API, set the AWSConfigs.EndpointDefinition property: AWSConfigs.EndpointDefinition = @"c:\config\endpoints.
AWS SDK for .NET Developer Guide Additional Application Parameters Alternatively, set the AWSLogMetrics key in the section: Alternatively, to set metrics logging with the SDK for .NET API, set the AWSConfigs.LogMetrics property: AWSConfigs.LogMetrics = true; This setting configures the default LogMetrics property for all clients/configs. Changes to this setting take effect only for new AWS client instances.
AWS SDK for .NET Developer Guide Additional Application Parameters AWSConfigs.ResponseLogging = ResponseLoggingOption.OnError; Changes to this setting take effect immediately. AWS.DynamoDBContext.TableNamePrefix Configures the default TableNamePrefix that the DynamoDBContext will use if not manually configured. To set the table name prefix in the .
AWS SDK for .NET Developer Guide Configuration Files Reference To set Signature Version 4 signing for Amazon S3 in the .config file, the recommended approach is to set the useSignatureVersion4 attribute of the s3 element, which is a child element of the aws element: Alternatively, set the AWS.S3.UseSignatureVersion4 key to true in the section: PAGE 23AWS SDK for .NET Developer Guide Configuration Files Reference • Allowed Elements (p. 19) • Elements Reference (p. 20) Declaring an AWS Settings Section You specify AWS settings in an App.config or Web.config file from within the aws element. Before you can begin using the aws element, you must cerate a section element (which is a child element of the configSections element) and set its name attribute to aws and its type attribute to Amazon.
AWS SDK for .NET Developer Guide Configuration Files Reference toTable="string value" />
AWS SDK for .NET Developer Guide Configuration Files Reference ... dynamoDB The dynamoDB element represents a collection of settings for Amazon DynamoDB. This element can include the conversionSchema attribute, which represents the version to use for converting between .NET and DynamoDB objects. Allowed values include V1 and V2. (This attribute maps to the Amazon.DynamoDBv2.DynamoDBEntryConversion class in the AWS SDK for .NET.) For more information, see DynamoDB Series - Conversion Schemas.
AWS SDK for .NET Developer Guide Configuration Files Reference from the Amazon.AWSConfigs.EC2Config.UseSignatureVersion4 property in the AWS SDK for .NET.) The parent of the ec2 element is the aws (p. 21) element. The ec2 element contains no child elements. The following is an example of the ec2 element in use: ... ... logging The logging element represents a collection of settings for response logging and performance metrics logging.
AWS SDK for .NET Developer Guide Configuration Files Reference ... ... map The map element represents a single item in a collection of type-to-table mappings from .NET types to DynamoDB tables. (This element maps to an instance of the Amazon.Util.TypeMapping class from the Amazon.AWSConfigs.DynamoDBConfig.Context.
AWS SDK for .NET Developer Guide Configuration Files Reference The parent of the property element is the map (p. 24) element. The property element contains no child elements. The following is an example of the property element in use: ... ... proxy The proxy element represents settings for configuring a proxy for the SDK for .NET to use.
AWS SDK for .NET Developer Guide Asynchronous APIs ... ... Amazon Web Services Asynchronous APIs for .NET Topics • Asynchronous API for .NET 4.5, Windows Store, and Windows Phone 8 (p. 26) • Asynchronous API for .NET 3.5 (p. 26) Asynchronous API for .NET 4.5, Windows Store, and Windows Phone 8 The AWS SDK for .NET uses the new task-based asynchronous pattern for .NET 4.5, Windows Store, and Windows Phone 8.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 PutItemResponse PutItem( PutItemRequest putItemRequest ) Asynchronous Method IAsyncResult BeginPutItem( GetSessionTokenRequest getSessionTokenRequest, AsyncCallback callback, Object state ) AsyncCallback callback The callback function is called when the asynchronous operation completes. When the function is called, it receives a single parameter of type IAsyncResult. The callback function has the following signature.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 // // You will need to use your own bucket name below in order // to run this sample code. // PutObjectRequest request = new PutObjectRequest { BucketName = "PUT YOUR OWN EXISTING BUCKET NAME HERE", Key = "Item", ContentBody = "This is sample content..." }; // // additional example code // } No Callback Specified The following example code calls BeginPutObject, performs some work, then calls EndPutObject to retrieve the service response.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 Callback with Client This example assumes that the following callback function has been defined. public static void CallbackWithClient(IAsyncResult asyncResult) { try { AmazonS3Client s3Client = (AmazonS3Client) asyncResult.AsyncState; PutObjectResponse response = s3Client.EndPutObject(asyncResult); Console.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 PutObjectResponse response = state.Client.EndPutObject(asyncResult); Console.WriteLine("Finished PutObject. Elapsed time: {0}", (DateTime.Now - state.Start).ToString()); } catch (AmazonS3Exception s3Exception) { // // Code to process exception // } } The following line of code calls BeginPutObject and specifies the above callback function. When the PutObject operation completes, the callback function is called.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 public DateTime Start { get { return startTime; } set { startTime = value; } } } class Program { public static void Main(string[] args) { TestPutObjectAsync(); } public static void SimpleCallback(IAsyncResult asyncResult) { Console.WriteLine("Finished PutObject operation with simple callback"); Console.Write("\n\n"); } public static void CallbackWithClient(IAsyncResult asyncResult) { try { AmazonS3Client s3Client = (AmazonS3Client) asyncResult.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 catch (AmazonS3Exception s3Exception) { // // Code to process exception // } } public static void TestPutObjectAsync() { // Create a client AmazonS3Client client = new AmazonS3Client(); PutObjectResponse response; IAsyncResult asyncResult; // // Create a PutObject request // // You will need to change the BucketName below in order to run this // sample code.
AWS SDK for .NET Developer Guide Migrating Your Code to the Latest SDK request.Key = "Item2"; asyncResult = client.BeginPutObject(request, SimpleCallback, null); request.Key = "Item3"; asyncResult = client.BeginPutObject(request, CallbackWithClient, cli ent); request.Key = "Item4"; asyncResult = client.BeginPutObject(request, CallbackWithState, new ClientState { Client = client, Start = DateTime.Now } ); Thread.Sleep( TimeSpan.FromSeconds(5) ); } } } See Also • Getting Started (p.
AWS SDK for .NET Developer Guide What's Different • Updated names for classes and properties to follow .NET conventions What's Different Architecture The AWS SDK for .NET uses a common runtime library to make AWS service requests. In version 1 of the SDK, this "common" runtime was added after the initial release, and several of the older AWS services did not use it. As a result, there was a higher degree of variability among services in the functionality provided by the AWS SDK for .NET version 1.
AWS SDK for .NET Developer Guide What's Different TransferUtilityUploadRequest uploadRequest = new TransferUtilityUploadRequest() { BucketName = "my-bucket", Key = "test", FilePath = "c:\test.txt", ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256 }; Removal of SecureString The use of System.Security.SecureString was removed in version 2 of the SDK because it is not available on the WinRT and Windows Phone 8 platforms.
AWS SDK for .NET Developer Guide What's Different As a result, many of the exception properties have changed; the XML property is no longer provided, for example. Amazon Redshift • The ClusterVersion.Name property has been renamed ClusterVersion.Version. Amazon S3 • AmazonS3Config.CommunicationProtocol was removed to be consistent with other services where ServiceURL contains the protocol. • The PutACLRequest.ACL property has been renamed AccessControlList to make it consistent with GetACLResponse.
AWS SDK for .NET Developer Guide Platform Differences Response and Result Classes To simplify your code, the Response and Result classes that are returned when creating a service object have been collapsed. For example, the code to get an Amazon SQS queue URL previously looked like this: GetQueueUrlResponse response = SQSClient.
AWS SDK for .NET Developer Guide AWS SDK for .NET Framework 4.5 AWS SDK for .NET Framework 4.5 The version of the SDK for .NET compiled against .NET Framework 4.5 supports the same set of services as version 1 of SDK for .NET. However, it uses a different pattern for asynchronous calls. Instead of the Begin/End pattern it uses the task-based pattern, which allows developers to use the new async and await keywords introduced in C# 5.0. AWS SDK for Windows RT The version of the SDK for .
AWS SDK for .NET Developer Guide Install AWS Assemblies with NuGet • IO Namespace Also, the Windows Phone 8 version of the SDK does not support decryption of the Windows password using the GetDecryptedPassword method. Install AWS Assemblies with NuGet NuGet is a package management system for the .NET platform. With NuGet, you can add the AWSSDK assembly and the TraceListener and SessionProvider extensions to your application without first installing the SDK.
AWS SDK for .NET Developer Guide NuGet Package Manager Console NuGet Package Manager Console To use NuGet from the Package Manager Console within Visual Studio: • Visual Studio 2010 – From the Tools menu, select Library Package Manager, and click Package Manager Console. • Visual Studio 2012 – From the Tools menu, select Nuget Package Manager, and click Package Manager Console. From the console, you can install the AWS assemblies using the Install-Package command. For example, to install the AWS SDK for .
AWS SDK for .NET Developer Guide AWS Resource APIs for .NET Programming AWS Services with the AWS SDK for .NET The following concepts, tutorials, and examples demonstrate how to use the AWS SDK for .NET to work with individual Amazon Web Services. Before you begin, be sure that you have set up the AWS SDK for .NET (p. 3) and that you have reviewed the material in the Programming with the AWS SDK for .NET (p. 8). Topics • AWS Resource APIs for .NET (p. 41) • AWS CloudFormation (p. 45) • Amazon DynamoDB (p.
AWS SDK for .NET Developer Guide AWS Resource APIs for .NET Caution The AWS Resource APIs for .NET are currently provided as a preview. This means that these resource APIs may frequently change in response to customer feedback, and these changes may happen without advance notice. Until these resource APIs exit the preview stage, please be cautious about writing and distributing production-quality code that relies on them. Using the AWS Resource APIs for .
AWS SDK for .NET Developer Guide Download and Reference the AWS Resource APIs for .NET var response = client.CreateUser(request); Console.WriteLine("User Name = '{0}', ARN = '{1}'", response.User.UserName, response.User.Arn); } catch (EntityAlreadyExistsException) { Console.WriteLine("User 'DemoUser' already exists.
AWS SDK for .NET Developer Guide Code Examples for Resource APIs Note that after unzipping, there will be three files: AWSSDK.dll, AWSSDK.pdb, and AWSSDK.xml. To enable robust debugging and help within Visual Studio, make sure that these three files remain together in the same folder. 3. From the project in Visual Studio that you want to use the resource APIs with, set a reference to the AWS Resource APIs for .NET library file that you just unzipped.
AWS SDK for .NET Developer Guide AWS CloudFormation AWS CloudFormation Programming with the AWS SDK for .NET The AWS SDK for .NET supports AWS CloudFormation, which creates and provision AWS infrastructure deployments predictably and repeatedly. For more information, see AWS CloudFormation. The following information introduces you to the AWS CloudFormation programming models in the SDK for .NET. Programming Models The SDK for .NET provides two programming models for working with AWS CloudFormation.
AWS SDK for .NET Developer Guide Amazon DynamoDB For related API reference information, see Amazon.CloudFormation and Amazon.CloudFormation.Model in the AWS SDK for .NET API Reference. Resource APIs The SDK for .NET provides the AWS Resource APIs for .NET for programming with AWS CloudFormation. These resource APIs provide a resource-level programming model that enables you to write code to work more directly with AWS CloudFormation resources as compared to their low-level API counterparts.
AWS SDK for .NET Developer Guide Programming Models • Using Expressions with DynamoDB (p. 52) • JSON Support in Amazon DynamoDB (p. 63) • Managing ASP.NET Session State with Amazon DynamoDB (p. 65) Programming Models The SDK for .NET provides three different programming models for communicating with DynamoDB. These programming models include the low-level model, the document model, and the object persistence model.
AWS SDK for .NET Developer Guide Programming Models // "HASH" = hash key, "RANGE" = range key. KeyType = "HASH" }, new KeySchemaElement { AttributeName = "Type", KeyType = "RANGE" }, }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 10, WriteCapacityUnits = 5 }, }; var response = client.CreateTable(request); Console.WriteLine("Table created with request ID: " + response.ResponseMetadata.
AWS SDK for .NET Developer Guide Programming Models } } while (status != TableStatus.ACTIVE); In the preceding example, the target table to check is referenced through the AmazonDynamoDBClient class's DescribeTable method. Every 5 seconds, the code checks the value of the table's TableStatus property. When the status is set to ACTIVE, then the table is ready to be modified. The following example shows how to use the low-level model to insert two items into a table in DynamoDB: // using Amazon.
AWS SDK for .NET Developer Guide Programming Models Document The document programming model provides an easier way to work with data in DynamoDB. This model is specifically intended for accessing tables and items in tables. You access this model through the Amazon.DynamoDBv2.DocumentModel namespace. Of the three models, the document model is easier to code against DynamoDB data compared to the low-level programming model. For example, you don't have to convert as many .
AWS SDK for .NET Developer Guide Programming Models int id = item["Id"].AsInt(); Or, you could simply perform an explicit cast here by using (int): int id = (int)item["Id"]; For more information about data type conversions with DynamoDB, see DynamoDB Data Types and DynamoDBEntry. For more information and examples about the DynamoDB document model, see .NET: Document Model. Object Persistence The object persistence programming model is specifically designed for storing, loading, and querying .
AWS SDK for .NET Developer Guide Additional Resources context.Save(item); In the preceding example, the item is inserted through the DynamoDBContext class's Save method, which takes an initialized instance of the .NET class that represents the item. (The instance of the DynamoDBContext class is initialized with an instance of the AmazonDynamoDBClient class.) The following example shows how to use an instance of this .NET object to get an item from a table in DynamoDB: // using Amazon.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB Topics • Sample Data (p. 53) • Get a Single Item by Using Expressions and the Item's Primary Key (p. 56) • Get Multiple Items by Using Expressions and the Table's Primary Key (p. 57) • Get Multiple Items by Using Expressions and Other Item Attributes (p. 58) • Print an Item (p. 58) • Create or Replace an Item by Using Expressions (p. 60) • Update an Item by Using Expressions (p. 61) • Delete an Item by Using Expressions (p.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB "N": "1" }, "RelatedItems": { "NS": [ "341", "472", "649" ] }, "Pictures": { "L": [ { "M": { "FrontView": { "S": "http://example/products/205_front.jpg" } } }, { "M": { "RearView": { "S": "http://example/products/205_rear.jpg" } } }, { "M": { "SideView": { "S": "http://example/products/205_left_side.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB "S": "301 description" }, "BicycleType": { "S": "Road" }, "Brand": { "S": "Brand-Company C" }, "Price": { "N": "185" }, "Gender": { "S": "F" }, "Color": { "SS": [ "Blue", "Silver" ] }, "ProductCategory": { "S": "Bike" }, "InStock": { "BOOL": true }, "QuantityOnHand": { "N": "3" }, "RelatedItems": { "NS": [ "801", "822", "979" ] }, "Pictures": { "L": [ { "M": { "FrontView": { "S": "http://example/products/301_front.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB } ] }, "ProductReviews": { "M": { "FiveStar": { "SS": [ "My daughter really enjoyed this bike!" ] }, "ThreeStar": { "SS": [ "This bike was okay, but I would have preferred it in my color.", "Fun to ride." ] } } } } Get a Single Item by Using Expressions and the Item's Primary Key The following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB Get Multiple Items by Using Expressions and the Table's Primary Key The following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.Query method and a set of expressions to get and then print the item that has an Id of 301, but only if the value of Price is greater than 150. Only the following attributes of the item are returned: Id, Title, and all of the ThreeStar attributes in ProductReviews. // using Amazon.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB Get Multiple Items by Using Expressions and Other Item Attributes The following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.Scan method and a set of expressions to get and then print all items that have a ProductCategory of Bike. Only the following attributes of the item are returned: Id, Title, and all of the attributes in ProductReviews. // using Amazon.DynamoDBv2; // using Amazon.DynamoDBv2.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB foreach (KeyValuePair kvp in attrs) { Console.Write(kvp.Key + " = "); PrintValue(kvp.Value); } } // Writes out just an attribute's value. public static void PrintValue(AttributeValue value) { // Binary attribute value. if (value.B != null) { Console.Write("Binary data"); } // Binary set attribute value. else if (value.BS.Count > 0) { foreach (var bValue in value.BS) { Console.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB else if (value.SS.Count > 0) { Console.Write("{0}", string.Join("\n", value.SS.ToArray())); } // Otherwise, boolean value. else { Console.Write(value.BOOL); } Console.Write("\n"); } In the preceding example, each attribute value has several data-type-specific properties that can be evaluated to determine the correct format to print the attribute.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB // using Amazon.DynamoDBv2.Model; // Provides a sample item that can be added to a table.
AWS SDK for .NET Developer Guide Using Expressions with DynamoDB // using Amazon.DynamoDBv2; // using Amazon.DynamoDBv2.
AWS SDK for .NET Developer Guide JSON Support in Amazon DynamoDB In the preceding example, the ExpressionAttributeNames property specifies the placeholder #title to represent the Title attribute. The ExpressionAttributeValues property specifies the placeholder :product to represent the value 18-Bicycle 301. The ConditionExpression property specifies that #title (Title) must equal :product (18-Bicycle 301).
AWS SDK for .NET Developer Guide JSON Support in Amazon DynamoDB Console.WriteLine(jsonPrettyText); // Output: // { // "Name" : "Shadow", // "Type" : "Horse", // "Id" : 3 // } In the preceding example, the Document class's ToJson method converts an item from the table into a JSON-formatted string. The item is retrieved through the Table class's GetItem method. To determine the item to get, in this example, the GetItem method uses the hash-and-range primary key of the target item.
AWS SDK for .NET Developer Guide Managing ASP.NET Session State with Amazon DynamoDB Additional Resources For additional information and examples of programming JSON with DynamoDB with the SDK for .NET, see: • DynamoDB JSON Support • Amazon DynamoDB Update - JSON, Expanded Free Tier, Flexible Scaling, Larger Items Managing ASP.NET Session State with Amazon DynamoDB ASP.NET applications often store session-state data in memory. However, this approach doesn't scale well.
AWS SDK for .NET Developer Guide Managing ASP.NET Session State with Amazon DynamoDB Note For now, you can leave the provisioned throughput settings at their minimum values of 1 read capacity unit and 1 write capacity unit. This will allow applications to read or write session data at the rate of once per second. If you expect higher rates of usage, you can come back to the DynamoDB console and increase these settings.
AWS SDK for .NET Developer Guide Managing ASP.NET Session State with Amazon DynamoDB /> The profile represents the AWS credentials that are used to communicate with DynamoDB to store and retrieve the session state. If you are using the AWS SDK for .NET and are specifying a profile in the appSettings section of your application's Web.config file, you do not need to specify a profile in the providers section; the AWS .NET client code will discover it at run time.
AWS SDK for .NET Developer Guide Amazon Elastic Compute Cloud (Amazon EC2) Security Considerations Once the DynamoDB table is created and the application is configured, sessions can be used as with any other session provider. As a security best practice, we recommend that you run your applications with the credentials of an AWS Identity and Access Management (IAM) user. You can use either the AWS Management Console or the AWS Toolkit for Visual Studio to create IAM users and define access policies.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances The sample code in this tutorial is written in C#, but you can use the AWS SDK for .NET with any compatible language. The AWS SDK for .NET installs a set of C# project templates, so the simplest way to start this project is to open Visual Studio, select New Project from the File menu, and then select AWS Empty Project.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances Enumerating Your Security Groups You can enumerate your security groups and check whether a particular security group exists. To enumerate your security groups Get the complete list of your security groups using DescribeSecurityGroups with no parameters. The following example checks each security group to see whether its name is my-sample-sg.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances To create a security group for EC2-Classic Create and initialize a CreateSecurityGroupRequest object. Assign a name and description to the GroupName and Description properties, respectively. The CreateSecurityGroup method returns a CreateSecurityGroupResponse object.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances Adding Rules to Your Security Group Use the following procedure to add a rule to allow inbound traffic on TCP port 3389 (RDP). This enables you to connect to a Windows instance. If you're launching a Linux instance, use TCP port 22 (SSH) instead. Tip You can get the public IP address of your local computer using a service. For example, we provide the following service: http://checkip.amazonaws.com/.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances 4. Pass the request object to the AuthorizeSecurityGroupIngress method, which returns an AuthorizeSecurityGroupIngressResponse object. var ingressResponse = ec2Client.AuthorizeSecurityGroupIngress(ingress Request); Console.WriteLine("New RDP rule for: " + ipRange); Create a Key Pair Using the SDK for .
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances This example saves the private key in the current directory, using the name of the key pair as the base file name of the .pem file. if (myKeyPair == null) { var newKeyRequest = new CreateKeyPairRequest() { KeyName = keyPairName }; var ckpResponse = ec2Client.CreateKeyPair(newKeyRequest); Console.WriteLine(); Console.WriteLine("New key: " + keyPairName); // Save the private key in a .
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances SecurityGroupIds = groups }; ImageId The ID of the AMI. For a list of public AMIs provided by Amazon, see Amazon Machine Images. InstanceType An instance type that is compatible with the specified AMI. For more information, see Instance Types in the Amazon EC2 User Guide for Microsoft Windows Instances. MinCount The minimum number of EC2 instances to launch.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances InstanceProfile = instanceProfile 3. Launch the instances by passing the request object to the RunInstances method. Save the IDs of the instances, as you need them to manage the instances. Use the returned RunInstancesResponse object to get a list of instance IDs for the new instances. The Reservation.Instances property contains a list of Instance objects, one for each EC2 instance that you successfully launched.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances string amiID = "ami-e189c8d1"; string keyPairName = "my-sample-key"; var launchRequest = new RunInstancesRequest() { ImageId = amiID, InstanceType = "t1.micro", MinCount = 1, MaxCount = 1, KeyName = keyPairName, NetworkInterfaces = enis }; ImageId The ID of the AMI. For a list of public AMIs provided by Amazon, see Amazon Machine Images. InstanceType An instance type that is compatible with the specified AMI.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances var instanceProfile = new IamInstanceProfile(); instanceProfile.Id = "winapp-instance-role-1"; instanceProfile.Arn = "arn:aws:iam::4444-5555-6666:instance-profile/winappinstance-role-1"; To specify this instance profile in the RunInstancesRequest object, add the following line. InstanceProfile = instanceProfile 4. Launch the instances by passing the request object to the RunInstances method.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances List runningInstances = statusResponse.DescribeInstancesResult.Re servation[0].Instance; foreach (Instance instance in runningInstances) { Console.WriteLine("Instance status: " + instance.InstanceState.Name); } Connecting to Your Running Instance After an instance is running, you can remotely connect to it using an RDP client on your computer.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances Tutorial: Amazon EC2 Spot Instances Overview Spot Instances enable you to bid on unused Amazon EC2 capacity and run any instances that you acquire for as long as your bid exceeds the current Spot Price. Amazon EC2 changes the Spot Price periodically based on supply and demand, and customers whose bids meet or exceed it gain access to the available Spot Instances.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances Step 1: Setting Up Your Credentials To begin using this code sample, you need to populate the App.config file with your AWS credentials, which identify you to Amazon Web Services. You specify your credentials in the files appSettings element. The preferred way to handle credentials is to create a profile in the SDK Store, which encrypts your credentials and stores them separately from any project.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances computer. If your connection to the Internet is mediated by a firewall or some other type of proxy, you will need to determine the external IP address that the proxy uses. One technique is to query a search engine such as Google or Bing with the string: "what is my IP address". 1 // TODO - Change the code below to use your external IP address. String ipSource = "XXX.XXX.XXX.XX/32"; 5 List ipRanges = new List(); ipRanges.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances three common strategies: bid to ensure cost is less than on-demand pricing; bid based on the value of the resulting computation; bid so as to acquire computing capacity as quickly as possible. • Reduce Cost Below On-Demand You have a batch processing job that will take a number of hours or days to run. However, you are flexible with respect to when it starts and when it completes.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances There are other options you can use to configure your Spot Requests. To learn more, see RequestSpotInstances in the AWS SDK for .NET. Running this code will launch a new Spot Instance Request. Note You will be charged for any Spot Instances that are actually launched, so make sure that you cancel any requests and terminate any instances you launch to reduce any associated fees.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances foreach (SpotInstanceRequest spotInstanceRequest in de scribeResponse.DescribeSpotInstanceRequestsResult.SpotInstanceRequest) { // If the state is open, it hasn't changed since we attempted 25 // to request it. There is the potential for it to transition // almost immediately to closed or canceled, so we compare // against open instead of active. if (spotInstanceRequest.State.Equals("open", StringComparis on.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances 1 try { // Cancel requests. CancelSpotInstanceRequestsRequest cancelRequest = new CancelSpotInstan ceRequestsRequest(); 5 foreach (SpotInstanceRequest spotInstanceRequest in requestResult.Re questSpotInstancesResult.SpotInstanceRequest) { cancelRequest.SpotInstanceRequestId.Add(spotInstanceRequest.SpotIn stanceRequestId); } 10 ec2.
AWS SDK for .NET Developer Guide Amazon Glacier Conclusion Congratulations! You have just completed the getting started tutorial for developing Spot Instance software with the AWS SDK for .NET. Amazon Glacier Programming with the AWS SDK for .NET The AWS SDK for .NET supports Amazon Glacier, which is a storage service optimized for infrequently used data, or "cold data." The service provides durable and extremely low-cost storage with security features for data archiving and backup.
AWS SDK for .NET Developer Guide Programming Models Console.WriteLine(" Notifications:"); Console.WriteLine(" Topic: {0}", responseNotifications.VaultNotificationConfig.SNSTopic); var events = responseNotifications.VaultNotificationConfig.Events; if (events.Any()) { Console.WriteLine(" Events:"); foreach (var e in events) { Console.WriteLine("{0}", e); } } else { Console.WriteLine(" } No events set."); } catch (ResourceNotFoundException) { Console.WriteLine(" No notifications set.
AWS SDK for .NET Developer Guide Programming Models job.StatusMessage); } } else { Console.WriteLine(" } No jobs."); } For additional examples, see: • Using the AWS SDK for .NET • Creating a Vault • Retrieving Vault Metadata • Downloading a Vault Inventory • • • • • • Configuring Vault Notifications Deleting a Vault Uploading an Archive in a Single Operation Uploading Large Archives in Parts Downloading an Archive Deleting an Archive For related API reference information, see Amazon.
AWS SDK for .NET Developer Guide Programming Models Resource APIs The SDK for .NET provides the AWS Resource APIs for .NET for programming with Amazon Glacier. These resource APIs provide a resource-level programming model that enables you to write code to work more directly with Amazon Glacier resources as compared to their low-level and high-level API counterparts. (For more information about the AWS Resource APIs for .
AWS SDK for .NET Developer Guide AWS Identity and Access Management (IAM) foreach (var job in jobs) { Console.WriteLine(" For job ID: {0}", job.Id); Console.WriteLine("Archive ID: {0}", job.ArchiveId); Console.WriteLine("Archive size in bytes: {0}", job.ArchiveSizeInBytes.ToString()); Console.WriteLine("Completed: {0}", job.Completed); Console.WriteLine("Completion date: {0}", job.CompletionDate); Console.WriteLine("Creation date: {0}", job.CreationDate); Console.
AWS SDK for .NET Developer Guide Programming Models Programming Models The SDK for .NET provides two programming models for working with IAM. These programming models are known as the low-level model and the resource model. The following information describes these models and how to use them. Low-Level APIs The SDK for .NET provides low-level APIs for programming with IAM.
AWS SDK for .NET Developer Guide Programming Models Console.WriteLine(" Access keys:"); foreach (var accessKey in responseAccessKeys.AccessKeyMetadata) { Console.WriteLine(" {0}", accessKey.AccessKeyId); } } For additional examples, see Tutorial: Using an IAM Role (p. 108). For related API reference information, see Amazon.IdentityManagement and Amazon.IdentityManagement.Model. Resource APIs The SDK for .NET provides the AWS Resource APIs for .NET for programming with IAM.
AWS SDK for .NET Developer Guide IAM Resource API Examples Console.WriteLine(" {0}", accessKey.Id); } } For additional examples, see IAM Resource API Examples (p. 94). For related API reference information, see Amazon.IdentityManagement.Resources. AWS Identity and Access Management Code Examples with the AWS Resource APIs for .NET The following code examples demonstrate how to program with IAM by using the AWS Resource APIs for .NET. The AWS Resource APIs for .
AWS SDK for .NET Developer Guide IAM Resource API Examples var user = iam.GetUserByName("DemoUser"); Console.WriteLine("For user {0}:", user.Name); Console.WriteLine(" In groups:"); foreach (var group in user.GetGroups()) { Console.WriteLine(" {0}", group.Name); } Console.WriteLine(" Policies:"); foreach (var policy in user.GetPolicies()) { Console.WriteLine(" {0}", policy.Name); } Console.WriteLine(" Access keys:"); foreach (var accessKey in user.GetAccessKeys()) { Console.WriteLine(" {0}", accessKey.
AWS SDK for .NET Developer Guide IAM Resource API Examples { Console.WriteLine(" {0}", accessKey.Id); } } Get Group Information The following example displays information about an existing group, including its associated policies and user accounts: // using Amazon.IdentityManagement.Resources; // using Amazon.IdentityManagement.Model; var iam = new IdentityManagementService(); try { var group = iam.GetGroupByName("DemoGroup"); Console.WriteLine("For group {0}:", group.Name); Console.
AWS SDK for .NET Developer Guide IAM Resource API Examples } Console.WriteLine(" Users:"); foreach (var user in group.GetUsers()) { Console.WriteLine(" {0}", user.Name); } } Get Role Information The following example displays information about an existing role, including its associated policies and instance profiles: // using Amazon.IdentityManagement.Resources; // using Amazon.IdentityManagement.Model; var iam = new IdentityManagementService(); try { var role = iam.GetRoleByName("DemoEC2"); Console.
AWS SDK for .NET Developer Guide IAM Resource API Examples Console.WriteLine(" Policies:"); foreach (var policy in role.GetPolicies()) { Console.WriteLine(" {0}", policy.Name); } Console.WriteLine(" InstanceProfiles:"); foreach (var instanceProfile in role.GetInstanceProfiles()) { Console.WriteLine(" {0}", instanceProfile.Name); } } Create a User Account The following example creates a new user account and then displays some information about it: // using Amazon.IdentityManagement.
AWS SDK for .NET Developer Guide IAM Resource API Examples Console.WriteLine("Group 'DemoGroup' already exists."); } Create a Role The following example creates a new role and then confirms whether the group was successfully created. // using Amazon.IdentityManagement.Resources; // using Amazon.IdentityManagement.Model; var iam = new IdentityManagementService(); // GenerateAssumeRolePolicy() is a custom method. string assumeRole = GenerateAssumeRolePolicy(); try { var role = iam.
AWS SDK for .NET Developer Guide IAM Resource API Examples var action = new ActionIdentifier("sts:AssumeRole"); var actions = new List(); actions.Add(action); var principal = new Principal("ec2.amazonaws.com") { Provider = "Service" }; var principals = new List(); principals.Add(principal); var statement = new Statement(Statement.StatementEffect.
AWS SDK for .NET Developer Guide IAM Resource API Examples } catch (NoSuchEntityException) { Console.WriteLine("Group 'DemoGroup' or " + "user 'DemoUser' does not exist."); } Add a Policy to a User Account, Group, or Role Add a Policy to a User Account The following example creates a new policy, adds the new policy to an existing user account, and then displays a list of the user account's associated policies: // using Amazon.IdentityManagement.Resources; // using Amazon.IdentityManagement.
AWS SDK for .NET Developer Guide IAM Resource API Examples "Statement" : [ { "Sid" : "ListDeploymentsStatement", "Effect" : "Allow", "Action" : "codedeploy:ListDeployments", "Resource" : "*" } ] } */ var action = new ActionIdentifier("codedeploy:ListDeployments"); var actions = new List(); actions.Add(action); var resource = new Resource("*"); var resources = new List(); resources.Add(resource); var statement = new Statement(Statement.StatementEffect.
AWS SDK for .NET Developer Guide IAM Resource API Examples group.CreatePolicy(policyDoc, "ListDeploymentConfigsPolicy"); Console.WriteLine("Policies for group {0}:", group.Name); foreach (var policyItem in group.GetPolicies()) { Console.WriteLine(" {0}", policyItem.Name); } } catch (NoSuchEntityException) { Console.WriteLine("Group 'DemoGroup' does not exist."); } The preceding example relies on the following example to create the new policy. The following example doesn't use the AWS Resource APIs for .
AWS SDK for .NET Developer Guide IAM Resource API Examples statements.Add(statement); var policy = new Policy { Id = "ListDeploymentConfigsPolicy", Version = "2012-10-17", Statements = statements }; return policy.ToJson(); } Add a Policy to a Role The following example creates a new policy and then adds the new policy to an existing role. The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently don't support adding a policy to a role.
AWS SDK for .NET Developer Guide IAM Resource API Examples "Version" : "2012-10-17", "Id" : "DemoEC2Permissions", "Statement" : [ { "Sid" : "DemoEC2PermissionsStatement", "Effect" : "Allow", "Action" : [ "s3:Get*", "s3:List*" ], "Resource" : "*" } ] } */ var actionGet = new ActionIdentifier("s3:Get*"); var actionList = new ActionIdentifier("s3:List*"); var actions = new List(); actions.Add(actionGet); actions.
AWS SDK for .NET Developer Guide IAM Resource API Examples var iam = new IdentityManagementService(); try { var user = iam.GetUserByName("DemoUser"); var accessKey = user.CreateAccessKey(); Console.WriteLine("For user {0}:", user.Name); Console.WriteLine(" Access key = {0}", accessKey.Id); // This is the only time that the secret access key will be displayed. Console.WriteLine(" Secret access key = {0}", accessKey.SecretAccessKey); } catch (NoSuchEntityException) { Console.
AWS SDK for .NET Developer Guide IAM Resource API Examples // using Amazon.IdentityManagement; // using Amazon.IdentityManagement.Model; var client = new AmazonIdentityManagementServiceClient(); var request = new CreateInstanceProfileRequest { InstanceProfileName = "DemoEC2-InstanceProfile" }; try { client.CreateInstanceProfile(request); } catch (EntityAlreadyExistsException) { Console.WriteLine( "The instance profile 'DemoEC2-InstanceProfile' already exists.
AWS SDK for .NET Developer Guide Tutorial: Using an IAM Role Tutorial: Grant Access Using an IAM Role and the AWS SDK for .NET All requests to AWS must be cryptographically signed using credentials issued by AWS. Therefore, you need a strategy for managing credentials for software that runs on Amazon EC2 instances. You must distribute, store, and rotate these credentials in a way that keeps them secure but also accessible to the software.
AWS SDK for .NET Developer Guide Tutorial: Using an IAM Role namespace s3.amazon.com.docsamples.retrieveobject { class S3Sample { static string bucketName = "bucket-name"; static string keyName = "folder/file-name.txt"; static IAmazonS3 client; public static void Main(string[] args) { string responseBody = ""; try { using (client = new AmazonS3Client()) { Console.
AWS SDK for .NET Developer Guide Tutorial: Using an IAM Role 5. If the program fails, ensure that you are using credentials that provide you with access to the bucket. (Optional) Transfer the sample program to a running Windows instance on which you haven't set up credentials. Run the program and verify that it fails because it can't locate credentials. Create an IAM Role Create an IAM role that has the appropriate permissions to access Amazon S3. To create the IAM role 1. Open the IAM console. 2. 3.
AWS SDK for .NET Developer Guide Tutorial: Using an IAM Role Note Alternatively, connect using the Toolkit for Visual Studio (as described in Connecting to an Amazon EC2 Instance in the AWS Toolkit for Visual Studio User Guide) and then copy the files from your local drive to the instance. The Remote Desktop session is automatically configured so that your local drives are available to the instance. To run the sample program on the EC2 instance 1. 2. Open the Amazon EC2 console.
AWS SDK for .NET Developer Guide Amazon Route 53 Amazon Route 53 Programming with the AWS SDK for .NET The AWS SDK for .NET supports Amazon Route 53, which is a highly available and scalable Domain Name System (DNS) web service. Topics • Updating Amazon Route 53 Resource Record Sets (p.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets using System; using System.Collections.Generic; using System.Threading; using Amazon; using Amazon.Route53; using Amazon.Route53.Model; namespace Route53_RecordSet { //Create a hosted zone and add a basic record set to it class recordset { public static void Main(string[] args) { string domainName = "www.example.org"; //[1] Create an Amazon Route 53 client object IAmazonRoute53 route53Client = AWSClientFactory.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets ChangeBatch = changeBatch }; ChangeResourceRecordSetsResponse recordsetResponse = route53Cli ent.ChangeResourceRecordSets(recordsetRequest); //[5] Monitor the change status GetChangeRequest changeRequest = new GetChangeRequest() { Id = recordsetResponse.ChangeInfo.Id }; while (route53Client.GetChange(changeRequest).ChangeInfo.Status == ChangeStatus.PENDING) { Console.WriteLine("Change is pending."); Thread.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets • CallerReference – (Required) An arbitrary user-defined string that serves as a request ID and can be used to retry failed requests. If you run this application multiple times, you must change the CallerReference value. 2. Pass the CreateHostedZoneRequest object to the client object's CreateHostedZone method.
AWS SDK for .NET Developer Guide Amazon Simple Storage Service (Amazon S3) 2. Pass the ChangeResourceRecordSetsRequest object to the client object's ChangeResourceRecordSets method. It returns a ChangeResourceRecordSetsResponse object, which contains a request ID that you can use to monitor the request's progress. [5] Monitor the update status Resource record set updates typically take a minute or so to propagate through the system.
AWS SDK for .NET Developer Guide Amazon Simple Notification Service (Amazon SNS) • Specifying Server-Side Encryption with Customer-Provided Encryption Keys Amazon Simple Notification Service Programming with the AWS SDK for .NET The AWS SDK for .NET supports Amazon Simple Notification Service (Amazon SNS), which is a web service that enables applications, end-users, and devices to instantly send and receive notifications from the cloud. For more information, see Amazon SNS.
AWS SDK for .NET Developer Guide Programming Models { Console.WriteLine(" {0}", sub.SubscriptionArn); } } var attrs = client.GetTopicAttributes( new GetTopicAttributesRequest { TopicArn = topic.TopicArn }).Attributes; if (attrs.Any()) { Console.WriteLine(" Attributes:"); foreach (var attr in attrs) { Console.WriteLine(" {0} = {1}", attr.Key, attr.Value); } } Console.WriteLine(); } request.NextToken = response.NextToken; } while (!string.IsNullOrEmpty(response.
AWS SDK for .NET Developer Guide Amazon Simple Queue Service (Amazon SQS) if (topic.Attributes.Count > 0) { Console.WriteLine(" Attributes:"); foreach (var attr in topic.Attributes) { Console.WriteLine("{0} = {1}", attr.Key, attr.Value); } } } } var subs = sns.GetSubscriptions(); if (subs.Any()) { Console.WriteLine("Subscriptions:"); foreach (var sub in subs) { Console.WriteLine(" Subscription ARN: {0}", sub.Arn); var attrs = sub.Attributes; if (attrs.Any()) { Console.
AWS SDK for .NET Developer Guide Programming Models • Creating and Using an Amazon SQS Queue (p. 121) Programming Models The SDK for .NET provides two programming models for working with Amazon SQS. These programming models are known as the low-level and resource models. The following information describes these models, how to use them, and why you would want to use them. Low-Level APIs The SDK for .NET provides low-level APIs for programming with Amazon SQS.
AWS SDK for .NET Developer Guide Creating and Using an Amazon SQS Queue Resource APIs The SDK for .NET provides the AWS Resource APIs for .NET for programming with Amazon SQS. These resource APIs provide a resource-level programming model that enables you to write code to work more directly with Amazon SQS resources as compared to their low-level API counterparts. (For more information about the AWS Resource APIs for .
AWS SDK for .NET Developer Guide Creating and Using an Amazon SQS Queue Create an Amazon SQS Client You will need an Amazon SQS client in order to create and use an Amazon SQS queue. Before configuring your client, you should create an App.Config file to specify your AWS credentials. You specify your credentials by referencing the appropriate profile in the appSettings section of the file. The following example specifies a profile named my_profile.
AWS SDK for .NET Developer Guide Creating and Using an Amazon SQS Queue Create an Amazon SQS Queue You can use the AWS SDK for .NET to programmatically create an Amazon SQS queue. Creating an Amazon SQS Queue is an administrative task. You can create a queue by using the AWS Management Console instead of creating a queue programmatically. To create an Amazon SQS queue 1. Create and initialize a CreateQueueRequest instance.
AWS SDK for .NET Developer Guide Creating and Using an Amazon SQS Queue Send an Amazon SQS Message You can use the Amazon SDK for .NET to send a message to an Amazon SQS queue. Important Due to the distributed nature of the queue, Amazon SQS cannot guarantee you will receive messages in the exact order they are sent. If you require that message order be preserved, place sequencing information in each message so you can reorder the messages upon receipt. To send a message to an Amazon SQS queue 1.
AWS SDK for .NET Developer Guide Creating and Using an Amazon SQS Queue 2. Pass the request object as a parameter to the ReceiveMessage method, as follows: ReceiveMessageResponse receiveMessageResponse = amazonSQSClient.ReceiveMessage(receiveMessageRequest); The method returns a ReceiveMessageResponse instance, containing the list of messages the queue contains. 3. The response object contains a ReceiveMessageResult member. This member includes a Messages list.
AWS SDK for .NET Developer Guide Additional Services DeleteMessageResponse response = amazonSQSClient.DeleteMessage(deleteMessageRequest); Calling DeleteMessage unconditionally removes the message from the queue, regardless of the visibility timeout setting. For more information about visibility timeouts, go to Visibility Timeout. For information about sending a message to a queue, see Send an Amazon SQS Message (p. 124).
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos AWS CloudFormation Templated AWS resource creation e eS S W A -duoC l m -roF -a noi t -orP m a - rg 4 5 )p .(m n gi e eS os l a d u o l C . n o z a m A -mroF -a ,noit d u o l C . n o z a m A -mroF -a d o M . n o i t , le dna d u o l C . n o z a m A -mroF -a l i t U . n o i t Amazon CloudFront Global content delivery network e eS -eC r eta a LRU -gS i -an erut -sU gni #C dna eht TE N.
AWS SDK for .NET Developer Guide Additional Services Service Description AWS CloudHSM Secure cryptographic key storage through hardware e eS security modules (HSMs) in the AWS cloud M S H d u o l C . n o z a m A dna d o M . S H d u o l C . n o z a m A le Amazon CloudSearch Managed search service e eS d u o l C . n o z a m A hcraeS dna d u o l C . n o z a m A d o M . h c r a e S le AWS CloudTrail User activity and change tracking e eS l i a r T d u o l C . n o z a m A dna d o M .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon Cognito User identity and app data synchronization e eS nozm a A -go C ot in -eC r -ned sa l it -orP re div dna -hcC a gni nozm a A -go C ot in -nedI yt i t sDI e eS os l a g o C . n o z a m A n e d I o t i n ,ytit g o C . n o z a m A n e d I o t i n d o M . y t i t , le g o C . n o z a m A -otin ,cnyS dna g o C . n o z a m A -otin d o M .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos AWS Data Pipeline Orchestration for data-driven workflows e eS a t a D . n o z a m A enilepiP dna a t a D . n o z a m A d o M . e n i l e p i P le AWS Direct Connect Dedicated network connection to AWS e eS r i D . n o z a m A -tce -noC tcen dna r i D . n o z a m A -tce -noC d o M . t c e n le Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon DynamoDB Predictable and scalable NoSQL data store e eS -yD B D m oan -orP m a - rg 4 6 )p .(m n gi dna -nE -ecnah stn m e ot eht -yD B D m oan KDS e eS os l a y D . n o z a m A -Doman , 2vB y D . n o z a m A -Doman d o M a t a D . 2 v B , le y D . n o z a m A -Doman -coD.2vB -u -tnem -doM , le dna y D . n o z a m A -Doman -doM.2vB le Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon Elastic Compute Cloud (Amazon EC2) Virtual servers in the cloud : eeS no•zam A 2CE - o rP -marg )8 6 .p(g nm i M•A I se l oR ro f nozam A 2CE -n I secnats -•mI - t rop gn i MV -mI sega dna sm eu l oV h t iw - rewoP l l ehS dna #C e eS os l a ,2CE.nozamA m I . 2 C E . n o z a m A ,trop d o M . 2 C E . n o z a m A , le dna l i t U . 2 C E .
AWS SDK for .NET Developer Guide Additional Services Service Description Amazon ElastiCache In-memory cache - eR secruos eeS -sU gni eht -tsaE l C -i ehca retsuC l - iC l tne rof TE N. dna -l iU t -zi gni nozm a A -tsaE l C -i ehca otuA -sD i -voc yre ni TE N. hguorh T -nE mi y e eS os l a t s a l E . n o z a m A -Ci ehca dna t s a l E . n o z a m A -Ci d o M . e h c a le Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos AWS Elastic Beanstalk AWS application container e eS -eC r - ta gni dna -eD -yolp gni -tsaE l ci -nae B klats -pA -ci p l -a sn oi t ni TE N. -sU gni S W A tiko T l rof -usV i la -utS oid e eS os l a t s a l E . n o z a m A -ci -naeB klats dna t s a l E . n o z a m A -ci -naeB d o M . k l a t s le Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Elastic Load Balancing Distribute incoming application traffic across mul-e e S tiple Amazon EC2 instances t s a l E . n o z a m A -ci -daoL -laB -na gnic dna t s a l E . n o z a m A -ci -daoL -laB -na d o M . g n i c le Amazon Elastic MapReduce (Amazon EMR) Managed Hadoop framework e eS -sU gni eht S W A KDS rof TE N. ot -eC r eta na nozm a A R ME retsuC l e eS os l a t s a l E .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon Glacier Archive storage in the cloud e eS nozm a A -aG l - ic re -orP m a - rg 8 7 )p .(m n gi e eS os l a a l G . n o z a m A -ic , re a l G . n o z a m A -ic -doM.re , le dna a l G . n o z a m A -ic s n a r T . r e ref Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description AWS Identity and Access Management (IAM) Access control and key management Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos : eeS M•A I - o rP -marg )1 9 .p(g nm i -• sU gn i MA I s resU M•A I - e rC - ned lai t - oR -a t no i t e eS os l a n e d I . n o z a m A -ytit -naM -ega tnem dna n e d I . n o z a m A -ytit -naM -ega d o M . t n e m le e eS os l a u A . n o z a m A -cA.ht -noCssec -lort ,yciloP u A . n o z a m A -cA.ht -noCssec -lort c A . y c i l o P n e d I n o i t -it -if , sre e S . n o z a m A -ruc -yti ,nekoT Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos dna e S . n o z a m A -ruc -yti d o M . n e k o T le AWS Import/Export Transferring data between the AWS cloud and portable storage devices AWS Key Management Service (AWS KMS) Encryption and key management service scaled e e S for the cloud y e K . n o z a m A -naM -ega -tnem -reS eciv dna y e K . n o z a m A -naM -ega -tnem -reS d o M .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos AWS OpsWorks DevOps application management service e eS s k r o W s p O . n o z a m A dna d o M . s k r o W s p O . n o z a m A le Amazon Relational Database Service (Amazon RDS) MySQL, Postgres, Oracle, SQL Server, and Amazon Aurora e eS S D R . n o z a m A dna d o M . S D R . n o z a m A le Amazon Redshift Managed petabyte-scale data warehouse servicee e S -no C -tcen gni ot a retsuC l yb -sU gni TE N.
AWS SDK for .NET Developer Guide Additional Services Service Description Amazon Simple Storage Service (Amazon S3) Scalable storage in the cloud Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos : eeS no•zam A 3S - o rP -marg )6 1 .p(g nm i e• h T eerhT - f iD - re f t ne s I PA ro f nozam A 3S no•zam A 3S - iL -e f e l cyc - naM - ega t nem -•k rW o gn i h t iw nozam A 3S - bO t ce j - r eV sno i s dna eh t SWA KDS ro f TEN . -•i lC t ne ed i S a t aD - nE -pyrc no i t h t iw SWA KDS ro f TEN . dna nozam A Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos 3S no•zam A 3S -snarT re f - l i tU yt i ro f - n iW swod erotS dna - n iW swod enohP e eS os l a ,3S.nozamA n E . 3 S . n o z a m A -pyrc ,noit ,OI.3S.nozamA d o M . 3 S . n o z a m A , le s n a r T . 3 S . n o z a m A , ref dna l i t U . 3 S . n o z a m A Amazon SimpleDB Highly available, scalable, and flexible non-relatione eS al data store m i S . n o z a m A BDelp dna m i S . n o z a m A d o M .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon Simple Email Service (Amazon SES) Email sending service e eS -dne S gni na lm E ia hguorh T eht nozm a A SES PT M S -nI -ret ecaf ht w i #C dna -dne S gni na lm E ia hguorh T nozm a A SES e eS os l a m i S . n o z a m A -Eelp liam dna m i S . n o z a m A -Eelp d o M . l i a m le Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description Amazon Simple Notification Service (Amazon SNS) Push notification service - eR secruos e eS nozm a A SNS -orP m a - rg 17 )p .(m n gi e eS os l a m i S . n o z a m A -Nelp -o -it -cif -a -noit -reS ,eciv m i S . n o z a m A -Nelp -o -it -cif -a -noit -reS d o M . e c i v , le dna m i S . n o z a m A -Nelp -o -it -cif -a -noit -reS l i t U .
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos Amazon Simple Queue Service (Amazon SQS) Message queue service : eeS no•zam A SQS - o rP -marg )9 1 .p(g nm i -•buS -bi rcs gn i na SQS eueuQ o t na SNS - poT c i -• sU gn i nozam A SQS daeD - t eL re t seueuQ e eS os l a ,SQS.nozamA d o M . S Q S . n o z a m A , le dna l i t U . S Q S . n o z a m A Version v2.0.
AWS SDK for .NET Developer Guide Additional Services Service Description - eR secruos AWS Storage Gateway Integrates on-premises IT environments with cloud: eeS storage -d•n iF gn i -panS s tohs -• eD - te l gn i -panS s tohs -• pU - t ad gn i -e t aG y aw -dnaB htd iw e t aR -mi L st i -• pU - t ad gn i -e t aG - yaw L TV -dnaB htd iw e t aR -mi L st i e eS os l a r o t S . n o z a m A -Gega -eta , yaw r o t S . n o z a m A -Gega -eta -doM.yaw , le dna r o t S . n o z a m A -Gega -eta litU.
AWS SDK for .NET Developer Guide Additional Services Area Description AWS Support Programmatic access to AWS Support cases ande e S Trusted Advisor features S W A . n o z a m A -puS trop dna S W A . n o z a m A -puS d o M . t r o p le General Helper classes and enumerations Other general progamming information for the SDK for .NET includes the following: • Overriding Endpoints in the AWS SDK for .NET • .NET Object Lifecycles Version v2.0.0 148 - eR secruos e eS nozamA dna l i t U .
AWS SDK for .NET Developer Guide Additional Resources Home Page for AWS SDK for .NET For more information about the AWS SDK for .NET, go to the home page for the SDK at http:// aws.amazon.com/sdkfornet. SDK Reference Documentation The SDK reference documentation includes the ability to browse and search across all code included with the SDK. It provides thorough documentation, usage examples, and even the ability to browse method source. For more information, see the AWS SDK for .NET API Reference.
AWS SDK for .NET Developer Guide Document History The following table describes the important changes since the last release of the AWS SDK for .NET Developer Guide. Last documentation update: February 5, 2015 Change Description Release Date New topic A new topic was added about additional options for adding February 5, 2015 settings to App.Config and Web.Config files: Configuration Files Reference for AWS SDK for .NET (p. 18).
AWS SDK for .NET Developer Guide Change Description Release Date Reorganized Table of Contents The Programming with AWS Services (p. 41) section of December 16, 2014 the Table of Contents was reorganized to group topics by service. As a result, four new topics were added: AWS Identity and Access Management (IAM) (p. 91), Amazon Elastic Compute Cloud (Amazon EC2) (p. 68), Amazon Simple Queue Service (Amazon SQS) (p. 119), and Amazon Route 53 (p. 112).