48
© 2012 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. AWSマイスターシリーズ Reloaded AWS SDK for .NET 2012.10.29 ソリューションアーキテクト 渡邉 源太 玉川 憲

AWSマイスターシリーズReloaded -AWS SDK for .NET-

Embed Size (px)

DESCRIPTION

ほぼ週間AWSマイスターシリーズのAWS SDK for .NETの回の資料です。

Citation preview

Page 1: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWSマイスターシリーズ Reloaded

AWS SDK for .NET

2012.10.29

ソリューションアーキテクト

渡邉 源太 玉川 憲

Page 2: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

Agenda

AWS SDK オーバービュー

AWS SDK for .NET

AWS Toolkit for Visual Studio

まとめ

Page 3: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS SDK オーバービュー

Page 4: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWSのサービス操作と言えば

AWS Management Console

AWSコマンドラインツール

Page 5: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

これらの裏側では・・・

各サービスの各操作にAPIが定義されている

AWSでは・・・

• 人間がGUIまたはCUI越しに叩く

• プログラミングしてそれを自動化・簡易化・カスタマイズ

• 人間が手でやらなくてはいけない事をプログラミングして自動化できる、これがSDKで簡単に実現可能

AWSの実は最も優れた一面

Page 6: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS SDKとは

AWSのサービスをプログラムで操作できるSDK • さまざまな言語で

• AWS SDK for Java

• AWS SDK for .NET

• AWS SDK for Ruby

• AWS SDK for PHP

• AWS SDK for Python (boto)

• AWS SDK for Android

• AWS SDK for iOS

• 有志の方による実装(ActionScript)も

• 通信は原則HTTPS

Page 7: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

動作イメージ

起動、停止

Put,Get

DB起動

バックアップ

情報取得

REST

SOAP AWS SDK

認証情報

Page 8: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

認証情報

AWSの認証キー(アクセスキー、シークレットキ-)

• AWSログイン後、[アカウント]>[セキュリティ証明書]の画面から取得

• IAMユーザーは、ManagementConsoleのIAMタブから取得

Page 9: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

操作の種類

例:EC2 • インスタンス起動・・・RunInstances

• リブート・・・ RebootInstances

• IPアドレス付与・・AllocateAddress

• などさまざまな操作が、プログラムから実行可能

• http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/Welcome.html

• SDKによってサポートする操作が異なる

Page 10: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS SDK for .NET

Page 11: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS SDK for .NET

AWS SDK for .NET

Amazon提供のAWS開発用.NET SDK

http://aws.amazon.com/sdkfornet/

環境:.NET Framework 3.5以降

最新版 1.5.5

C#およびVisual Basicをサポート

Page 12: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

前提条件

.NET framework 3.5以上

Microsoft Visual Studio 2008(Standard 以上)、 Microsoft

Visual Studio 2010(Professional 以上)またはVisual

Studio 2012 (Professional 以上)

Microsoft Visual Studio 2012 Express

Microsoft Visual C# 2008/2012 Express Edition

Microsoft Visual Web Developer 2008/2012 Express

Edition

12

Page 13: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

操作可能サービス

Amazon CloudFront Amazon Simple Queue Service

Amazon CloudWatch Amazon Simple Storage Service

Amazon CloudSearch Amazon Simple Workflow Service

Amazon DynamoDB Amazon SimpleDB

Amazon ElastiCache Amazon Virtual Private Cloud

Amazon Elastic Compute Cloud Auto Scaling

Amazon Elastic MapReduce AWS CloudFormation

Amazon Glacier AWS Elastic Beanstalk

Amazon Relational Database Service AWS Import/Export

Amazon Route 53 AWS Identity and Access Management

Amazon Simple Email Service AWS Storage Gateway

Amazon Simple Notification Service Elastic Load Balancing

Page 14: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS SDK for .NETに含まれるもの

AWS .NETライブラリ

コードサンプル

ドキュメンテーション

AWS Toolkit for Visual Studio

Page 15: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

インストール方法

以下のページの右上隅にある「Download AWS .NET SDK」ボタンをクリック • http://aws.amazon.com/jp/sdkfornet/

ファイルを保存するかどうかをたずねるメッセージがブラウザに表示されたら、ローカルのディスクに保存

保存したインストーラを開いてインストールプロセスを開始

