Yog*_*hNC 7 c# amazon-web-services
我们使用连接到AWS SNS服务的AWS SDK工具包在vs 2010中设计了WebService应用程序.
当我们直接从VS 2010开发工作室运行时,它非常有效,但是当我们将Web服务发布到本地IIS或专用的Web服务器时,它会失败并显示以下错误消息.
Amazon.Runtime.AmazonServiceException: Unable to find credentials
Exception 1 of 4:
System.ArgumentException: Path cannot be the empty string or all whitespace.
Parameter name: path
at System.IO.Directory.GetParent(String path)
at Amazon.Runtime.StoredProfileAWSCredentials.DetermineCredentialsFilePath(String profilesLocation)
at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation)
at Amazon.Runtime.EnvironmentAWSCredentials..ctor()
at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__1()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 2 of 4:
System.ArgumentException: Path cannot be the empty string or all whitespace.
Parameter name: path
at System.IO.Directory.GetParent(String path)
at Amazon.Runtime.StoredProfileAWSCredentials.DetermineCredentialsFilePath(String profilesLocation)
at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation)
at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__2()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 3 of 4:
System.InvalidOperationException: The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY were not set with AWS credentials.
at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor()
at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__3()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 4 of 4:
Amazon.Runtime.AmazonServiceException: Unable to reach credentials server
at Amazon.Runtime.InstanceProfileAWSCredentials.GetContents(Uri uri)
at Amazon.Runtime.InstanceProfileAWSCredentials.<GetAvailableRoles>d__0.MoveNext()
at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole()
at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__4()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
at Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient..ctor()
at CellicaAwsSnsService..ctor()
at Service..ctor()
Run Code Online (Sandbox Code Playgroud)
Yog*_*hNC 15
在可以从Web服务应用程序访问此路径的任何路径上创建凭证文件.C:\ awsfile\credentials但请记住不要给这个文件任何扩展名文件应包含以下数据.
[default]
aws_access_key_id=[your_access_key]
aws_secret_access_key=[your_secret_key]
Run Code Online (Sandbox Code Playgroud)
在此之后,您需要在Web.config文件中的appsetting标记中设置路径:
<appSettings>
<add key="AWSProfilesLocation" value="C:\awsfile\credentials" />
<add key="AWSRegion" value="us-east-1" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11934 次 |
| 最近记录: |