无法仅在生产环境AWS S3 SDK中查找凭据例外

时间:2018-03-15 06:19:59

标签: c# asp.net amazon-web-services amazon-s3

我使用Amazon Web Services S3 SDK for .NET能够将图像上传到我的S3存储桶。该项目在localhost上运行良好,但是当我发布到我的生产环境时,我收到此错误:

Unable to find credentials<br><br>Exception 1 of 4:<br>
System.InvalidOperationException: The app.config/web.config files for 
the application did not contain credential information
2 of 4 Amazon.Runtime.AmazonClientException: Unable to find the 'default' profile in CredentialProfileStoreChain.
3 of 4 The environment variables AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN were not set with AWS credentials.
4 of 4 Unable to reach credentials server

这当然让我相信这是我web.config <appsettings>部分中存在的一个问题,我已按此设置:

  <appSettings file="..\..\AppSettingsSecrets.config">
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

我在AppSettingsSecrets.config文件中设置了我的密钥,如下所示:

<appSettings>
  <add key="AWSProfileName" value="MYPROFILENAME"/>
  <add key="AWSAccessKey" value="MYACCESSKEY"/>
  <add key="AWSSecretKey" value="MYSECRETKEY"/>
</appSettings>

但是因为它在我的测试环境中工作,所以我很困惑为什么我的生产环境不能使用这些密钥。你需要看到什么其他代码才能解决这个问题?我是在正确的轨道上吗?

看到这个人有同样的问题,但他是旧版SDK中的一个错误(他的解决方案是等待更新),所以没有帮助我不认为:AmazonServiceException: Unable to find credentials

0 个答案:

没有答案