Forum Discussion
AliSafa
3 years agoAdvocate 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 ...
- 3 years ago
Yes, it was an example. Run your SQL query, convert the result to JSON, then use that as the payload.
lbendlin
3 years agoSuper User
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))
AliSafa
3 years agoAdvocate I
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.
- lbendlin3 years agoSuper User
Yes, it was an example. Run your SQL query, convert the result to JSON, then use that as the payload.