get-AzBlueprint's version field is returned as a JObject, not a powershell object
Description
get-AzBlueprint's version field is returned as a JObject, not a powershell object You can see this with a simple GetType()
EDIT: bug report lost all details - replacing
Steps to reproduce
PS C:\VSProjects> $BPName = "Net-Spoke"
$bp = Get-AzBlueprint -ManagementGroupId $MyManagementGroupID -Name $BPName
PS C:\VSProjects> $bp.Versions.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False JObject Newtonsoft.Json.Linq.JContainer
PS C:\VSProjects> $bp.Versions.Count
PS C:\VSProjects> $bp.Versions.ToString()
{
"1.0": {
"datePublished": "2019-05-10T22:36:28Z",
"changeNotes": "Initial Release"
},
"1.1": {
"datePublished": "2019-05-10T22:39:42Z"
},
"1.2": {
"datePublished": "2019-05-10T23:22:41Z"
},
"1.3": {
"datePublished": "2019-05-14T20:27:40Z",
"changeNotes": "Some Notes"
}
}
PS C:\VSProjects> $bp.Versions.'1.0'
HasValues : False
Type : Date
Parent : {}
Root : {1.0, 1.1, 1.2, 1.2.1...}
Next :
Previous :
Path : ['1.0'].datePublished
First :
Last :
LineNumber : 0
LinePosition : 0
HasValues : False
Type : String
Parent : {}
Root : {1.0, 1.1, 1.2, 1.2.1...}
Next :
Previous :
Path : ['1.0'].changeNotes
First :
Last :
LineNumber : 0
LinePosition : 0
Environment data
PS C:\VSProjects> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
Module versions
Script 0.1.0 Az.Blueprint {Get-AzBlueprint, Get-AzBlueprintAssignment, New-AzBlueprintAssignment, Remove-AzBlueprintAssignment...}
Debug output
Error output
@filizt Can you verify that the output type being returned by the cmdlet is correct? The documentation shows System.Object. https://docs.microsoft.com/en-us/powershell/module/az.blueprint/get-azblueprint?view=azps-2.0.0
@filizt Can you verify that the output type being returned by the cmdlet is correct? The documentation shows System.Object. https://docs.microsoft.com/en-us/powershell/module/az.blueprint/get-azblueprint?view=azps-2.0.0
Looking.
Hey @ChristopherGLewis - current behavior is expected since we made some design decisions in the past and what you see (versions field type being JObject) is manifestation of that. That being said, our team agreed that we should provide a better experience here, so I'm working on a fix. It should be going out in the next release of AzBlueprint module.
@filizt I would highly advise against exposing any types from the Newtonsoft.Json library. The version of this library that is used is directly linked to the version of PowerShell you are using (Windows PowerShell, PowerShell Core 6.0/6.1/6.2). So, you may have significant issues when users try to run the cmdlets in these different environments. Here's just a small informational table showing the version differences:
| Windows PowerShell 5.1 | PowerShell Core 6.0 | PowerShell Core 6.1 | PowerShell Core 6.2 | |
|---|---|---|---|---|
| Newtonsoft.Json | 6.0.8 | 10.0.3 | 11.0.2 | 12.0.1 |
I don’t believe any of the other Az cmdlets expose anything but standard PowerShell objects.
I wasn’t looking forwards to re-learning jobject parsing...