31
© 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

Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 1: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

© 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

Page 2: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 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

Page 3: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

AWS Tools for the .NET Community

• AWS SDK for .NET

• AWS Tools for Windows PowerShell

• AWS Toolkit for Visual Studio

• AWS Elastic Beanstalk Container

Page 4: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 5: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Application Architecture

CloudShotz

S3 Bucket

DynamoDB Table

{user123, image456}

Page 6: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

How DynamoDB Works

• Data is stored in Tables

• Tables do not have a fixed schema

• Tables have provisioned throughput

Page 7: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

DynamoDB Keys

UserId ImageId S3Bucket S3Key

123 456 My-images Images/456

Hash Key Range Key Attributes

Key

Page 8: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

DynamoDB Provisioned Throughput

Ima

ge

: W

ikim

edia

Com

mo

ns

Page 9: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Throttling

Consumed Capacity

0

1

2

3

4

5

6

7

Throttled Requests

0

100

200

300

400

500

600

Page 10: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

DynamoDB and the .NET SDK

• Low-level DynamoDB API – 1:1 API Mapping

• Document-Based API – Key-value Dictionary

• Object-Persistence API – Annotated Classes

Page 11: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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);

Page 12: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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);

Page 13: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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);

Page 14: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Amazon S3

• Unlimited Internet storage

• Keys grouped by bucket

• Objects are URL addressable

Page 15: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

AWS Elastic Beanstalk

• Easy deployment management

• Creates all necessary AWS resources

• You retain full control

• Deploy .NET applications from Visual Studio

Page 16: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

IAM Roles

my-s3-bucket

s3:GetObject

s3:PutObject

ImageMetadata

dynamodb:GetItem

Dynamodb:PutItem

Action Resource

Page 17: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 18: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

DynamoDB Table

Page 19: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

Queue

DynamoDB Table

Page 20: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

Image Resizer Svc

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

Queue

DynamoDB Table

Worker Reads from queue

Page 21: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

Image Resizer Svc

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

Queue

DynamoDB Table

Worker gets image metadata

from DynamoDB

Page 22: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 23: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 24: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

Image Resizer Svc

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

Queue

DynamoDB Table

Worker updates image metadata

In DynamoDB

Page 25: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Adding an Image Processing Worker

Image Resizer Svc

CloudShotz

Elastic Beanstalk

Environment

S3 Bucket

Queue

DynamoDB Table

Worker removes message from

queue

Page 26: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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

Page 27: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

SDK Install Layout

Page 28: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Visual Studio Project Setup

Page 29: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Credential Management

• Do not embed access credentials

• Web identity federation – Supports Facebook, Google, and Amazon

• Token Vending Machine

Page 30: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

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)

Page 31: Building Scalable Windows and .NET Apps on AWS (TLS302) | AWS re:Invent 2013

Please give us your feedback on this

presentation

As a thank you, we will select prize

winners daily for completed surveys!

TLS302