DynamoDb无法将项添加到表中

时间:2017-09-06 11:31:20

标签: c# amazon-web-services lambda amazon-dynamodb

我正在努力从lambda函数写入DynamoDb数据库。下面的代码转到“In try”消息。我既没有“保存”也没有“失败”。哦,没有数据写入dynamodb表。有点期待,错误的密钥,错误的权限,任何真的。

nsProp是一个c#对象并且有数据, 表键是Site, 范围键是SignupDate。

提前致谢

var credentials = new BasicAWSCredentials(
            accessKey: accessKey,
            secretKey: secretKey);

        var config = new AmazonDynamoDBConfig
        {
            RegionEndpoint = RegionEndpoint.EUWest2           
        };

        Console.WriteLine("After config");
        AmazonDynamoDBClient newclient = new AmazonDynamoDBClient(credentials, config);
        var NewContext = new DynamoDBContext(client);

        try
        {
            Console.WriteLine("In try");

            PutItemResponse x = await newclient.PutItemAsync(
                tableName: tableName,

                item: new Dictionary<string, AttributeValue>
                {
                        {"Site", new AttributeValue {S = nsProp.Site}},
                        {"SignupDate", new AttributeValue {S = nsProp.SignupDate}},
                        {"Email", new AttributeValue {S = nsProp.Email}}
                }
            );
            Console.WriteLine(x);
            //await context.SaveAsync<NewsletterSignupProp>(nsProp);

            Console.WriteLine("Save");
            return "Save";
        }
        catch (Exception ex)
        {
            Console.WriteLine("Fail" + ex.Message);
            return "Fail";
        }

0 个答案:

没有答案