AWS SDK for .NETDeveloper GuideVersion v2.0.0
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 a
{ Console.WriteLine(" {0}", accessKey.Id); }}Get Group InformationThe following example displays information about an existing grou
} Console.WriteLine(" Users:"); foreach (var user in group.GetUsers()) { Console.WriteLine(" {0}", user.Name); }}Get
Console.WriteLine(" Policies:"); foreach (var policy in role.GetPolicies()) { Console.WriteLine(" {0}", policy.Name);
Console.WriteLine("Group 'DemoGroup' already exists.");}Create a RoleThe following example creates a new role and then confirms
var action = new ActionIdentifier("sts:AssumeRole"); var actions = new List<ActionIdentifier>(); actions.Add(action); var princip
}catch (NoSuchEntityException){ Console.WriteLine("Group 'DemoGroup' or " + "user 'DemoUser' does not exist.&qu
"Statement" : [ { "Sid" : "ListDeploymentsStatement", "Effect" : "Allow",
group.CreatePolicy(policyDoc, "ListDeploymentConfigsPolicy"); Console.WriteLine("Policies for group {0}:", group.Name); foreac
statements.Add(statement); var policy = new Policy { Id = "ListDeploymentConfigsPolicy", Version = "2012-10-17", Stat
"Version" : "2012-10-17", "Id" : "DemoEC2Permissions", "Statement" : [ { &quo
NoteAlthough using the appSettings element is still supported, we recommend that you moveto using the aws element instead, for example:<configurati
var iam = new IdentityManagementService();try{ var user = iam.GetUserByName("DemoUser"); var accessKey = user.CreateAccessKey(); Console.
// using Amazon.IdentityManagement;// using Amazon.IdentityManagement.Model; var client = new AmazonIdentityManagementServiceClient();var request = ne
Tutorial: Grant Access Using an IAM Role and theAWS SDK for .NETAll requests to AWS must be cryptographically signed using credentials issued by AWS.
namespace s3.amazon.com.docsamples.retrieveobject{ class S3Sample { static string bucketName = "bucket-name"; static string keyName
If the program fails, ensure that you are using credentials that provide you with access to the bucket.5. (Optional) Transfer the sample program to a
NoteAlternatively, connect using the Toolkit for Visual Studio (as described in Connecting to anAmazon EC2 Instance in the AWS Toolkit for Visual Stud
Amazon Route 53 Programming with the AWSSDK for .NETThe AWS SDK for .NET supports Amazon Route 53, which is a highly available and scalable DomainName
using System;using System.Collections.Generic;using System.Threading;using Amazon;using Amazon.Route53;using Amazon.Route53.Model;namespace Route53_Re
ChangeBatch = changeBatch }; ChangeResourceRecordSetsResponse recordsetResponse = route53Cli ent.ChangeResourceRecordSets(recordsetR
• CallerReference – (Required) An arbitrary user-defined string that serves as a request IDand can be used to retry failed requests.If you run this ap
Programming with the AWS SDKfor .NETThis section provides general information for developing software with the AWS SDK for .NET.For information about
2. Pass the ChangeResourceRecordSetsRequest object to the client object'sChangeResourceRecordSets method. It returns a ChangeResourceRecordSetsRe
• Specifying Server-Side Encryption with Customer-Provided Encryption KeysAmazon Simple Notification ServiceProgramming with the AWS SDK for .NETThe A
{ Console.WriteLine(" {0}", sub.SubscriptionArn); } } var attrs = client.GetTopicAttributes( new GetTopicAtt
if (topic.Attributes.Count > 0) { Console.WriteLine(" Attributes:"); foreach (var attr in topic.Attributes) {
• Creating and Using an Amazon SQS Queue (p. 121)Programming ModelsThe SDK for .NET provides two programming models for working with Amazon SQS.These
Resource APIsThe SDK for .NET provides the AWS Resource APIs for .NET for programming with Amazon SQS.Theseresource APIs provide a resource-level prog
Create an Amazon SQS ClientYou will need an Amazon SQS client in order to create and use an Amazon SQS queue. Before configuringyour client, you shoul
Create an Amazon SQS QueueYou can use the AWS SDK for .NET to programmatically create an Amazon SQS queue. Creating anAmazon SQS Queue is an administr
Send an Amazon SQS MessageYou can use the Amazon SDK for .NET to send a message to an Amazon SQS queue.ImportantDue to the distributed nature of the q
2. Pass the request object as a parameter to the ReceiveMessage method, as follows:ReceiveMessageResponse receiveMessageResponse = amazonSQSClient.
Another way to configure an application is to edit the appSettings element in the project's App.configor Web.config file.The following example sp
DeleteMessageResponse response = amazonSQSClient.DeleteMessage(deleteMessageRequest);Calling DeleteMessage unconditionally removes the message fro
Re-sourcesDescriptionServiceSeeAWSCloud-Form-a-tionPro-gram-ming (p.45)SeealsoAmazon.Cloud-Form-a-tion,Amazon.Cloud-Form-a-tion.Mod-el,andAmazon.Cloud
Re-sourcesDescriptionServiceSeeAmazon.CloudHSMandAmazon.CloudHSM.Mod-elSecure cryptographic key storage through hardwaresecurity modules (HSMs) in the
Re-sourcesDescriptionServiceSeeAmazonCog-nitoCre-den-tialsPro-viderandCach-ingAmazonCog-nitoIden-tityIDsSeealsoAmazon.Cog-nitoIden-tity,Amazon.Cog-nit
Re-sourcesDescriptionServiceSeeAmazon.Data-PipelineandAmazon.Data-Pipeline.Mod-elOrchestration for data-driven workflowsAWS Data PipelineSeeAmazon.Dir
Re-sourcesDescriptionServiceSeeDy-namoDBPro-gram-ming (p.46)andEn-hance-mentstotheDy-namoDBSDKSeealsoAmazon.Dy-namoD-Bv2,Amazon.Dy-namoD-Bv2.DataMod-e
Re-sourcesDescriptionServiceSee:• AmazonEC2Pro-gram-ming (p.68)• IAMRolesforAmazonEC2In-stances• Im-port-ingVMIm-agesandVolumeswithPower-ShellandC#See
Re-sourcesDescriptionServiceSeeUs-ingtheElast-iC-acheClusterCli-entfor.NETandUtil-iz-ingAmazonElast-iC-acheAutoDis-cov-eryin.NETThroughEn-yimSeealsoAm
Re-sourcesDescriptionServiceSeeCre-at-ingandDe-ploy-ingElast-icBean-stalkAp-plic-a-tionsin.NETUs-ingAWSToolkitforVisu-alStu-dioSeealsoAmazon.Elast-ic-
Re-sourcesDescriptionServiceSeeAmazon.Elast-ic-Load-Bal-an-cingandAmazon.Elast-ic-Load-Bal-an-cing.Mod-elDistribute incoming application traffic acros
IAM credentials are easier to revoke if they are compromised and you can apply a policy to each userthat restricts them to a specified set of resource
Re-sourcesDescriptionServiceSeeAmazonGla-ci-erPro-gram-ming (p.87)SeealsoAmazon.Gla-ci-er,Amazon.Gla-ci-er.Mod-el,andAmazon.Gla-ci-er.Trans-ferArchive
Re-sourcesDescriptionServiceAccess control and key managementAWS Identity and Access Management (IAM)Version v2.0.0137AWS SDK for .NET Developer Guide
Re-sourcesDescriptionServiceSee:• IAMPro-gram-ming (p.91)• Us-ingIAMUsers• IAMCre-den-tialRo-ta-tionSeealsoAmazon.Iden-tity-Man-age-mentandAmazon.Iden
Re-sourcesDescriptionServiceandAmazon.Se-cur-ity-Token.Mod-elSeeAmazon.Im-por-tEx-portandAmazon.Im-por-tEx-port.Mod-elTransferring data between the AW
Re-sourcesDescriptionServiceSeeAmazon.OpsWorksandAmazon.OpsWorks.Mod-elDevOps application management serviceAWS OpsWorksSeeAmazon.RDSandAmazon.RDS.Mod
Re-sourcesDescriptionServiceScalable storage in the cloudAmazon Simple Storage Service (Amazon S3)Version v2.0.0141AWS SDK for .NET Developer GuideAdd
Re-sourcesDescriptionServiceSee:• AmazonS3Pro-gram-ming (p.116)• TheThreeDif-fer-entAPIsforAmazonS3• AmazonS3Li-fe-cycleMan-age-ment• Work-ingwithAmaz
Re-sourcesDescriptionServiceS3• AmazonS3Trans-ferUtil-ityforWin-dowsStoreandWin-dowsPhoneSeealsoAmazon.S3,Amazon.S3.En-cryp-tion,Amazon.S3.IO,Amazon.S
Re-sourcesDescriptionServiceSeeSend-inganEmailThroughtheAmazonSESSMTPIn-ter-facewithC#andSend-inganEmailThroughAmazonSESSeealsoAmazon.Sim-pleE-mailand
Re-sourcesDescriptionServiceSeeAmazonSNSPro-gram-ming (p.117)SeealsoAmazon.Sim-pleN-o-ti-fic-a-tion-Ser-vice,Amazon.Sim-pleN-o-ti-fic-a-tion-Ser-vice.
Using a Credentials FileYou can also store profiles in a credentials file, which can also be used by the other AWS SDKS, theAWS CLI, and AWS Tools for
Re-sourcesDescriptionServiceSee:• AmazonSQSPro-gram-ming (p.119)• Sub-scrib-inganSQSQueuetoanSNSTop-ic• Us-ingAmazonSQSDeadLet-terQueuesSeealsoAmazon.
Re-sourcesDescriptionServiceSee:• Find-ingSnap-shots• De-let-ingSnap-shots• Up-dat-ingGate-wayBand-widthRateLim-its• Up-dat-ingGate-way-VTLBand-widthR
Re-sourcesDescriptionAreaSeeAmazon.AWS-Sup-portandAmazon.AWS-Sup-port.Mod-elProgrammatic access to AWS Support cases andTrusted Advisor featuresAWS Su
Additional ResourcesHome Page for AWS SDK for .NETFor more information about the AWS SDK for .NET, go to the home page for the SDK at http://aws.amazo
Document HistoryThe following table describes the important changes since the last release of the AWS SDK for .NETDeveloper Guide.Last documentation u
Release DateDescriptionChangeDecember 16, 2014The Programming with AWS Services (p. 41) section ofthe Table of Contents was reorganized to group topic
Specifying a ProfileProfiles are the preferred way to use credentials in an application running locally.You can store profilesin the SDK Store or in t
Although you can reference a profile programmatically by usingAmazon.Runtime.StoredProfileAWSCredentials, we recommend that you use the aws elementins
AmazonEC2Config config = new AmazonEC2Config();config.ServiceURL = "https://us-east-1.amazonaws.com";Amazon.Runtime.AWSCredentials credentia
<aws endpointDefinition="c:\config\endpoints.xml""/>Alternatively, you can set the AWSEndpointDefinition key in the <appSettin
AWS SDK for .NET: Developer GuideCopyright © 2015 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.The following are trademarks of
<logging logMetrics="true"/>Alternatively, set the AWSLogMetrics key in the <appSettings> section:<add key="AWSLogMetric
AWSConfigs.ResponseLogging = ResponseLoggingOption.OnError;Changes to this setting take effect immediately.AWS.DynamoDBContext.TableNamePrefixConfigur
To set Signature Version 4 signing for Amazon S3 in the .config file, the recommended approachis to set the useSignatureVersion4 attribute of the s3 e
• Allowed Elements (p. 19)• Elements Reference (p. 20)Declaring an AWS Settings SectionYou specify AWS settings in an App.config or Web.config file fr
toTable="string value" /> <map type="NameSpace.Class, Assembly" targetTable="string value&qu
• toTable — The to-table portion of the from-table to to-table mapping. (This attribute maps to theAmazon.Util.TableAlias.ToTable property in the AWS
</aws>...dynamoDBThe dynamoDB element represents a collection of settings for Amazon DynamoDB. This element caninclude the conversionSchema attr
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.Th
...<logging logTo="SystemDiagnostics" logResponses="OnError" logMetrics="true" logMetricsFormat="JSON"
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 prope
Table of ContentsAWS SDK for .NET Developer Guide ... 1Ho
...<s3 useSignatureVersion4="true" />...Amazon Web Services Asynchronous APIs for.NETTopics• Asynchronous API for .NET 4.5, Windows S
PutItemResponse PutItem( PutItemRequest putItemRequest)Asynchronous MethodIAsyncResult BeginPutItem( GetSessionTokenRequest getSessionTokenRequest,A
// // You will need to use your own bucket name below in order // to run this sample code. // PutObjectRequest request = new PutObjectRequest {
Callback with ClientThis example assumes that the following callback function has been defined.public static void CallbackWithClient(IAsyncResult asyn
PutObjectResponse response = state.Client.EndPutObject(asyncResult); Console.WriteLine("Finished PutObject. Elapsed time: {0}",
public DateTime Start { get { return startTime; } set { startTime = value; } } } class Program { public sta
catch (AmazonS3Exception s3Exception) { // // Code to process exception // } } public stat
request.Key = "Item2"; asyncResult = client.BeginPutObject(request, SimpleCallback, null); request.Key = "Item
• Updated names for classes and properties to follow .NET conventionsWhat's DifferentArchitectureThe AWS SDK for .NET uses a common runtime libra
TransferUtilityUploadRequest uploadRequest = new TransferUtilityUploadRequest() { BucketName = "my-bucket", Key = "test", FilePat
Amazon Simple Notification Service (Amazon SNS) ... 117Programming Models ...
As a result, many of the exception properties have changed; the XML property is no longer provided,for example.Amazon Redshift• The ClusterVersion.Nam
<configuration> <appSettings> <add key="AWSProfileName" value="profile_name"/> <add key="AWSRegio
AWS SDK for .NET Framework 4.5The version of the SDK for .NET compiled against .NET Framework 4.5 supports the same set of servicesas version 1 of SDK
• IO NamespaceAlso, the Windows Phone 8 version of the SDK does not support decryption of the Windows passwordusing the GetDecryptedPassword method.In
NuGet Package Manager ConsoleTo use NuGet from the Package Manager Console within Visual Studio:• Visual Studio 2010 – From the Tools menu, select Lib
Programming AWS Services withthe AWS SDK for .NETThe following concepts, tutorials, and examples demonstrate how to use the AWS SDK for .NET to workwi
CautionThe AWS Resource APIs for .NET are currently provided as a preview. This means that theseresource APIs may frequently change in response to cus
var response = client.CreateUser(request); Console.WriteLine("User Name = '{0}', ARN = '{1}'", response.User.User
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,
AWS CloudFormation Programming with theAWS SDK for .NETThe AWS SDK for .NET supports AWS CloudFormation, which creates and provision AWS infrastructur
AWS SDK for .NET DeveloperGuideThe AWS SDK for .NET is a single downloadable package that includes Visual Studio project templates,the AWS .NET librar
For related API reference information, see Amazon.CloudFormation andAmazon.CloudFormation.Model in the AWS SDK for .NET API Reference.Resource APIsThe
• Using Expressions with DynamoDB (p. 52)• JSON Support in Amazon DynamoDB (p. 63)• Managing ASP.NET Session State with Amazon DynamoDB (p. 65)Program
// "HASH" = hash key, "RANGE" = range key. KeyType = "HASH" }, new KeySchemaElement { Attribute
}} while (status != TableStatus.ACTIVE);In the preceding example, the target table to check is referenced through the AmazonDynamoDBClientclass&apos
DocumentThe document programming model provides an easier way to work with data in DynamoDB.This modelis specifically intended for accessing tables an
int id = item["Id"].AsInt();Or, you could simply perform an explicit cast here by using (int):int id = (int)item["Id"];For more in
context.Save(item);In the preceding example, the item is inserted through the DynamoDBContext class's Save method,which takes an initialized inst
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 a
"N": "1" }, "RelatedItems": { "NS": [ "341", "472", "649"
"S": "301 description" }, "BicycleType": { "S": "Road" }, "Brand": { "S
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 ch
} ] }, "ProductReviews": { "M": { "FiveStar": { "SS": [ "My daughter r
Get Multiple Items by Using Expressions and the Table'sPrimary KeyThe following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.Query
Get Multiple Items by Using Expressions and Other ItemAttributesThe following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.Scan methoda
foreach (KeyValuePair<string, AttributeValue> kvp in attrs) { Console.Write(kvp.Key + " = "); PrintValue(kvp.Value); }}// Wr
else if (value.SS.Count > 0) { Console.Write("{0}", string.Join("\n", value.SS.ToArray())); } // Otherwise, boolean val
// using Amazon.DynamoDBv2.Model;// Provides a sample item that can be added to a table.public static Dictionary<string, AttributeValue> CreateI
// using Amazon.DynamoDBv2;// using Amazon.DynamoDBv2.Model;var client = new AmazonDynamoDBClient();var request = new UpdateItemRequest{ TableName =
In the preceding example, the ExpressionAttributeNames property specifies the placeholder #titleto represent the Title attribute.The ExpressionAttribu
Console.WriteLine(jsonPrettyText);// Output:// {// "Name" : "Shadow",// "Type" : "Horse",// &quo
Additional ResourcesFor additional information and examples of programming JSON with DynamoDB with the SDK for .NET,see:• DynamoDB JSON Support• Amazo
Getting Started with the AWS SDKfor .NETTo get started with the AWS SDK for .NET, complete the following tasks:Tasks• Create an AWS Account and Creden
NoteFor now, you can leave the provisioned throughput settings at their minimum values of 1read capacity unit and 1 write capacity unit. This will all
/> </providers></sessionState>The profile represents the AWS credentials that are used to communicate with DynamoDB to storea
Security ConsiderationsOnce the DynamoDB table is created and the application is configured, sessions can be used as withany other session provider.As
The sample code in this tutorial is written in C#, but you can use the AWS SDK for .NET with any compatiblelanguage.The AWS SDK for .NET installs a se
Enumerating Your Security GroupsYou can enumerate your security groups and check whether a particular security group exists.To enumerate your security
To create a security group for EC2-ClassicCreate and initialize a CreateSecurityGroupRequest object. Assign a name and description to theGroupName and
Adding Rules to Your Security GroupUse the following procedure to add a rule to allow inbound traffic on TCP port 3389 (RDP). This enablesyou to conne
4. Pass the request object to the AuthorizeSecurityGroupIngress method, which returns anAuthorizeSecurityGroupIngressResponse object.var ingressRespon
This example saves the private key in the current directory, using the name of the key pair as the basefile name of the .pem file.if (myKeyPair == nul
SecurityGroupIds = groups};ImageIdThe ID of the AMI. For a list of public AMIs provided by Amazon, see Amazon Machine Images.InstanceTypeAn instan
The preferred approach for handling credentials is to create a profile for each set of credentials in theSDK Store.You can create and manage profiles
InstanceProfile = instanceProfile3. Launch the instances by passing the request object to the RunInstances method. Save the IDs ofthe instances, as yo
string amiID = "ami-e189c8d1";string keyPairName = "my-sample-key";var launchRequest = new RunInstancesRequest(){ ImageId = ami
var instanceProfile = new IamInstanceProfile();instanceProfile.Id = "winapp-instance-role-1";instanceProfile.Arn = "arn:aws:iam::4444-
List<Instance> runningInstances = statusResponse.DescribeInstancesResult.Re servation[0].Instance;foreach (Instance instance in runningInstances
Tutorial: Amazon EC2 Spot InstancesOverviewSpot Instances enable you to bid on unused Amazon EC2 capacity and run any instances that you acquirefor as
Step 1: Setting Up Your CredentialsTo begin using this code sample, you need to populate the App.config file with your AWS credentials,which identify
computer. If your connection to the Internet is mediated by a firewall or some other type of proxy, you willneed to determine the external IP address
three common strategies: bid to ensure cost is less than on-demand pricing; bid based on the value ofthe resulting computation; bid so as to acquire c
There are other options you can use to configure your Spot Requests.To learn more, seeRequestSpotInstances in the AWS SDK for .NET.Running this code w
foreach (SpotInstanceRequest spotInstanceRequest in de scribeResponse.DescribeSpotInstanceRequestsResult.SpotInstanceRequest)
To configure the .NET CLRTo ensure the best performance of your server-based applications on systems with multiple processorsor processor cores, we re
1 try { // Cancel requests. CancelSpotInstanceRequestsRequest cancelRequest = new CancelSpotInstan ceRequestsRequest(); 5
ConclusionCongratulations! You have just completed the getting started tutorial for developing Spot Instance softwarewith the AWS SDK for .NET.Amazon
Console.WriteLine(" Notifications:"); Console.WriteLine(" Topic: {0}", responseNotifications.VaultNotificationCon
job.StatusMessage); } } else { Console.WriteLine(" No jobs."); }}For additional examples, see:• Using the AWS SDK for .NE
Resource APIsThe SDK for .NET provides the AWS Resource APIs for .NET for programming with Amazon Glacier.These resource APIs provide a resource-level
foreach (var job in jobs) { Console.WriteLine(" For job ID: {0}", job.Id); Console.WriteLine("Archive ID: {0
Programming ModelsThe SDK for .NET provides two programming models for working with IAM. These programming modelsare known as the low-level model and
Console.WriteLine(" Access keys:"); foreach (var accessKey in responseAccessKeys.AccessKeyMetadata) { Console.WriteLine(" {0
Console.WriteLine(" {0}", accessKey.Id); }}For additional examples, see IAM Resource API Examples (p. 94).For related API reference
var user = iam.GetUserByName("DemoUser"); Console.WriteLine("For user {0}:", user.Name); Console.WriteLine(" In groups:
Commenti su questo manuale