More Related Content
Similar to AWSマイスターシリーズReloaded -AWS SDK for .NET- (20)
More from Amazon Web Services Japan (20)
AWSマイスターシリーズReloaded -AWS SDK for .NET-
- 1. AWSマイスターシリーズ
Reloaded
AWS SDK for .NET
2012.10.29
ソリューションアーキテクト
渡邉 源太 玉川 憲
© 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.
- 2. Agenda
AWS SDK オーバービュー
AWS SDK for .NET
AWS Toolkit for Visual Studio
まとめ
© 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.
- 3. AWS SDK オーバービュー
© 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.
- 4. AWSのサービス操作と言えば
AWS Management Console
AWSコマンドラインツール
© 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.
- 5. これらの裏側では・・・
各サービスの各操作にAPIが定義されている
AWSでは・・・
• 人間がGUIまたはCUI越しに叩く
• プログラミングしてそれを自動化・簡易化・カスタ
マイズ
• 人間が手でやらなくてはいけない事をプログラミングして自
動化できる、これがSDKで簡単に実現可能
AWSの実は最も優れた一面
© 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.
- 6. 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
© 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.
- 7. 動作イメージ
起動、停止
Put,Get
REST
AWS SDK
SOAP
DB起動
バックアップ
認証情報
情報取得
© 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.
- 8. 認証情報
AWSの認証キー(アクセスキー、シークレットキ-)
• AWSログイン後、[アカウント]>[セキュリティ証明書]の画面
から取得
• IAMユーザーは、ManagementConsoleのIAMタブから取得
© 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.
- 9. 操作の種類
例:EC2
• インスタンス起動・・・RunInstances
• リブート・・・ RebootInstances
• IPアドレス付与・・AllocateAddress
• などさまざまな操作が、プログラムから実行可能
• http://docs.amazonwebservices.com/AWSEC2/latest/APIR
eference/Welcome.html
• SDKによってサポートする操作が異なる
© 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.
- 10. 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.
- 11. 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をサポート
© 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.
- 12. 前提条件
.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
© 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.
- 13. 操作可能サービス
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
© 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.
- 14. AWS SDK for .NETに含まれるもの
AWS .NETライブラリ
コードサンプル
ドキュメンテーション
AWS Toolkit for Visual Studio
© 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.
- 15. インストール方法
以下のページの右上隅にある
「Download AWS .NET SDK」ボタン
をクリック
• http://aws.amazon.com/jp/sdkfornet/
ファイルを保存するかどうかをたずねる
メッセージがブラウザに表示されたら、
ローカルのディスクに保存
保存したインストーラを開いてインス
トールプロセスを開始
© 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.
- 16. 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>
© 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.
- 17. サンプル: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);
© 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.
- 18. サンプル:S3バケットの作成
// S3操作用クライアント
AmazonS3 s3 = new AmazonS3Client();
// bucket情報の設定
PutBucketRequest putBucketRequest = new PutBucketRequest
{
BucketName = "Mybucket",
BucketRegion = S3Region.APN1
};
// bucket作成
s3.PutBucket(putBucketRequest);
© 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.
- 19. サンプル:S3オブジェクトのアップロード
// S3操作用クライアント
AmazonS3 s3 = new AmazonS3Client();
//オブジェクト情報の設定
PutObjectRequest putObjectRequest = new PutObjectRequest
{
BucketName = "Mybucket",
Key = "Item1",
FilePath = "contents.txt"
};
//
PutObjectResponse response = s3.PutObject(putObjectRequest);
© 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.
- 20. サンプル: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);
© 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.
- 21. リージョンを選択する
リージョンの選択
デフォルトはどれも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
© 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.
- 22. 有効な利用方法
利用方法(運用面)
決まったインスタンスを起動するバッチ
固定ディスク(EBS)のスナップショットを定期取得
S3からデータを定期的に取得
S3上のデータを監視して、無くなったら通知
利用方法(アプリから)
アプリのバックエンドとして、DynamoDBを使う
メール送信のためにSNSを使う
データ保存のためにS3を使う
© 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.
- 23. サンプル:Petboard
ASP.NETによるサンプルア
プリ
• http://aws.amazon.com/art
icles/3592?_encoding=UTF
8&jiveRedirect=1
SimpleDBおよびS3を活用
• メンバー情報およびペットの
データをSimpleDBに格納
• 画像イメージをS3に格納し、
ASP.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.
- 24. AWS Toolkit for Visual Studio
© 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.
- 25. AWS Toolkit for Visual Studio
Visual Studioを使用してのサービスの管理が可能
AWS SDK for .NETによるアプリケーション開発に対応
AWS Elastic Beanstalk/AWS CloudFormationによ
る.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.
- 26. 前提条件
.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
© 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.
- 27. 機能
アカウント管理
AWS Explorer
• 各種サービスの情報表示/操作
EC2 コンソール
• EC2のコントロールパネル
AWS CloudFormation
AWS Elastic Beanstalk
• デプロイ、デバッグ、環境構築
© 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.
- 28. アカウント管理
Access Key IDとSecret Access keyを登録
複数のアカウント登録が可能
© 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.
- 29. 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
ツリーから情報にアクセス
© 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.
- 31. AWS Explorer – Amazon CloudFront
Distributionの新規作成
既存Distributionの一覧
Distributionの内容表示・変更
Distributionの有効化/無効化
© 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.
- 32. AWS Explorer – Amazon DynamoDB
テーブルの追加/削除
キャパシティの変更
テーブル内アイテム一覧
属性追加
スキャンの実行
© 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.
- 33. AWS Explorer – Amazon RDS
DBの作成/削除
• SQL Server Databaseの作成
既存RDSの一覧
DBへの接続
• Visual Studioのサーバーエクスプロー
ラーからの接続が可能
© 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.
- 34. AWS Explorer – Amazon S3
Bucketの作成/削除、権限設
定
オブジェクトの一覧
オブジェクトの削除、権限設
定、Pre-signed URLの生成
オブジェクトアップロード
© 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.
- 35. AWS Explorer – Amazon SimpleDB
ドメインの作成/削除
クエリーの実行と結果の編集
Attributeの追加
CSVへのエクスポート
© 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.
- 36. AWS Explorer – Amazon SNS
トピックの一覧表示
トピックの作成
サブスクリプションの作成/削除
ポリシーの編集
© 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.
- 37. AWS Explorer – Amazon SQS
キューの作成、削除
キューのプロパティの管理
キューへのメッセージ送信
キュー内の一覧
© 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.
- 38. EC2 コンソール
AMI管理
• 検索、削除、AMIからの起動
インスタンス管理
• 右クリックから状態変更、AMI作成、EBSの操作
• インスタンスタイプおよびセキュリティグループによるフィル
ター
© 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.
- 39. EC2コンソール
EBS管理
• EBS作成、削除、スナップショット作成
• スナップショット一覧、削除
© 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.
- 40. EC2コンソール
セキュリティグループ管理
• セキュリティグループ作成、削除
• アクセス条件の追加、削除
© 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.
- 41. アプリケーションのデプロイ
Visual Studioから直接AWSへアプリケーションのデプ
ロイが可能
• AWS CloudFormationまたはAWS ElasticBeanstalk
© 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.
- 42. AWS CloudFormation
AWS CloudFormationテン
プレートによるアプリケー
ションのデプロイ
Single Instance Template
またはLoad Balanced
Templateから選択
.NET Frameworkのバー
ジョンが指定可能
Application URLからアプリ
にアクセス可能
42
© 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.
- 43. AWS Elastic Beanstalk
AWS Elastic Beanstalk
によるデプロイ
複数のバージョンのデプ
ロイが可能
Elastic Beanstalkの環境
情報表示と編集
各環境に属する
AutoScaling,ELB,EC2の
一覧表示
© 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.
- 44. AWS Elastic Beanstalk
各種詳細設定
• AutoScalingポリシー
• トリガー条件、インスタ
ンス起動設定、ゾーン設
定
• .NET Framework設定
• ELB設定
• 通知設定
© 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.
- 45. AWS Toolkit for Visual Studioまとめ
AWS Toolkit for Visual StudioはWindows開発者のための
プロのツール
• ほとんどのサービスがVisual Studioから操作可能
• サービスの設定および確認に利用
AWS SDK for .NETによる.NET開発に対応
開発したアプリはCloudFormationまたはElastic Beanstalk
によりAWSに直接デプロイ
© 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.
- 46. まとめ
© 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.
- 47. SDKを使うことで
• 運用管理での煩雑な手間をコーディングで楽にすることが可能
• どのサービスでも同じような使い勝手で利用可能
• 実際のサービス開発のお供に
• S3
• SNS/SQS/SWF
• DynamoDB
AWSはコーディングする方の力を最大限に引き出すイ
ンフラ
• HAPPY CODING!!
© 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.
- 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.