page_type | languages | name | description | products | |||
---|---|---|---|---|---|---|---|
sample |
|
Quickstart: Use Azure Cache for Redis in Python |
Learn how to incorporate Azure Cache for Redis into a Python app. |
|
This sample show you how to incorporate Azure Cache for Redis into a Python app. See the accompanying article on the documentation site for details, including best practices and how to create the sample code from scratch.
- Azure subscription - create one for free
- Python 3
- For macOS or Linux, download from python.org.
- For Windows 11, use the Windows Store.
Redis-py is a Python interface to Azure Cache for Redis. Use the Python packages tool, pip
, to install the redis-py
package from a command prompt.
The following example used pip3
for Python 3 to install redis-py
on Windows 11 from an Administrator command prompt.
Download the sample code to your development PC.
Change directories to the folder containing this sample.
Edit the PythonApplication1.py source. Replace <Your Host Name>
and <Your Access Key>
with the values from your Azure Cache for Redis instance. Your host name is of the form <DNS name>.redis.cache.windows.net.
Run PythonApplication1.py with Python.
Important
For Azure Cache for Redis version 3.0 or higher, TLS/SSL certificate check is enforced. ssl_ca_certs must be explicitly set when connecting to Azure Cache for Redis. For RedHat Linux, ssl_ca_certs are in the /etc/pki/tls/certs/ca-bundle.crt certificate module.