Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!View all the Fabric Data Days sessions on demand. View schedule
Modern learning platforms generate massive volumes of highly relational data, rich, valuable, and often underutilized. Moodle, as one of the most widely deployed LMS platforms, exposes a deep and complex data architecture with hundreds of interlinked tables governing users, courses, enrolments, logs, activities, and grades.
This article explains how Microsoft Fabric integrates with Moodle LMS REST API to create a scalable and reliable learning analytics ecosystem. We will walk through API integration, ingestion, lakehouse storage, Spark optimization, and automated pipelines: the foundation required to operationalize LMS analytics at an enterprise level.
Understanding Learning Data Architecture
Moodle operates on MySQL and ships with 400+ core and modular tables. This architecture provides incredible flexibility but requires careful modeling for analytics. For analytics-focused workloads, the foundation typically begins with the Users, Courses, and Enrolments tables. These three entities anchor most LMS metrics: learner activity, course uptake, engagement, and progression.
A Quick Glimpse Inside the Internal Database
Why Integrate Moodle with Microsoft Fabric?
Organizations frequently struggle to operationalize LMS data for:
Fabric solves this by:
The result is a modern, maintainable LMS analytics platform with end-to-end automation built in.
Now we examine the backend of an online learning platform, Moodle.
Step 1: Setting Up LMS REST API
The first requirement is enabling programmatic access to Moodle:
1. Configure a Custom Web Service:
Navigate to:
Site Administration → Server → Web Services → External Services
Create a custom service (e.g., myservice) and bind required REST functions:
2. Generate an Authentication Token:
Under Manage Tokens, generate a token mapped to the custom service.
This token functions as your service identity, allowing Fabric to authenticate API calls in unattended pipelines.
3. Validate Capabilities:
Ensure the token user has read-only permissions on:
Following the principle of least privilege is critical for data governance and compliance.
Step 2: Extracting LMS Data Using Python in Fabric Notebooks
With API access configured, we can use Python (Requests + Pandas) inside Fabric notebooks to call Moodle REST endpoints.
Each call includes:
Python Example: Fetching Courses & Enrolments
import requests
import pandas as pd
# Moodle API info
moodle_url = ""
token = ""
# --- COURSES TABLE ---
params_courses = {
"wstoken": token,
"wsfunction": "core_course_get_courses",
"moodlewsrestformat": "json"
}
response_courses = requests.post(moodle_url, data=params_courses)
courses = response_courses.json()
df_courses = pd.DataFrame(courses)
print("Courses fetched:", len(df_courses))
display(df_courses.head())
# --- ENROLMENTS TABLE ---
params_enrol = {
"wstoken": token,
"wsfunction": "core_enrol_get_enrolled_users",
"moodlewsrestformat": "json",
"courseid": 2
}
response_enrol = requests.post(moodle_url, data=params_enrol)
enrolments = response_enrol.json()
df_enrol = pd.DataFrame(enrolments)
print("Enrolments fetched:", len(df_enrol))
display(df_enrol.head())
The code above provides clean JSON transformed into Pandas DataFrames, making it an ideal first step for structured ingestion.
Production Security Note: Use Azure Key Vault
Tokens and API keys must never be hard-coded.
Store tokens in Azure Key Vault and access them securely in notebooks.
Key Vault supports:
Always create the Key Vault resource before consumption in Fabric.
Step 3: Persisting Extracted Data to Fabric Raw Zone
Once extracted, the first landing area is the Raw Data Zone inside Fabric Lakehouse.
Saving CSVs to Raw Zone:
import os
output_path = "/lakehouse/default/Files/raw/"
os.makedirs(output_path, exist_ok=True)
df_courses.to_csv(output_path + "moodle_courses.csv", index=False)
df_enrol.to_csv(output_path + "moodle_enrolments.csv", index=False)
print("All CSVs saved in Lakehouse folder:", output_path)
The Raw Zone provides:
Step 4: Scaling with Apache Spark
Spark becomes essential as LMS data grows.
Loading CSVs into Spark DataFrames:
courses_spark = spark.read.format("csv").option("header","true").load("Files/raw/moodle_courses.csv")
enrol_spark = spark.read.format("csv").option("header","true").load("Files/raw/moodle_enrolments.csv")
Spark enables distributed processing, schema inference, and massive parallel transformations, which are ideal for LMS workloads.
Step 5: Optimizing Storage Using Parquet & Delta
Parquet Format
Delta Lake
Save as Parquet
courses_spark.write.mode("overwrite").parquet("Files/moodle_courses_parquet")
enrol_spark.write.mode("overwrite").parquet("Files/moodle_enrolments_parquet")
Save as Delta
courses_spark.write.format("delta").mode("overwrite").saveAsTable("moodle_courses_delta")
enrol_spark.write.format("delta").mode("overwrite").saveAsTable("moodle_enrolments_delta")
The code above creates a robust, governed LMS data lakehouse.
Step 6: Automating the End-to-End Pipeline with Fabric Data Pipelines
Fabric Pipelines orchestrate the entire workflow from API extraction through Notebooks to Power BI auto-refresh. Pipelines are scheduled daily, weekly, and hourly depending on your SLA.
Integrated monitoring provides:
Validation in Lakehouse Explorer
After the automated load completes, we verify:
Fabric Lakehouse Explorer provides a clean view of your Moodle datasets, now ready for BI, ML, and advanced analytics.
This architecture delivers a fully secure and automated pipeline driven by LMS REST APIs, enabling structured ingestion into the Fabric Lakehouse, scalable processing through Apache Spark, and optimized storage using Parquet and Delta formats, all culminating in seamless analytics powered by Power BI.
You can expand the pipeline to include gradebook analytics, activity tracking, completion predictions, learning path optimization, cohort analysis, and personalized recommendations, unlocking deeper insights into the learning ecosystem.
When Moodle meets Microsoft Fabric, your LMS data transforms from operational records into strategic insights!
For a complete end-to-end demonstration, watch my video here:
Transforming LMS Data into Insights with Microsoft Fabric (Fabric Data Days Edition)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.