Page 16: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

App.configの設定

App.configにアクセスキーとシークレットキーを以下のように設定

<configuration>

<appSettings>

<add key="AWSAccessKey" value="[ENTER YOUR ACCESS

KEY ID HERE]"/>

<add key="AWSSecretKey" value="[ENTER YOUR SECRET

ACCESS KEY HERE]"/>

</appSettings>

</configuration>

Page 17: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

サンプル:EC2インスタンス起動

// EC2操作用のクライアント

AmazonEC2 ec2 = new AmazonEC2Client(); // 立ち上げたいインスタンス情報の作成

RunInstancesRequest runInstanceRequest = new RunInstancesRequest{

ImageId = "ami-xxx",

MaxCount = 1,

MinCount = 1,

KeyName = “YourKeyName",

SecurityGroup = { “yourSecurityGroup” },

InstanceType = InstanceType.M1Small

}; // インスタンスの起動

ec2.RunInstances(runInstanceRequest);

Page 18: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

サンプル:S3バケットの作成

// S3操作用クライアント AmazonS3 s3 = new AmazonS3Client(); // bucket情報の設定 PutBucketRequest putBucketRequest = new PutBucketRequest { BucketName = "Mybucket", BucketRegion = S3Region.APN1 }; // bucket作成

s3.PutBucket(putBucketRequest);

Page 19: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

サンプル:S3オブジェクトのアップロード

// S3操作用クライアント AmazonS3 s3 = new AmazonS3Client(); //オブジェクト情報の設定 PutObjectRequest putObjectRequest = new PutObjectRequest { BucketName = "Mybucket", Key = "Item1", FilePath = "contents.txt" }; // PutObjectResponse response = s3.PutObject(putObjectRequest);

Page 20: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

サンプル:RDSインスタンスの作成

// RDS操作用クライアント AmazonRDS rds = new AmazonRDSClient(); // DB instance情報の設定 CreateDBInstanceRequest createDBInstanceRequest = new CreateDBInstanceRequest { AllocatedStorage = 30, DBInstanceClass = "db.m1.small", DBInstanceIdentifier = "sqlserver", Engine = "sqlserver-ex", MasterUsername = "sa", MasterUserPassword = "password" }; // DB instance作成 rds.CreateDBInstance(createDBInstanceRequest);

Page 21: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

リージョンを選択する

リージョンの選択

デフォルトはどれもus-east

ServiceURLで指定

