我正在使用aws sdk for .net,在emr集群中创建一个pig活动并在管道中调用,
try
{
var profileName = ConfigurationManager.AppSettings["AWS_PROFILE_NAME"];
var accessKey = ConfigurationManager.AppSettings["AWS_ACCESS_KEY"];
var secretKey = ConfigurationManager.AppSettings["AWS_SECRET_KEY"];
Amazon.Util.ProfileManager.RegisterProfile(profileName, accessKey, secretKey);
using (_dataPipelineClient = new AmazonDataPipelineClient(accessKey, secretKey, Amazon.RegionEndpoint.USEast1))
{
//proccesing code ...
}
}
catch (Exception e)
{
Logger.Error("ReportScheduler -> Error ocurred.", e);
throw new Exception("ReportScheduler -> Error ocurred.", e);
}
在我的本地服务器中,一切运行都没有问题。但是在托管中它抛出了这个例外:
AmazonClientException
CryptProtectData失败。
Amazon.Runtime.Internal.Settings.UserCrypto in Encrypt at line 94:0
System.String Encrypt(System.String)
Amazon.Runtime.Internal.Settings.SettingsCollection+ObjectSettings in WriteToJson at line 94:0
Void WriteToJson(ThirdParty.Json.LitJson.JsonWriter)
Amazon.Runtime.Internal.Settings.SettingsCollection in Persist at line 62:0
Void Persist(System.IO.StreamWriter)
Amazon.Runtime.Internal.Settings.PersistenceManager in saveSettingsType at line 93:0
Void saveSettingsType(System.String, Amazon.Runtime.Internal.Settings.SettingsCollection)
Amazon.Util.ProfileManager in RegisterProfile at line 115:0
Void RegisterProfile(System.String, System.String, System.String)
有人能给我一些想法,关于问题可能在哪里。
感谢。
答案 0 :(得分:1)
我遇到了同样的问题,对我来说有用的是使用基本的AWS凭证而不是使用商店凭证。
public static AmazonS3Client GetAwsS3Client(string accessKey, string secretKey)
{
var credentials = new BasicAWSCredentials(accessKey, secretKey);
return new AmazonS3Client(credentials, Amazon.RegionEndpoint.USEast1);
}