Azure / Azure/azure-powershell
Invoke-AzureRmOperationalInsightsQuery returns any data as string
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
When run Invoke-AzureRmOperationalInsightsQuery and get .Results from the object all data is returned as string. According to the official documentation the Log Analytics Search API returns the types of the different columns. The Enumerable that is returned for results should honer the data types and return them as the output of the query rather returning every column as string. This breaks any functionality to
handle the data properly like converting it to JSON or PowerShell array and make some actions by doing comparison on things like dates, integers, etc.
### Script/Steps for Reproduction
Works with any query that return results with different formats like int.
```powershell
$summaryQuery = 'Perf | take 1'
$summaryQueryResults =Invoke-AzureRmOperationalInsightsQuery -Workspace $Workspace -Query $Query -Timespan (New-TimeSpan -Hours 24)
$summaryQueryResults.Results.CounterValue
0
$summaryQueryResults.Results.CounterValue.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
```
It should've integer or double but not string.
### Module Version
```powershell
Get-Module -Name AzureRM -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.4.1 AzureRM
```
### Environment Data
```powershell
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```
### Debug Output
There is no need for debug as it can be reproduced very easily.
```
```
Contributor guide
Assessment
This issue has not been assessed yet.