• AmazonEC2Config config = new AmazonEC2Config { ServiceURL = “https://ec2.ap-norhteast-1.amazonaws.com” };

サービス毎のエンドポイントは下記URL参照

• http://docs.amazonwebservices.com/general/latest/gr/rande.html

Page 22: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

有効な利用方法

利用方法(運用面)

決まったインスタンスを起動するバッチ

固定ディスク(EBS)のスナップショットを定期取得

S3からデータを定期的に取得

S3上のデータを監視して、無くなったら通知

利用方法(アプリから)

アプリのバックエンドとして、DynamoDBを使う

メール送信のためにSNSを使う

データ保存のためにS3を使う

Page 23: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

サンプル:Petboard

ASP.NETによるサンプルアプリ

• http://aws.amazon.com/articles/3592?_encoding=UTF8&jiveRedirect=1

SimpleDBおよびS3を活用

• メンバー情報およびペットのデータをSimpleDBに格納

• 画像イメージをS3に格納し、ASP.NETからアップロード可能

Page 24: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Toolkit for Visual Studio

Page 25: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Toolkit for Visual Studio

Visual Studioを使用してのサービスの管理が可能

AWS SDK for .NETによるアプリケーション開発に対応

AWS Elastic Beanstalk/AWS CloudFormationによる.NETアプリケーションのデプロイに対応

Page 26: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

前提条件

.NET framework 3.5 Service Pack 1 以上

Microsoft Visual Studio 2008(Standard 以上)、 Microsoft Visual Studio 2010(Professional 以上)またはVisual Studio 2012 (Professional 以上)

AWS Elastic Beanstalk/AWS CloudFormation デプロイメントの場合:

• Web 配置ツール 1.0 以上が必要です。Microsoft Visual Studio 2010 には、Web 配置ツール 1.0 がプレインストールされています。

26

Page 27: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

機能

アカウント管理

AWS Explorer

• 各種サービスの情報表示/操作

EC2 コンソール

• EC2のコントロールパネル

AWS CloudFormation

AWS Elastic Beanstalk

• デプロイ、デバッグ、環境構築

Page 28: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

アカウント管理

Access Key IDとSecret Access keyを登録

複数のアカウント登録が可能

Page 29: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer

各サービス情報の一覧 • Amazon CloudFront

• Amazon DynamoDB

• Amazon EC2

• Amazon RDS

• Amazon S3

• Amazon SimpleDB

• Amazon SNS

• Amazon SQS

• AWS CloudFormation

• AWS Elastic Beanstalk

• AWS IAM

ツリーから情報にアクセス

Page 30: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

リージョンとアカウント

メニューからリージョンとアカウントの切り替え

Page 31: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon CloudFront

Distributionの新規作成

既存Distributionの一覧

Distributionの内容表示・変更

Distributionの有効化/無効化

Page 32: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon DynamoDB

テーブルの追加/削除

キャパシティの変更

テーブル内アイテム一覧

属性追加

スキャンの実行

Page 33: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon RDS

DBの作成/削除

• SQL Server Databaseの作成

既存RDSの一覧

DBへの接続

• Visual Studioのサーバーエクスプローラーからの接続が可能

Page 34: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon S3

Bucketの作成/削除、権限設定

オブジェクトの一覧

オブジェクトの削除、権限設定、Pre-signed URLの生成

オブジェクトアップロード

Page 35: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon SimpleDB

ドメインの作成/削除

クエリーの実行と結果の編集

Attributeの追加

CSVへのエクスポート

Page 36: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon SNS

トピックの一覧表示

トピックの作成

サブスクリプションの作成/削除

ポリシーの編集

Page 37: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Explorer – Amazon SQS

キューの作成、削除

キューのプロパティの管理

キューへのメッセージ送信

キュー内の一覧

Page 38: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

EC2 コンソール

AMI管理

• 検索、削除、AMIからの起動

インスタンス管理

• 右クリックから状態変更、AMI作成、EBSの操作

• インスタンスタイプおよびセキュリティグループによるフィルター

Page 39: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

EC2コンソール

EBS管理

• EBS作成、削除、スナップショット作成

• スナップショット一覧、削除

Page 40: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

EC2コンソール

セキュリティグループ管理

• セキュリティグループ作成、削除

• アクセス条件の追加、削除

Page 41: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

アプリケーションのデプロイ

Visual Studioから直接AWSへアプリケーションのデプロイが可能

• AWS CloudFormationまたはAWS ElasticBeanstalk

Page 42: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS CloudFormation

AWS CloudFormationテンプレートによるアプリケーションのデプロイ

Single Instance TemplateまたはLoad Balanced Templateから選択

.NET Frameworkのバージョンが指定可能

Application URLからアプリにアクセス可能

42

Page 43: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Elastic Beanstalk

AWS Elastic Beanstalkによるデプロイ

複数のバージョンのデプロイが可能

Elastic Beanstalkの環境情報表示と編集

各環境に属するAutoScaling,ELB,EC2の一覧表示

Page 44: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Elastic Beanstalk

各種詳細設定

• AutoScalingポリシー

• トリガー条件、インスタンス起動設定、ゾーン設定

• .NET Framework設定

• ELB設定

• 通知設定

Page 45: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

AWS Toolkit for Visual Studioまとめ

AWS Toolkit for Visual StudioはWindows開発者のためのプロのツール

• ほとんどのサービスがVisual Studioから操作可能

• サービスの設定および確認に利用

AWS SDK for .NETによる.NET開発に対応

開発したアプリはCloudFormationまたはElastic Beanstalk

によりAWSに直接デプロイ

Page 46: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

まとめ

Page 47: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

SDKを使うことで

• 運用管理での煩雑な手間をコーディングで楽にすることが可能

• どのサービスでも同じような使い勝手で利用可能

• 実際のサービス開発のお供に

• S3

• SNS/SQS/SWF

• DynamoDB

AWSはコーディングする方の力を最大限に引き出すインフラ

• HAPPY CODING!!

Page 48: AWSマイスターシリーズReloaded -AWS SDK for .NET-

© 2012 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.

ご参加ありがとう ございました