Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AliSafa
Advocate I
Advocate I

Live Stream Power BI

Hi Folks,

 

is it possible to create a Live Streaming Dataset reading Data from a SQL table? 
I could not find any source which explains it well. 

 

I tried to run a PowerShell code to force it to use an SQL server. but the problem is the power shell code does not  execute and it gives a bunch of errors complaining KeyBlocker:

 

 

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId: WebCmdletWebResponseException, Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod: {"error":{"message": "The request was blocked by KeyBlocker "}}
At line:57 char:1
+ Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Jason ...

1 ACCEPTED SOLUTION

Yes, it was an example. Run your SQL query, convert the result to JSON, then use that as the payload.

View solution in original post

7 REPLIES 7
AliSafa
Advocate I
Advocate I

thanks Ibendlin 
so i should convert my sql code which is (Select * from My table) to Json and Run the result inside the windows powershell ISE.
i will search a tool to convert it to json. 
thanks a lot

One thing to keep in mind:  One of the fields in your table should probably be a timestamp, and it should be in UTC and in ISO8601 format.

lbendlin
Super User
Super User

You can certainly do that - run a query against the SQL table and push the result into the streaming dataset.  It sounds a little weird though - how real time is your SQL data source?

its each 15 minutes. you said run a query against the SQL table and push the result into the streaming dataset.

the question is how to push the rsult to streaming Dataset?

thx

Real-time streaming in Power BI - Power BI | Microsoft Learn

Here is an example using Powershell

 

 

#capture stats
$date = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:00.000Z')
$mem = (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue
$proc = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue
$disk = (Get-Counter '\LogicalDisk(C:)\% free space').CounterSamples.CookedValue
$mashups = 0+(get-process "Microsoft.Mashup.Container.NetFX45" | Measure-Object ).Count
$mashmem = 0+(get-process "Microsoft.Mashup.Container.NetFX45" | Measure-Object WS -Sum ).Sum
$gwmem = 0+(get-process "Microsoft.PowerBI.EnterpriseGateway" | Measure-Object WS -Sum ).Sum
#enforce TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$payload = @{
"Host" = $env:computername
"Timestamp" = $date
"Available Memory in MB" = $mem
"Processor Load %" = $proc
"% Free on C:" = $disk
"Mashups" = $mashups
"Mashup Memory" = $mashmem
"Gateway Memory" = $gwmem
}
#push URL
$endpoint = "https://api.powerbi.com/beta/<tenant ID>/datasets/<dataset id>/rows?key=<API key>"
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))

 

thank you for your answer 
it seems that this code is reading data from memory and Processor etc and push it into the streamin dataset. 
but i need to read data from a sql table and push it to a Streaming dataset.

Yes, it was an example. Run your SQL query, convert the result to JSON, then use that as the payload.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.