AWS SDK for .NET Developer Guide Version v2.0.
AWS SDK for .NET Developer Guide AWS SDK for .NET: Developer Guide Copyright © 2014 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 Creating and Using an Amazon SQS Queue ............................................................................ Create an Amazon SQS Client ....................................................................................... Create an Amazon SQS Queue ..................................................................................... Amazon SQS Queue URLs ...........................................................................................
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. Tutorials and Examples (p. 32) 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. Go to 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 For more information about configuring an AWS application, see Configuring Your AWS SDK for .NET Application (p. 8). Version v2.0.
AWS SDK for .NET Developer Guide Configuring Your Application Programming with the AWS SDK for .NET This section provides general programming techniques and information for developing software with the AWS SDK for .NET. Topics • Configuring Your AWS SDK for .NET Application (p. 8) • AWS Region Selection (p. 16) • Amazon Web Services Asynchronous APIs for .NET (p. 16) • Migrating Your Code to the Latest Version of the AWS SDK for .NET (p. 24) • Platform Differences in the AWS SDK for .NET (p.
AWS SDK for .NET Developer Guide Configuring AWS Credentials You can also configure an SDK for .NET application programmatically, by setting property values in the AWSConfigs class. The following example specifies the AWSRegion (p. 14) and AWSLogging (p. 13) parameters: AWSConfigs.AWSRegion = "us-west-2"; AWSConfigs.Logging = LoggingOptions.Log4Net; Programmatically defined parameters override any values that were specified in an App.config or Web.config file.
AWS SDK for .NET Developer Guide Configuring AWS Credentials Topics • Using the SDK Store (p. 10) • Using a Credentials File (p. 10) • Using Credentials in an Application (p. 11) Using the SDK Store The preferred way to manage credentials for SDK for .NET applications is to add a profile to the SDK Store for each set of credentials that you want to use in your applications. • The SDK Store can contain multiple profiles from any number of accounts.
AWS SDK for .NET Developer Guide Configuring AWS Credentials [profile_name] aws_access_key_id = accessKey aws_secret_access_key = secretKey A profile can optionally include a session token. For more information, see Best Practices for Managing AWS Access Keys. Tip If you include a profile named default, the SDK for .NET will use that profile by default if it cannot find the specified profile. By default, the SDK for .NET searches for profiles only in the user's home directory.
AWS SDK for .NET Developer Guide Configuring AWS Credentials This example assumes that you are using the SDK Store or a credentials file in the default location, under the current user's home directory. If your profiles are stored in a credentials file in an arbitrary location, specify the location by adding an AWSProfilesLocation value to appSettings.
AWS SDK for .NET Developer Guide Additional Application Parameters AmazonS3Config config = new AmazonS3Config(); config.ProxyCredentials = new NetworkCredential("foo", "bar"); Earlier versions of the SDK used ProxyUsername and ProxyPassword, but these properties have been deprecated. Configuring Other Application Parameters In addition to configuring credentials (p. 9), you can configure a number of other application parameters: • AWSEndpointDefinition (p. 13) • AWSLogging (p.
AWS SDK for .NET Developer Guide Additional Application Parameters You can set multiple values at once, separated by commas. To set both log4net and System.Diagnostics logging in the .config file, use: Using the SDK for .NET API, combine the values of the LoggingOptions enumeration and set the AWSConfigs.Logging property: AWSConfigs.Logging = LoggingOptions.Log4Net | LoggingOptions.
AWS SDK for .NET Developer Guide Additional Application Parameters To set service logging with the SDK for .NET API, set the AWSConfigs.ResponseLogging property to one of the values of the ResponseLoggingOption enumeration: 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 AWS Region Selection By default, this setting is false, though Signature Version 4 may be used by default in some cases or with some regions. When the setting is true, Signature Version 4 will be used for all requests. Changes to this setting take effect only for new Amazon EC2 client instances. AWS Region Selection AWS regions allow you to access AWS services that reside physically in a specific geographic region.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 4.5, Windows Store, and Windows Phone 8 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.You can use the async and await keywords to perform and manage asynchronous operations for all AWS products without blocking.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 void Callback(IAsyncResult asyncResult) Object state The third parameter, state, is a user-defined object that is made available to the callback function as the AsyncState property of the asyncResult parameter, that is, asyncResult.AsyncState. Calling Patterns • Passing a callback function and a state object. • Passing a callback function, but passing null for the state object.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 No Callback Specified The following example code calls BeginPutObject, performs some work, then calls EndPutObject to retrieve the service response.The call to EndPutObject is enclosed in a try block to catch any exceptions that might have been thrown during the operation. asyncResult = client.BeginPutObject(request, null, null); while ( ! asyncResult.IsCompleted ) { // // Do some work here // } try { response = client.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 } } The following line of code calls BeginPutObject and specifies the preceding callback function. When the PutObject operation completes, the callback function is called. In this example, the call to BeginPutObject specifies the Amazon S3 client object for the state parameter. The callback function uses the client to call the EndPutObject method to retrieve the server response.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 callback function uses the Amazon S3 client object to call the EndPutObject method to retrieve the server response. The callback also extracts the start time for the operation and uses it to print the time it took for the asynchronous operation to complete. As in the previous examples, because exceptions that occur during the operation are received when EndPutObject is called, this call is placed within a try block. asyncResult = client.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 { Console.WriteLine("Finished PutObject operation with simple callback"); Console.Write("\n\n"); } public static void CallbackWithClient(IAsyncResult asyncResult) { try { AmazonS3Client s3Client = (AmazonS3Client) asyncResult.AsyncState; PutObjectResponse response = s3Client.EndPutObject(asyncResult); Console.WriteLine("Finished PutObject operation with client call back"); Console.WriteLine("Service Response:"); Console.
AWS SDK for .NET Developer Guide Asynchronous API for .NET 3.5 // Create a PutObject request // // You will need to change the BucketName 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..." }; response = client.PutObject(request); Console.WriteLine("Finished PutObject operation for {0}.", request.Key); Console.WriteLine("Service Response:"); Console.
AWS SDK for .NET Developer Guide Migrating Your Code to the Latest SDK See Also • Getting Started (p. 3) • Programming with the AWS SDK for .NET (p. 8) Migrating Your Code to the Latest Version of the AWS SDK for .NET This guide describes changes in the latest version of the SDK, and how you can migrate your code to the latest SDK. Topics • Introduction (p. 24) • What's New (p. 24) • What's Different (p. 24) Introduction The AWS SDK for .NET was released in November 2009 and was originally designed for .
AWS SDK for .NET Developer Guide What's Different • The version 2 runtime for .NET 3.5 is similar to the existing version 1 runtime, which is based on the System.Net.HttpWebRequest class and uses the Begin and End pattern for asynchronous methods. • The version 2 runtime for .NET 4.5 is based on the new System.Net.Http.HttpClient class and uses Tasks for asynchronous methods, which enables users to use the new async and await keywords in C# 5.0.
AWS SDK for .NET Developer Guide What's Different • All client interfaces have been renamed to follow the .NET convention of starting with the letter "I". For example, the AmazonEC2 class is now IAmazonEC2. • Properties for collections have been properly pluralized. • AWSClientFactory.CreateAmazonSNSClient has been renamed CreateAmazonSimpleNotificationServiceClient. • AWSClientFactory.CreateAmazonIdentityManagementClient has been renamed CreateAmazonIdentityManagementServiceClient.
AWS SDK for .NET Developer Guide What's Different • The GenerateMD5 property has been removed from PutObjectRequest and UploadPartRequest because this is now automatically computed as the object is being written to Amazon S3 and compared against the MD5 returned in the response from Amazon S3. • The PutBucketTagging.TagSets collection is now PutBucketTagging.TagSet, and now takes a list of Tag objects.
AWS SDK for .NET Developer Guide Platform Differences Refer to the return value type of the Create* method for the service client that you're using to see what values are returned. These are all listed in the AWS SDK for .NET API Reference. Platform Differences in the AWS SDK for .NET 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.
AWS SDK for .NET Developer Guide Install AWS Assemblies with NuGet This version of the SDK for .NET supports only the following services. This is the same set of services as those supported in the AWS SDK for Android and the AWS SDK for iOS.
AWS SDK for .NET Developer Guide NuGet from Solution Explorer NuGet from Solution Explorer To use NuGet from Solution Explorer, right-click on your project and select Manage NuGet Packages... from the context menu. From the Manage NuGet Packages dialog box, select Online in the left pane. You can then search for the package that you want to install using the search box in the upper right corner. The screenshot shows the AWS.Extensions assembly package.
AWS SDK for .NET Developer Guide NuGet Package Manager Console Install-Package AWSSDK -Version 1.5.1.0 The NuGet website provides a page for every package that is available through NuGet such as the AWSSDK and AWS.Extensions assemblies. The page for each package includes a sample command line for installing the package using the console. Each page also includes a list of the previous versions of the package that are available through NuGet.
AWS SDK for .NET Developer Guide Managing ASP.NET Session State with Amazon DynamoDB AWS SDK for .NET Tutorials and Examples The following tutorials and examples demonstrate how to use the AWS SDK for .NET to access 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). Contents • Managing ASP.NET Session State with Amazon DynamoDB (p.
AWS SDK for .NET Developer Guide Create the ASP.NET_SessionState Table The AWS SDK for .NET includes AWS.SessionProvider.dll, which contains an ASP.NET session state provider. Also included is the AmazonDynamoDBSessionProviderSample sample, which demonstrates how to use Amazon DynamoDB as a session-state provider. For more information about using Session State with ASP.NET applications, go to the MSDN documentation. Create the ASP.
AWS SDK for .NET Developer Guide Configure the Session State Provider Note If you decide not to create the table beforehand, the session state provider will create the table for you during its initialization. See the web.config options below for a list of attributes that act as configuration parameters for the session-state table. If the provider creates the table, it will use these parameters. Configure the Session State Provider To configure an ASP.
AWS SDK for .NET Developer Guide Security Considerations AWSSecretKey Secret key to use. This can be set either in the providers section or in the appSettings section. We recommend not using this setting. Instead, specify credentials by using AWSProfileName to specify a profile. AWSProfileName The profile name that is associated with the credentials that you want to use. For more information, see Configuring Your AWS SDK for .NET Application (p. 8). Region Required string attribute.
AWS SDK for .NET Developer Guide Tutorial: Creating Amazon EC2 Instances "Resource" : "arn:aws:dynamodb:us-east-1::table/ASP.NET_SessionState" } ] } Tutorial: Creating Amazon EC2 Instances with the AWS SDK for .NET You can access the features of Amazon EC2 using the AWS SDK for .NET. For example, you can create, start, and terminate 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 .
AWS SDK for .NET Developer Guide Create a Security Group Create a Security Group Using the SDK for .NET Create a security group, which acts as a virtual firewall that controls the network traffic for one or more EC2 instances. By default, Amazon EC2 associates your instances with a security group that allows no inbound traffic. You can create a security group that allows your EC2 instances to accept certain traffic.
AWS SDK for .NET Developer Guide Create a Security Group { Name = "vpc-id", Values = new List() {vpcID} }; var dsgRequest = new DescribeSecurityGroupsRequest(); dsgRequest.Filters.Add(vpcFilter); var dsgResponse = ec2Client.DescribeSecurityGroups(dsgRequest); List mySGs = dsgResponse.SecurityGroups; foreach (SecurityGroup item in mySGs) { Console.WriteLine("Existing security group: " + item.GroupId); if (item.
AWS SDK for .NET Developer Guide Create a Security Group The CreateSecurityGroup method returns a CreateSecurityGroupResponse object. You can get the ID of the new security group from the response and then use DescribeSecurityGroups with the security group ID to get the SecurityGroup object for the security group.
AWS SDK for .NET Developer Guide Create a Key Pair FromPort and ToPort The beginning and end of the port range. This example specifies a single port, 3389, which is used to communicate with Windows over RDP. IpRanges The IP addresses or address ranges, in CIDR notation. For convenience, this example uses 0.0.0.0/0, which authorizes network traffic from all IP addresses.This is acceptable for a short time in a test environment, but it's unsafe in a production environment. 2.
AWS SDK for .NET Developer Guide Launch an EC2 Instance foreach (KeyPairInfo item in myKeyPairs) { Console.WriteLine("Existing key pair: " + item.KeyName); if (item.KeyName == keyPairName) { myKeyPair = item; } } Creating a Key Pair and Saving the Private Key The example in this section follows from the example in the previous section. If the key pair doesn't already exist, create it. Be sure to save the private key now, because you can't retrieve it later.
AWS SDK for .NET Developer Guide Launch an EC2 Instance • Checking the State of Your Instance (p. 46) • Connecting to Your Running Instance (p. 46) Launching an EC2 Instance You launch an instance in either EC2-Classic or EC2-VPC. For more information about EC2-Classic and EC2-VPC, see Supported Platforms in the Amazon Elastic Compute Cloud User Guide for Microsoft Windows. To launch an EC2 instance in EC2-Classic 1. Create and initialize a RunInstancesRequest object.
AWS SDK for .NET Developer Guide Launch an EC2 Instance { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "iam:PassRole", "iam:ListInstanceProfiles", "ec2:*" ], "Resource": "*" }] } For example, the following snippet instantiates and configures an IamInstanceProfileSpecification object for an IAM role named winapp-instance-role-1. var instanceProfile = new IamInstanceProfile(); instanceProfile.Id = "winapp-instance-role-1"; instanceProfile.
AWS SDK for .NET Developer Guide Launch an EC2 Instance { DeviceIndex = 0, SubnetId = subnetID, Groups = groups, AssociatePublicIpAddress = true }; List enis = new List() {eni}; DeviceIndex The index of the device on the instance for the network interface attachment. SubnetId The ID of the subnet to launch the instance into. GroupIds One or more security groups. For more information, see Create a Security Group (p. 37).
AWS SDK for .NET Developer Guide Launch an EC2 Instance 3. (Optional) To launch the instance with an IAM role (p. 47), specify an IAM instance profile in the RunInstancesRequest. Note that an IAM user can't launch an instance with an IAM role without the permissions granted by the following policy.
AWS SDK for .NET Developer Guide Terminate an EC2 Instance Checking the State of Your Instance Use the following procedure to get the current state of your instance. Initially, your instance is in the pending state. You can connect to your instance after it enters the running state. To check the state of your instance 1. Create and configure a DescribeInstancesRequest object.
AWS SDK for .NET Developer Guide Tutorial: Using an IAM Role var deleteRequest = new TerminateInstancesRequest() { InstanceIds = instanceIds }; var deleteResponse = ec2Client.TerminateInstances(deleteRequest); foreach (InstanceStateChange item in deleteResponse.TerminatingInstances) { Console.WriteLine(); Console.WriteLine("Terminated instance: " + item.InstanceId); Console.WriteLine("Instance state: " + item.CurrentState.
AWS SDK for .NET Developer Guide Create a Sample that Retrieves an Object from Amazon S3 The following walkthrough uses a sample program that retrieves an object from Amazon S3 using the AWS credentials that you've configured. Next, we create an IAM role to provide the AWS credentials. Finally, we launch an instance with an IAM role that provides the AWS credentials to the sample program running on the instance. Walkthrough • Create a Sample that Retrieves an Object from Amazon S3 (p.
AWS SDK for .NET Developer Guide Create an IAM Role responseBody = reader.ReadToEnd(); } } using (FileStream s = new FileStream( "s3Object.txt", FileMode.Create )) using (StreamWriter writer = new StreamWriter(s)) { writer.WriteLine( responseBody ); } } catch (AmazonS3Exception s3Exception) { Console.WriteLine(s3Exception.Message, s3Exception.InnerException); } } // main } // class } // namespace To test the sample code 1. 2. Open Visual Studio and create an AWS Console project.
AWS SDK for .NET Developer Guide Run the Sample Program on the EC2 Instance • To launch an EC2 instance using the console, follow the directions in Launching a Windows Instance in the Amazon Elastic Compute Cloud User Guide for Microsoft Windows. When you reach the Review Instance Launch page, click Edit instance details. In IAM role, specify the IAM role that you created previously. Complete the procedure as directed.
AWS SDK for .NET Developer Guide Tutorial: Amazon EC2 Spot Instances a. Click Download Remote Desktop File. When your browser prompts you to do so, save the .rdp file. When you have finished, you can click Close to dismiss the Connect To Your Instance dialog box. b. Navigate to your downloads directory, right-click the .rdp file, and then select Edit. On the Local Resources tab, under Local devices and resources, click More.
AWS SDK for .NET Developer Guide Prerequisites Spot Instances perform exactly like other Amazon EC2 instances while running, and like other Amazon EC2 instances, Spot Instances can be terminated when you no longer need them. If you terminate your instance, you pay for any partial hour used (as you would for On-Demand or Reserved Instances). However, if your instance is terminated by Amazon EC2 because the Spot Price goes above your bid, you will not be charged for any partial hour of usage.
AWS SDK for .NET Developer Guide Step 2: Setting Up a Security Group 5 CreateSecurityGroupRequest securityGroupRequest = new CreateSecurity GroupRequest(); securityGroupRequest.GroupName = "GettingStartedGroup"; securityGroupRequest.GroupDescription = "Getting Started Security Group"; ec2.CreateSecurityGroup(securityGroupRequest); 10 } catch (AmazonEC2Exception ae) { if (string.Equals(ae.ErrorCode, "InvalidGroup.Duplicate", StringCompar ison.InvariantCulture)) { 15 Console.WriteLine(ae.
AWS SDK for .NET Developer Guide Step 3: Submitting Your Spot Request Comparison.InvariantCulture)) { 10 Console.WriteLine(ae.Message); } else { throw; 15 } } You can also create the security group using the AWS Toolkit for Visual Studio. Go to the toolkit documentation for more information. Step 3: Submitting Your Spot Request To submit a Spot Request, you first need to determine the instance type, the Amazon Machine Image (AMI), and the maximum bid price you want to use.
AWS SDK for .NET Developer Guide Step 4: Determining the State of Your Spot Request To request a Spot Instance, you simply need to build your request with the parameters we have specified so far. We start by creating a RequestSpotInstanceRequest object. The request object requires the number of instances you want to start (2) and the bid price ($0.03). Additionally, you need to set the LaunchSpecification for the request, which includes the instance type, AMI ID, and security group you want to use.
AWS SDK for .NET Developer Guide Step 4: Determining the State of Your Spot Request describeRequest.SpotInstanceRequestId.Add(spotInstanceRequest.SpotIn stanceRequestId); 10 } 1 // Create a variable that will track whether there are any // requests still in the open state. bool anyOpen; 5 // Create a list to store any instances that were activated.
AWS SDK for .NET Developer Guide Step 5: Cleaning up Your Spot Requests and Instances 50 if (anyOpen) { // Wait for the requests to go active. Console.WriteLine("Requests still in open state, will retry in 60 seconds."); 55 Thread.Sleep((int)TimeSpan.FromMinutes(1).TotalMilliseconds); } } while (anyOpen); If you just ran the code up to this point, your Spot Instance Request would complete—or possibly fail with an error.
AWS SDK for .NET Developer Guide Conclusion this array to the InstanceId member of a TerminateInstancesRequest object, then passing that object to the ec2.TerminateInstances API. 1 if (instanceIds.Count > 0) { try 5 { TerminateInstancesRequest terminateRequest = new TerminateInstances Request(); terminateRequest.InstanceId = instanceIds; ec2.TerminateInstances(terminateRequest); } catch (AmazonEC2Exception e) { Console.WriteLine("Error terminating instances"); Console.WriteLine("Caught Exception: " + e.
AWS SDK for .NET Developer Guide Create an Amazon SQS Client 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 Amazon SQS Queue URLs To create an Amazon SQS queue 1. Create and initialize a CreateQueueRequest instance. Provide the name of your queue and specify a visibility timeout for your queue messages, as follows: CreateQueueRequest createQueueRequest = new CreateQueueRequest(); createQueueRequest.QueueName = "MySQSQueue"; createQueueRequest.DefaultVisibilityTimeout = 10; Your queue name must only be composed of alphanumeric characters, hyphens, and underscores.
AWS SDK for .NET Developer Guide Receive a Message from 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. Create and initialize a SendMessageRequest instance.
AWS SDK for .NET Developer Guide Delete a Message from an Amazon SQS Queue 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 Related Resources 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. 60).
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets 4. Monitor the change to verify that it is complete. The example is a simple console application that shows how to use the SDK for .NET to implement this procedure for a basic record set. To run this example 1. In the Visual Studio File menu, click New and then click Project. 2. 3. Select the AWS Empty Project template and specify the project's name and location.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets ResourceRecords = new List {new ResourceRecord { Value = "192.0.2.235"}} }; Change change1 = new Change() { ResourceRecordSet = recordSet, Action = ChangeAction.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets The profile must grant permissions for the actions that you intend to use—the Amazon Route 53 actions in this case. Attempts to call actions that lack permissions will fail. For more information, see Configuring AWS Credentials (p. 9). The example uses the default constructor to create the object, which implicitly specifies the application's default profile and region.
AWS SDK for .NET Developer Guide Updating Amazon Route 53 Resource Record Sets • Action – The action to be taken for this resource record set: CREATE, DELETE, or UPSERT. For more information on these actions, see Elements. This example creates a new resource record set in the hosted zone, so Action is set to CREATE. 3. Create a ChangeBatch object and set its Changes property to a list of the Change objects that you created in the previous step.
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: November 8, 2013 Change Description Release Date Support for .NET SDK version 2 This guide has been modified to support the latest version November 8, 2013 of the AWS SDK for .NET. New topic This topic tracks recent changes to the AWS SDK for .NET September 9, 2013 Developer Guide.