page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
Azure Managed Instance for Apache Cassandra provides automated deployment and scaling operations for managed open-source Apache Cassandra datacenters. |
azure-cassandra-mi-python-getting-started |
Azure Managed Instance for Apache Cassandra provides automated deployment and scaling operations for managed open-source Apache Cassandra datacenters. It accelerates hybrid scenarios and reduces ongoing maintenance.
This quick start demonstrates how to connect to a Cassandra Managed instance cluster with Python. You'll then build a user profile console app, output as shown in the following image, with sample data.
- Before you can run this sample, you must have the following perquisites:
- An Azure Managed Instance for Apache Cassandra cluster. Check out our Quickstart guide here.
- Networking access from this application to your Azure Managed Instance for Apache Cassandra cluster (the service only deploys private IP addresses injected into a Virtual network).
- A version of Python that supports the Cassandra driver version. For example, cassandra-driver==3.20.2 supports only Python versions 2.7, 3.4, 3.5, 3.6 and 3.7.
- Git.
- Python Driver - Note: Cassandra driver version 3.20.2 is the latest Python driver that supports the v4 wire protocol for open source Apache Cassandra by default. If using a later version, please explicitly set
protocol_version
to 4 (see sample).
-
Clone this repository using
git clone https://github.com/Azure-Samples/Azure-Samples/azure-cassandra-mi-python-v4-getting-started.git
. -
Replace
<FILLME>
inusername
,password
,contactPoint
anddatacenter-name
with the appropriate values inconfig.py
. ThecontactPoint
should be one of the private I.P. seed nodes in your cluster.'username': '<FILLME>', 'password': '<FILLME>', 'contactPoint': '<FILLME>', 'datacenter-name': '<FILLME>', 'port':9042
-
Run the below in a terminal to install required python packages.
pip install cassandra-driver pip install prettytable pip install requests pip install pyopenssl
-
Run
python pyquickstart.py
in a terminal to execute it.
The code included in this sample is intended to get you quickly started with a python program that connects to Azure Managed Instance for Apache Cassandra.