Upload
amazon-web-services
View
109
Download
2
Tags:
Embed Size (px)
DESCRIPTION
The AWS SDK for .NET and the AWS Toolkit for Visual Studio help developers build scalable apps on AWS services. Learn how to use these tools to define app data in Amazon DynamoDB and access it through a simple object persistence framework. We demonstrate deploying a web app to a customized, auto-scaled AWS Elastic Beanstalk environment. Finally, using the new version of the AWS SDK for .NET, you learn how to access your AWS data from apps targeting the Windows Store and Windows Phone platforms.
Citation preview
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
Building Scalable Windows and .NET Apps
on AWS
Norm Johanson & Jim Flanagan / AWS Developer Resources
November 15, 2013
What We’ll Learn
• Using Amazon DynamoDB with .NET
• Deploying to AWS Elastic Beanstalk
• Customizing Our Beanstalk Environments
• Using Our SDK for Windows Store Applications
AWS Tools for the .NET Community
• AWS SDK for .NET
• AWS Tools for Windows PowerShell
• AWS Toolkit for Visual Studio
• AWS Elastic Beanstalk Container
AWS Tools for the .NET Community
• AWS SDK for .NET – Version 2 – Supports WinRT and Windows Phone 8
• AWS Toolkit for Visual Studio – Supports Visual Studio 2010, 2012, and 2013
• AWS Elastic Beanstalk Container – Container customization
– Instance Profiles
– Single Instance Environments
Application Architecture
CloudShotz
S3 Bucket
DynamoDB Table
{user123, image456}
How DynamoDB Works
• Data is stored in Tables
• Tables do not have a fixed schema
• Tables have provisioned throughput
DynamoDB Keys
UserId ImageId S3Bucket S3Key
123 456 My-images Images/456
Hash Key Range Key Attributes
Key
DynamoDB Provisioned Throughput
Ima
ge
: W
ikim
edia
Com
mo
ns
Throttling
Consumed Capacity
0
1
2
3
4
5
6
7
Throttled Requests
0
100
200
300
400
500
600
DynamoDB and the .NET SDK
• Low-level DynamoDB API – 1:1 API Mapping
• Document-Based API – Key-value Dictionary
• Object-Persistence API – Annotated Classes
Low Level API PutItemRequest putRequest = new PutItemRequest() {
TableName = "ImageMetadata",
Item = new Dictionary<string, AttributeValue> {
{"UserId", new AttributeValue {S = userId}},
{"ImageId", new AttributeValue {S = Guid.NewGuid().ToString()}},
{"Caption", new AttributeValue {S = "Cool Photo"}},
{"UploadDate", new AttributeValue {
S = DateTime.Now.ToString("yyyy-MM-dd\\THH:mm:ss.fff\\Z")}},
{"Bucket", new AttributeValue {S = bucketName}},
{"S3Key", new AttributeValue {S = s3Key}}
}
};
PutItemResponse putResponse = this.ddbClient.PutItem(putRequest);
Document Model API Table table = Table.LoadTable(this.ddbClient, "ImageMetadata");
Document document = new Document();
document["UserId"] = userId;
document["ImageId"] = Guid.NewGuid();
document["Caption"] = "Cool Photo";
document["UploadDate"] = DateTime.Now;
document["Bucket"] = bucketName;
document["S3Key"] = s3Key;
table.PutItem(document);
Object Persistence Model API ImageMetadata image = new ImageMetadata(DateTime.Now, userId);
image.Caption = "Cool Photo";
image.S3Bucket = bucketName;
image.S3Key = s3Key;
context.Save<ImageMetadata>(image);
Amazon S3
• Unlimited Internet storage
• Keys grouped by bucket
• Objects are URL addressable
AWS Elastic Beanstalk
• Easy deployment management
• Creates all necessary AWS resources
• You retain full control
• Deploy .NET applications from Visual Studio
IAM Roles
my-s3-bucket
✔
✔
s3:GetObject
s3:PutObject
ImageMetadata
✔
✔
dynamodb:GetItem
Dynamodb:PutItem
Action Resource
EC2 Instance Profiles
EC2 Instance
AWS SDK
Identity and
Access
Management
EC2
Instance
Profile
✖
✔
Web.config
Instance Profile
SDK looks in
multiple places
for credentials
Adding an Image Processing Worker
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
DynamoDB Table
Adding an Image Processing Worker
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker Reads from queue
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker gets image metadata
from DynamoDB
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker downloads full-size
image from S3 bucket
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker resizes image and
puts thumbnail in S3 bucket
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker updates image metadata
In DynamoDB
Adding an Image Processing Worker
Image Resizer Svc
CloudShotz
Elastic Beanstalk
Environment
S3 Bucket
Queue
DynamoDB Table
Worker removes message from
queue
Windows Store & Windows Phone
• New in version 2 of the SDK
• Asynchronous API only
• Service level support – Windows Phone has 11 services
– Window Store supports all services
• Separate assemblies for each platform
SDK Install Layout
Visual Studio Project Setup
Credential Management
• Do not embed access credentials
• Web identity federation – Supports Facebook, Google, and Amazon
• Token Vending Machine
What’s Next?
• Try out our SDK and Tools – AWS Website - http://aws.amazon.com/sdkfornet/
– Nuget - https://www.nuget.org/packages/awssdk
– Open Source at GitHub - https://github.com/aws/aws-sdk-net
• Let us know what you think – AWS Forums
– GitHub
– StackOverflow
• Follow our blog http://blogs.aws.amazon.com/net/ (Twitter: @awsfornet)
Please give us your feedback on this
presentation
As a thank you, we will select prize
winners daily for completed surveys!
TLS302