Build a fully serverless weather streaming pipeline that fetches live weather data every 60 seconds from WeatherAPI, processes and flattens it, and streams it to Azure Event Hub, then stores it in Microsoft Fabric Eventhouse via EventStream for real-time querying using KQL.
This is ideal for real-time dashboards, anomaly detection, or downstream analytics.
Inspired by this youtube series.
WeatherAPI --> Azure Function (Timer Trigger) --> Azure Event Hub --> Microsoft Fabric EventStream --> Eventhouse (KQL DB) --> Power BI Dashboard
- Azure Subscription (I used a student account. If you don't have that, please use a free trial with a new account)
- WeatherAPI Key (https://www.weatherapi.com/). Sign up and obtain a login key (up to 1m API calls a month for free!)
- Visual Studio Code with Azure Functions extension installed
- Python 3.x
- Microsoft Fabric access (Again, feel free to use a free trial here)
- Power BI Desktop (latest version)
- On the azure website, create a resource group. I called
rg-WeatherStream
- Namespace:
weatherstreamingnamespace# This is the name I used, please use any acceptable name of your choice - Event Hub Name:
weatherstreameventhub# This is the name I used, please use any acceptable name of your choice
Create a Shared Access Policy under the Event Hub with:
- Name:
fabric-listen# This is the name I used, please use any acceptable name of your choice - Permissions: Listen only # 'Listen only' is all we need for this
- Name:
kv-weather-streaming-311# This is the name I used, please use any acceptable name of your choice - Add a secret:
weatherapikey# This is the name I used, please use any acceptable name of your choice - Value: Your WeatherAPI key
You can create this from the Azure Portal.
- Install the Azure Functions Extension
- Sign in to your Azure account
- Click Azure Icon → Workspace → Create Function Project
- Language:
Python - Trigger:
Timer Trigger - Function Name:
weatherapifunction - Schedule (CRON):
*/60 * * * * *(every 60 seconds) # Modify this according to your requirements
- Go to: Function App → Settings → Identity → Set
Status: On
- Role:
Azure Event Hubs Data Sender - Assigned to: Managed Identity of the Function App
- Role:
Key Vault Secrets User - Assigned to: Managed Identity of the Function App
azure.eventhub
azure.identity
azure.keyvault.secrets
requestsEdit function_app.py to:
- Fetch the WeatherAPI key securely from Key Vault
- Fetch current weather, air quality, forecast, and alerts
- Flatten the JSON
- Send the data to Event Hub
Full Python code is provided in the repository folder; Using
DefaultAzureCredential()for secure authentication to both services. Just copy the code across to start with. You can modify it to your needs after getting this running.
- In VS Code, right-click the workspace folder →
Deploy to Function App - Select your Function App
✅ Done! Your function is now running every 30 seconds and sending JSON data to Event Hub.
- Name:
weather-fabric-ws# This is the name I used, please use any acceptable name of your choice
- Go to workspace →
+ New→ Select Eventhouse - Name this appropriately.
- Go to workspace →
+ New→ Select EventStream - Add Source →
Event Hub- Paste Namespace and Event Hub name
- Authentication: Shared Access Key
- Use
fabric-listenshared access policy or the policy you've made before in Step 2 - Data Format:
JSON
- Click Destination Node →
+ Destination→ Select Eventhouse - Destination Name:
weather-target - Choose Eventhouse and KQL DB created earlier
- Table Name:
weather-table# This is the name I used, please use any acceptable name of your choice - Data Format:
JSON - Check "Activate ingestion after adding the data source"
- Save and Publish the stream
✅ Data is now flowing live into Microsoft Fabric!
- Go to Fabric → Workspace → Eventhouse → Table →
weather-table - Click
⋮(three dots) →Query with code - Run:
weather-table
| take 100or
weather-table
| count✅ You should see live data from WeatherAPI inside your KQL database.
- Download the
.pbixfile from this GitHub repository - Open it in Power BI Desktop
- Go to:
Table View→ Select a table → ClickEdit Query - Click
Advanced Editor - Change the following:
- Eventhouse URL
- KQL Database name
- Table name
- Confirm and apply changes
- Click
Refreshto load updated data
- Click
Publishand choose the workspace you created - The dashboard and semantic model will appear under your resource group
- Go to:
Eventhouse→New KQL Queryset - Name:
alerts - Source: Your Eventhouse database
['weather-table']
| where alerts != '[]' // filter for records where alert condition exists
| extend AlertValue = tostring(alerts) // extract alerts as a string
| summarize LastTriggered = max(EventProcessedUtcTime) by AlertValue
| join kind = leftanti (
['weather-table']
| where alerts != '[]'
| extend AlertValue = tostring(alerts)
| summarize LastTriggered = max(EventProcessedUtcTime) by AlertValue
| where LastTriggered < ago(4m)
) on AlertValueThis filters out any outdated alerts and gives you only currently active ones.
You've built a fully serverless, secure, and real-time data streaming pipeline from WeatherAPI → Azure Function → Event Hub → Fabric → KQL Database → Power BI.
This sets the foundation for building real-time dashboards, alerts, and analytics pipelines.