如何在 .NET 中以编程方式启动 Amazon EC2 实例 [英] How to start an Amazon EC2 instance programmatically in .NET
问题描述
我一直试图在 C# 中启动 EC2 实例,但没有成功.
I have been attempting to start an instance of EC2 in C# without luck.
当传入一个实例 id 来启动实例时,我收到一个错误,即无法找到该实例,尽管我传入了一个从对象属性中获得的实例 ID.
When passing in an instance id to start the instance I get an error that the instance cannot be found despite that I am passing in an instance ID that I have obtained from the object property.
如果您对此有任何提示或指示,我将不胜感激.
I would be most grateful for any tips or pointers with this.
推荐答案
亚马逊付出巨大努力将其 AWS Cloud .Net SDK 集成到 VS2008 &VS 2010
Amazon made huge efforts to integrate its AWS Cloud .Net SDK To VS2008 & VS 2010
- 1 - 下载并安装 AWS SDK msi
- 2 - 创建一个 AWS 控制台项目,输入您的凭证
(可从您的 AWS 控制台在右上角的登录名菜单下获得) - 3 - 添加以下代码(见下图).
- 4 - 大功告成.这是非常简单的.
您可以通过刷新 AWS 控制台屏幕来检查程序启动/停止成功.
AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client();
//Start Your Instance
ec2.StartInstances(new StartInstancesRequest().WithInstanceId("i-00000000"));
//Stop it
ec2.StopInstances(new StopInstancesRequest().WithInstanceId("i-00000000"));
您只需将i-00000000"替换为您的实例 ID(在您的 AWS 管理控制台中可用)
You just need to replace "i-00000000" by your instance Id (available in your AWS Management Console)
希望这可以帮助那些在谷歌上搜索这个问题并在这个问题上磕磕绊绊的人(就像我自己那样)快速开始.
通过这些向导执行这些简单的步骤将使您免于头痛.
Hope this helps those googling this and stumbling upon this question (as I did myself) start off quickly.
Following these simple steps via these wizards will spare you considerable headaches.
这篇关于如何在 .NET 中以编程方式启动 Amazon EC2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!