Serverless Graph Analytics
By default, for users on paid plans, Neo4j Graph Intelligence comes with Serverless Graph Analytics enabled. For trial users, Graph Intelligence uses a plugin that runs on the instance. Data Scientists and Analysts can run a selection of algorithms in Bloom. Data Scientists have access to the full library of algorithms via Fabric Notebooks.
This allows the graph algorithms to be run from Bloom. Graph Intelligence provides a serverless graph analytics service that runs on demand. Enabling Serverless Graph Analytics disables the plugin and the functionality available within Bloom.
Enabling Serverless Graph Analytics
Trial users who have upgraded to paid plans, or users who selected the 'Plugin' during Graph Dataset creation, need to use the Aura Console to enable Graph Analytics:
-
Open the Aura Console.
-
Select Instances from the sidebar.
-
Select the instance with the name of the graph dataset you created in Microsoft Fabric. Your organization may have multiple instances; make sure to select the correct instance name.
-
Select Configure.
-
Select Serverless (recommended), this disables the plugin used by Bloom.
Obtaining API and Connection Details for Fabric Notebooks
In order to connect, you need to obtain API credentials and connection information for the instance in Aura that is available in Microsoft Fabric. To do this:
-
Select your user icon top right of Aura Console.
-
Select Account Settings.
-
Select API Keys.
-
Generate an API key (client ID & client secret) and store both in Azure Key Vault.
-
To obtain connection details return to the Instance menu and select Connect and Drivers.
-
Select the default Python driver and copy the connection information — you will use the Neo4j URI and username directly in the notebook, and store the password as a secret in Azure Key Vault.
URI = "neo4j+s://d4df0777.databases.neo4j.io"
AUTH = ("<Username>", "<Password>")
Running algorithms through Query
You can use Cypher® to run Graph Data Science (GDS) algorithms directly in the Query experience. The basic workflow follows the same lifecycle described in the GDS manual.
-
Check what’s available
List the algorithms and utilities in your environment:
CALL gds.list() YIELD name, type, description RETURN name, type, description ORDER BY name; -
Project a graph
Algorithms run on in-memory graphs. Use
gds.graph.project(native) orgds.graph.project.cypher(Cypher projection) to create one:CALL gds.graph.project('myGraph', ['Person', 'Company'], { WORKS_FOR: {}, KNOWS: {} }); -
Run an algorithm
Most algorithms support four modes:
-
Stream: Returns results to the client (exploration).
-
Write: Writes results back as node/relationship properties.
-
Mutate: Adds results as properties on the in-memory graph only.
-
Stats: Returns summary of statistics.
Example: PageRank in stream modeCALL gds.pageRank.stream('myGraph', { maxIterations: 20, dampingFactor: 0.85 }) YIELD nodeId, score RETURN gds.util.asNode(nodeId).name AS name, score ORDER BY score DESC LIMIT 20;
-
-
Clean up
When you no longer need the in-memory graph:
CALL gds.graph.drop('myGraph');
Quick start Fabric Notebook
#provide the api credentials to the sessions object
from graphdatascience.session import AuraAPICredentials, GdsSessions
# The API Key is available from Aura Console - refer to instructions above
client_id = notebookutils.credentials.getSecret("https://<name>.vault.azure.net/", "<AURA_CLIENT_ID_KEY>")
client_secret = notebookutils.credentials.getSecret("https://<name>.vault.azure.net/", "<AURA_CLIENT_SECRET_KEY>")
neo4j_password = notebookutils.credentials.getSecret("https://<name>.vault.azure.net/", "<NEO4J_PASSWORD_KEY>")
api_credentials = AuraAPICredentials(client_id,client_secret
# If your account is a member of several project, you must also specify the project ID to use
#project_id=os.environ.get("PROJECT_ID", None),
)
sessions = GdsSessions(api_credentials=api_credentials)
#Estimate the amount of memory required
from graphdatascience.session import AlgorithmCategory, SessionMemory
# Explicitly define the size of the session
memory = SessionMemory.m_8GB
# Estimate the memory needed for the GDS session based on nodes and relationships and the algorithm
memory = sessions.estimate(
node_count=20,
relationship_count=50,
algorithm_categories=[AlgorithmCategory.CENTRALITY, AlgorithmCategory.NODE_EMBEDDING],
)
print(memory)
#Create the session
from datetime import timedelta
from graphdatascience.session import DbmsConnectionInfo
# Provide the connection details specified above
db_connection = DbmsConnectionInfo(
uri = "neo4j+s://<your-instance-id>.databases.neo4j.io",
auth = ("neo4j", neo4j_password)
)
# Create a GDS session!
gds = sessions.get_or_create(
# give your session a representative name
session_name="customers_and_orders",
memory=SessionMemory.m_4GB,
db_connection=db_connection,
#specify how long you would like the session to live for
ttl=timedelta(minutes=4),
)
##note if the sessions expire you cannot reuse the same name
##You can view the sessions in the Aura Console, select Graph Analytics from the sidebar
#Alternatively you can run
from pandas import DataFrame
gds_sessions = sessions.list()
# for better visualization
DataFrame(gds_sessions)
Refer to the Graph Data Science Client → Aura Graph Analytics for AuraDB which details how to project a graph into a session, run algorithms, and write back to the database.