如何在代码中更改 AWS SDK 区域?
How to change AWS SDK region in code?
有必要定义
<add key="AWSRegion" value="us-east-1"/>
App.config 中的应用程序设置以指定要使用的区域。
我需要以编程方式更改它
var creds = new BasicAWSCredentials(key, token);
using (var routes = AWSClientFactory.CreateAmazonRoute53Client(creds)){}
如何在代码中指定区域?
最佳做法是使用更可配置的版本(即从 web.config/app.config
配置的端点)。对于EC2客户端,可以通过以下方式实现:
var region = RegionEndpoint.GetBySystemName("ap-northeast-1");
var awsEC2Client = new AmazonEC2Client(region);
出于其他原因,您可以从 here
指定
资源Link:
- How to set the EndPoint / Region for the C# .NET SDK : EC2Client?
- How to start an Amazon EC2 instance programmatically in .NET
有必要定义
<add key="AWSRegion" value="us-east-1"/>
App.config 中的应用程序设置以指定要使用的区域。
我需要以编程方式更改它
var creds = new BasicAWSCredentials(key, token);
using (var routes = AWSClientFactory.CreateAmazonRoute53Client(creds)){}
如何在代码中指定区域?
最佳做法是使用更可配置的版本(即从 web.config/app.config
配置的端点)。对于EC2客户端,可以通过以下方式实现:
var region = RegionEndpoint.GetBySystemName("ap-northeast-1"); var awsEC2Client = new AmazonEC2Client(region);
出于其他原因,您可以从 here
指定资源Link:
- How to set the EndPoint / Region for the C# .NET SDK : EC2Client?
- How to start an Amazon EC2 instance programmatically in .NET