Help Center/
FunctionGraph/
User Guide (Kuala Lumpur Region)/
FAQs/
External Resource Access FAQs/
How Does a Function Access Redis?
Updated on 2023-07-06 GMT+08:00
How Does a Function Access Redis?
Perform the following operations:
- Check whether the Redis instance is deployed in a VPC.
- If the Redis instance is deployed in a VPC, configure the same VPC and subnet as the Redis instance for the function by referring to Configuring VPC Access.
- If the Redis instance is built on a public network, obtain its public IP address.
- Compile code for connecting a function to the Redis instance.
FunctionGraph has integrated third-party library redis-py in its Python 2.7 and Python 3.6 runtimes. Therefore, you do not need to download any other Redis libraries.
# -*- coding:utf-8 -*- import redis def handler (event, context): r = redis.StrictRedis(host="host_ip",password="passwd",port=6379) print(str(r.get("hostname"))) return "^_^"
- If the function fails to access to the Redis instance on a public network, perform the following operations:
- Modify the redis.conf file to allow access from any IP addresses.
- Set a password for accessing the Redis instance in the redis.conf file.
- Disable the firewall.
- If the function needs to access DCS APIs, create an agency and grant required permissions.
- If the function fails to access to the Redis instance on a public network, perform the following operations:
Parent topic: External Resource Access FAQs
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot