如何在C#中使用Lambda的AWS Elasticache [英] How to use AWS Elasticache from Lambda in c#

查看:87
本文介绍了如何在C#中使用Lambda的AWS Elasticache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了所有内容,但无法找到上述所有内容的教程/示例/演练!我正在尝试使用C#编写Lambda函数,该函数使用了一些ElastiCache存储.我可以找到从C#访问ElastiCache的示例,但是我发现引用的每个库都无法在Lambda使用的.NetCore 1.0上运行!有没有人设法做到这一点?非常感谢.

I've searched and searched and have been unable to find a tutorial / example / walkthrough with all of the above! I am trying to write a Lambda function in C# which makes use of some ElastiCache storage. I can find examples of ElastiCache access from C#, but every Library I have found referenced will not operate with .NetCore 1.0, which is what Lambda uses! Has anyone managed to do this? Many thanks.

推荐答案

是的,有可能,而且您是对的,有关此主题的信息很少.关键是将您的Elasticache实例和Lambda函数托管在同一VPC中.从高层次上,您需要:

Yes, it is possible and you're right, the information on this subject is sparse. The key is to host your Elasticache instance and Lambda Function in the same VPC. From a high level you need to:

  1. 设置至少具有两个子网组,路由表和安全组的VPC.
  2. 创建一个指向第1步中创建的两个子网组的Elasticache子网组.
  3. 使用指向步骤2中创建的Elasticache子网组的实例创建您的Elasticache实例.
  4. 创建您的C#Lambda函数,并使用第3方库连接到Elasticache.对于Redis,我在.Net Core 1.0中成功使用了StackExchange.Redis 1.2.1.较新的版本不适用于.Net Core 1.0.
  5. 将您的Lambda与相同的VPC,子网和安全组相关联.
  6. 将Lambda函数与IAM角色相关联,该角色允许您执行Lambda并调用ec2:CreateNetworkInterface(我认为VPC调用需要它,但不确定).诸如AWSLambdaFullAccess和AWSLambdaVPCAccessExecutionRole之类的东西将起作用.
  7. 测试您的Lambda的连通性.

此博客文章具有更好的演练: http://fitsofury.blogspot.com/2018/02/aws-connect-to-elasticache-redis.html

This blog posting has a better walkthrough: http://fitsofury.blogspot.com/2018/02/aws-connect-to-elasticache-redis.html

这篇关于如何在C#中使用Lambda的AWS Elasticache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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