如何在NET Core的AWS开发工具包上设置凭证? [英] How to set credentials on AWS SDK on NET Core?

查看:121
本文介绍了如何在NET Core的AWS开发工具包上设置凭证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AWS SDK的新手,我正在尝试遵循AWS

I'm new to AWS SDK and I'm trying to follow the AWS documentation, but gives little to none on what exactly I need to setup.

官方文档告诉我将其添加到appsettings.json:

The official docs tell me to add this to the appsettings.json:

{
  "AWS": {
    "Profile": "local-test-profile",
    "Region": "us-west-2"
  }
}

然后创建客户端:

var options = Configuration.GetAWSOptions();
IAmazonS3 client = options.CreateServiceClient<IAmazonS3>();

这将引发异常,表明无法找到凭据.我在哪里放置Api ID和密钥?这是什么个人资料?

This causes an exception to be thrown saying it cannot find the credentials. Where do I put the Api ID and Key? What is this profile?

请记住,我对如何设置此设置没有任何偏好.我只是在尝试遵循.NET Core的官方文档,而它们的唯一示例不起作用.这些文档似乎暗示我应该对它们的许多术语和设置有先验知识,或者我要迁移现有的应用程序并且已经进行了所有设置.

Please, bear in mind I have no preferences on how to set this up. I'm just trying to follow the official documentation for .NET Core, and their only example doesn't work. The docs seem to imply I should have prior knowledge of many of their terms and settings or that I'm migrating an existing app and already have everything setup.

有人可以指出这个示例中缺少的内容只是为了使API正确连接到AWS吗?

Can someone please point me to what is missing from this example just to make the API correctly connect to AWS?

推荐答案

json文件为$"appsettings.{env.EnvironmentName} .json",因此应将其命名为appsettings.Development.json并设置环境变量

The json file is $"appsettings.{env.EnvironmentName}.json", so you should call it appsettings.Development.json and have the environment variable set.

您是否在AWS凭证文件中定义了本地测试配置文件"配置文件.

Did you define your"local-test-profile" profile in the AWS credentials file.

应位于C:\ Users \ {USERNAME} \.aws \ credentials

Should be in C:\Users\{USERNAME}\.aws\credentials

[local-test-profile]
aws_access_key_id = your_access_key_id
aws_secret_access_key = your_secret_access_key

如果您不想将其放置在默认位置,则可以设置"ProfilesLocation" json配置文件.

If you don't want it in the default location, you can set the 'ProfilesLocation' json config file.

这篇关于如何在NET Core的AWS开发工具包上设置凭证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