Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureRM cmdlets return object with a json-like format #1384

Closed
trondhindenes opened this issue Dec 1, 2015 · 65 comments
Closed

AzureRM cmdlets return object with a json-like format #1384

trondhindenes opened this issue Dec 1, 2015 · 65 comments
Assignees
Labels
Compute Network Service Attention This issue is responsible by Azure service team.

Comments

@trondhindenes
Copy link

When running for example Get-AzureRmVm, the following is returned:
image
For some reason the Azure team decided to go with a "json-like" view of returned objects, making it incredibly hard to read the output - json is simply a bad choice for being consumed by humans.

Implement proper output objects by using PowerShell formatting file (.format.ps1xml).

@lukeb1961
Copy link

lukeb1961 commented Dec 1, 2015 via email

@pcgeek86
Copy link
Contributor

pcgeek86 commented Dec 1, 2015

"json is simply a bad choice for being consumed by humans"

Not to mention that nothing in the PowerShell core sets a precedent like this for displaying objects.

Cheers,
Trevor Sullivan

@jeffpatton1971
Copy link

Honestly I think it's just in how they decided to format the output, to lead folks in the direction of templates.

@trondhindenes
Copy link
Author

@jeffpatton1971 don't you agree that the output is terrible? I'm finding the spacing, characters and commas increidble hard to read. If it's too hard to implement format.psxml files, just give me regular objects. Like every other PS module on the planet does.

@jeffpatton1971
Copy link

Let me answer this way. Using the image you posted above, what you see is what appears to be json output for the extensions property. For me, I kind of like being able to see (at a glance) all the properties and values in the underlying object; it's nice. My problem with this view is that the data being displayed is most likely held in ExtensionsText property (https://gist.github.com/jeffpatton1971/29e536cd0147694796cd) this is misleading at best, an outright lie at worst. I still feel this is a silly formatting issue.

from your perspective and that of someone who has been building custom powershell modules for my employers for years now, I feel like you. Seriously Microsoft? In every single blessed example of powershell on Microsoft.com and beyond this is not a thing. do not start altering the formatting like this for arbitrary cmdlets on what appear to be arbitrary modules within the overarching azure powershell library...it's stupid.

@singhkays
Copy link

Adding folks from the dev team and networking team as well @huangpf @hyonholee @DeepakRajendranMsft since this is prevalent in both Compute and Networking cmdlets.

Definitely good feedback. One thing I am yet to see the alternative to a JSON format that is good at displaying properties that are n levels deep. For example how to display all the information in a StorageProfile array of data disks

StorageProfile           : {
                         "DataDisks": [
                           {
                             "Lun": 0,
                             "Caching": "ReadWrite",
                             "CreateOption": "Empty",
                             "DiskSizeGB": 1,
                             "Name": "data-disk-1",
                             "SourceImage": null,
                             "VirtualHardDisk": {
                               "Uri": "http://123.blob.core.windows.net/vhds/data-disk-1.vhd"
                             }
                           },
                           {
                             "Lun": 1,
                             "Caching": "ReadWrite",
                             "CreateOption": "Empty",
                             "DiskSizeGB": 1,
                             "Name": "data-disk-2",
                             "SourceImage": null,
                             "VirtualHardDisk": {
                               "Uri": "http://123.blob.core.windows.net/vhds/data-disk-2.vhd"
                             }
                           }
                         ],

I'm not saying it is the best way to display information but I'm trying to find an approach that strikes a balance between users who want to see all information in one place and users who don't appreciate all the brackets, quotes. If we went with a more YAML like approach, is that acceptable?

Attached is a sample
image

@jeffpatton1971
Copy link

Just copying this over the yammer feed.

Honestly, I think just not display the text fields in the output is fine. The typical output of .net properties in powershell is really very simple. I've updated my gist (https://gist.github.com/jeffpatton1971/29e536cd0147694796cd) so you can see it. Since the beginning .net objects have appeared as their type names (ie line 57 LinuxConfiguration) and in powershell we know that we can delve into that further with $vm.osprofile.linuxconfiguration to see the properties with the object. This has been the standard that Trond Hindenes has been referring to, really I think since monad. The seemingly arbitrary change to display the .net assembly as json is jarring...to say the least.

That said, I get your point, you now have easy access to view all classes and subclasses and properties...nifty..works well for looking at possibly how a template should be laid out....but again...really goes against the grain.

wwjd
what would https://twitter.com/jsnover do ;-)

@jeffpatton1971
Copy link

Re-reading your statement above @singhkay and I think you're trying to solve a problem, that for those of us who use powershell day in and day out, that isn't really a problem. Was this something that was discussed only internally?

Just going to re-iterate I really think this just a formatting issue, change the output format back to the traditional powershell way and be done. Then either override the .ToString() method of the objects to return json, or give param -asJson to your cmdlet.

@pcgeek86
Copy link
Contributor

If a user wants JSON output, then they pipe the VM object into ConvertTo-Json (PowerShell 3.0+).

I think that the recommendation from @singhkay is reasonable. At least it doesn't have all the syntactical details included in it. It still looks a bit messy, but for the time being, I don't have any better suggestions, unless someone else chimes in with an idea.

ps. I strongly recommend against adding an -AsJson parameter. There is no precedent in PowerShell for this, and users should be guided to use ConvertTo-Json. If someone isn't using PowerShell 3.0, or later, by now, they should be guided to upgrade.

Cheers,
Trevor Sullivan

@singhkays
Copy link

@pcgeek86 Adding to this from the Yammer convo

The current proposed default view is to show the below object view and show the current full detailed view using a -Full switch. However, as you can see a bunch of very useful information is hidden behind the object types which could cause a bunch of dissatisfaction from users who are now used to seeing this information in top level without using the -Full switch. So, getting a consensus on this from the community would be great!

Another question, is there a reason (other than this being the PS way) why some might prefer this view over -Full being the default view if you can access objects like $vm.OSProfile, $vm.NetworkProfile in both views?

Get-AzureRmVM -ResourceGroupName somerg -Name MyWindowsVM

ResourceGroupName : somerg
Id : /subscriptions/123431-2de6-4179-8ab1-365da4211af4/resourceGroups/somerg/providers/Microsoft.Compute/virtualMachines/MyWindowsVM
Name : MyWindowsVM
Type : Microsoft.Azure.Management.Compute.Models.VirtualMachineListResponse
Location : westus
Tags : {}
AvailabilitySetReference : null
DiagnosticsProfile : Microsoft.Azure.Management.Compute.Models.DiagnosticsProfile
Extensions : Microsoft.Azure.Management.Compute.Models.Extensions
HardwareProfile : Microsoft.Azure.Management.Compute.Models.HardwareProfile
InstanceView : null
NetworkProfile : Microsoft.Azure.Management.Compute.Models.NetworkProfile
OSProfile : Microsoft.Azure.Management.Compute.Models.OSProfile
Plan : null
ProvisioningState : Succeeded
StorageProfile : Microsoft.Azure.Management.Compute.Models.StorageProfile

@jeffpatton1971
Copy link

I agree with @pcgeek86 if the underlying .net is sound, then convertto-json will allow us to see that if we want to, we can also access through the typename.class.propertyname syntax.

@singhkay The useful information isn't hidden, it's there and for those of us who have been using powershell since it started, this is what we're used to and have come to expect.

Again, respectfully, I think you're trying to solve a problem that isn't.

@trondhindenes
Copy link
Author

@singhkay I seriously find json messy to read. In addition, what Jeff/Trevor wrote. Please look at previous unfortunate decisions the Azure PowerShell team has made in terms of diverging from the regular way of doing PowerShell and take some learning from it.

@pcgeek86
Copy link
Contributor

I think users should become familiar with the object model of a Virtual Machine. If you display all of the content on the top-level VM object, then people will think that it's a more or less "flat" structure. Instead, if you require them to "drill down" into the VM object, using properties, then they will naturally learn the structure of the object. This isn't too different from other object models, such as the System.Diagnostics.Process object that is returned from the out-of-box Get-Process command.

Cheers,
Trevor Sullivan

@Vijayaraghavanl
Copy link

What is the status on this issue? Could we look forward for a regular output from powershell cmdlets as against a JSON view anytime soon? ConvertTo-Json exists anyway in case we need the output to be in JSON format.

@singhkays
Copy link

Update on this, we discussed this with few other teams besides Compute and the consensus is to not adopt the object view of the Get cmdlets properties as it hides too much important information e.g. below

DiagnosticsProfile : Microsoft.Azure.Management.Compute.Models.DiagnosticsProfile
Extensions : Microsoft.Azure.Management.Compute.Models.Extensions
HardwareProfile : Microsoft.Azure.Management.Compute.Models.HardwareProfile

Now on the the proposed solution. We discussed with the PowerShell team, who suggested we take a look at output of the following PS cmd which displays an object on the second level.

(Get-Process).Modules[0] | fl ModuleName,FileVersionInfo

ModuleName      : ApplicationFrameHost.exe
FileVersionInfo : File:             C:\WINDOWS\system32\ApplicationFrameHost.exe
                  InternalName:     Application Frame Host
                  OriginalFilename: ApplicationFrameHost.exe
                  FileVersion:      10.0.10586.0 (th2_release.151029-1700)
                  FileDescription:  Application Frame Host
                  Product:          Microsoft® Windows® Operating System
                  ProductVersion:   10.0.10586.0
                  Debug:            False
                  Patched:          False
                  PreRelease:       False
                  PrivateBuild:     False
                  SpecialBuild:     False
                  Language:         English (United States)

Based on this we have two designs for you folks to consider. Note in both cases you'll still be able to access subobjects the same way you do today i.e. $vm.StorageProfile.osDisk.osType

Proposal 1

  • Top level properties (profiles) and sub objects (osDIsk, imageReference, dataDisks) are aligned along a single column
  • All values within an object are aligned to a single column top to bottom for readability but values across different objects would be aligned across different column.
  • Properties that are arrays are represented with []
  • Empty line after objects to separate out the objects from other objects for readability
ResourceGroupName        : kayrg2
Id                       : /subscriptions/XXXXXXXXX/resourceGroups/kayrg2/providers/Microsoft.Compute/virtualMachines/cid4085b9ab28112a1
Name                     : cid4085b9ab28112a1
Type                     : Microsoft.Compute/virtualMachines
Location                 : westus
ProvisioningState        : Succeeded
HardwareProfile          : vmSize : Standard_D2
Tags                     : [
                            Department : testdep
                            CostCenter : testcost
                            TestTag3   : test
                           ]

AvailabilitySetReference : null
NetworkProfile           : networkInterfaces : [
                              primary : true
                              id      : /subscriptions/XXXXXXXX/resourceGroups/kayrg2/providers/Microsoft.Network/networkInterfaces/gateway-nic
                           ]

OSProfile                : computerName         : cid4085b9ab28112a1
                           adminUsername        : notused
                           adminPassword        : null
                           customData           : IyEvYmluL2Jhc2g=
                           windowsConfiguration : null
                           linuxConfiguration   :
                              disablePasswordAuthentication : false
                              ssh                           : null
                           secrets : []

Plan                     : name          : sg-byol
                           publisher     : checkpoint
                           product       : check-point-r77-10
                           promotionCode : null

StorageProfile           : imageReference :
                             publisher : checkpoint
                             offer     : check-point-r77-10
                             sku       : sg-byol
                             version   : latest

                           osDisk :
                             osType             : Linux
                             encryptionSettings : null
                             name               : osDisk
                             image              : null
                             caching            : ReadWrite
                             createOption       : FromImage
                             diskSizeGB         : null
                             vhd:
                               uri : http://ci21c713ff5add7e76.blob.core.windows.net/vhds/cid4085b9ab28112a1.vhd

DiagnosticsProfile       : bootDiagnostics :
                              enabled    :    true
                              storageUri : http://ci21c713ff5add7e76.blob.core.windows.net

Proposal 2

  • This is based on aligning all the values on a single column so that it's easier to read from top to bottom as the values are in the same line
  • The properties/keys on the left and subobjects on the left are also aligned along a single column
  • The indendtation is along the properties. These are indented according to their depth in the object
Id                              :/subscriptions/XXX/resourceGroups/ws2016/providers/Microsoft.Compute/virtualMachines/ws2016
ProvisioningState               : Succeeded
Name                            : ws2016
Location                        : westus
Type                            : Microsoft.Compute/virtualMachines

HardwareProfile:
    Size                        : Standard_D2_v2

StorageProfile:
  Imagereference:
    Publisher                   : MicrosoftWindowsServer
    Offer                       : WindowsServer
    Sku                         : Windows-Server-Technical-Preview
    Version                     : latest

  OSDisk:
    OSType                      : Windows
    Name                        : ws2016
    Caching                     : ReadWrite
    CreateOption                : FromImage
    Vhd:
      Uri                       : https://wsa89.blob.core.windows.net/vhds/ws2016sa1162616.vhd

OSProfile:
  ComputerName                  : ws2016
  UserName                      : kay
  WindowsConfiguration:
    ProvisionVMAgent            : true
    Enableautomaticupdates      : true

NetworkProfile:
  NetworkInterfaces:
    NetworkInterface #1:
      Primary                   : false
      Provisioning State        : Succeeded
      Name                      : ws2016562
      Location                  : westus

@pcgeek86
Copy link
Contributor

I vote for proposal 1.

Cheers,
Trevor Sullivan

@singhkays
Copy link

Thanks for the feedback @pcgeek86! @trondhindenes @jeffpatton1971 @Vijayaraghavanl @lukeb1961 Any thoughts on which proposal you prefer?

@huangpf
Copy link
Contributor

huangpf commented Mar 11, 2016

Proposal #2 is better, because the semi colons are aligned, and sub-fields at various levels are clearly indented.

Proposal #1’s semi colons are scattered all around, which makes it very difficult to follow the content, and it’s unclear when it goes to next level and when it’s not, i.e.
• HardwareProfile : vmSize : Standard_D2
vs.
• StorageProfile : imageReference :
publisher : checkpoint

@Kraftwerx
Copy link
Member

+1 for proposal #2, but as someone who lives in PoSh with these cmdlets, I'm not sure there's a big problem with the current json output. For some reason this has never bit me when manipulating objects json output or not.

@kilasuit
Copy link

Not sure why you couldn't just have the output in nested Hashtables as that really is simple enough and is already widely known.

Again its items like this that make me wonder about the decision points being made on the development practises of this set of Microsoft "Official" Modules

An example of this in action would be the objects output from the Find-Module Cmdlet and In my Opinion this is the correct way for you to output data as it can easily be manipuated and pushed along the pipeline (if required)

@singhkays
Copy link

@kilasuit Interesting, do you have an example of the nested hashtables output from Find-Module? I'm seeing just a table

PS C:\WINDOWS\system32> Find-Module 

Version    Name                                Type       Repository           Description                                                                                                                    
-------    ----                                ----       ----------           -----------                                                                                                                    
1.0.5      AzureRM.profile                     Module     PSGallery            Microsoft Azure PowerShell - Profile credential management cmdlets for Azure Resource Manager                                  
1.0.5      Azure.Storage                       Module     PSGallery            Microsoft Azure PowerShell - Storage service cmdlets. Manages blobs, queues, tables and files in Microsoft Azure storage acc...
1.2.2      AzureRM                             Module     PSGallery            Azure Resource Manager Module                                                                                                  
1.7.3      Posh-SSH                            Module     PSGallery            Provide SSH functionality for executing commands against remote hosts.                                                         
1.0.5      AzureRM.Storage                     Module     PSGallery            Microsoft Azure PowerShell - Storage service management cmdlets for Azure Resource Manager.  Creates and manages storage acc...
1.0.5      AzureRM.Automation                  Module     PSGallery            Microsoft Azure PowerShell - Automation service cmdlets for Azure Resource Manager                                             
1.0.5      AzureRM.Resources                   Module     PSGallery            Microsoft Azure PowerShell - Azure Resource Manager cmdlets.  Manages subscriptions, tenants, resource groups, deployment te...
1.2.4      AzureRM.Compute                     Module     PSGallery            Microsoft Azure PowerShell - Compute service cmdlets for Azure Resource Manager.  Manages virtual machines, hosted services,...

@kilasuit
Copy link

If you were to run the following

Find-Module AzureRM | Select-object *

You'll find the AdditionalMetadata property is a Hashtable with nested Hashtables added into it.

@singhkays
Copy link

@kilasuit Thanks! I see it now. The problem I find with this is that it just displays the key in the embedded object (Created, ItemType, copyright, PackageSize...). The GET VM analogous to this wouldn't give much info in the default view. You'll have to dig into each object to find the VM properties. For an example exercise, trying to find the storage account the VM data disk is in would take many interactions with the VM object versus a view that shows all properties in the above proposals.

Id                :/subscriptions/XXX/resourceGroups/ws2016/providers/Microsoft.Compute/virtualMachines/ws2016
ProvisioningState : Succeeded
Name              : ws2016
Location          : westus
Type              : Microsoft.Compute/virtualMachines
HardwareProfile   : {Size}
StorageProfile    : {Imagereference, OSDisk}
OSProfile         : {ComputerName, UserName, WindowsConfiguration}
NetworkProfile    : {NetworkInterfaces}
PS C:\WINDOWS\system32> $obj = Find-Module AzureRM | Select-object *

PS C:\WINDOWS\system32> $obj


Name                       : AzureRM
Version                    : 1.2.2
Type                       : Module
Description                : Azure Resource Manager Module
Author                     : Microsoft Corporation
CompanyName                : azure-sdk
Copyright                  : Microsoft Corporation. All rights reserved.
PublishedDate              : 3/4/2016 3:04:49 AM
InstalledDate              : 
UpdatedDate                : 
LicenseUri                 : 
ProjectUri                 : 
IconUri                    : 
Tags                       : {PSModule}
Includes                   : {Function, RoleCapability, Command, DscResource...}
PowerShellGetFormatVersion : 
ReleaseNotes               : 
Dependencies               : {}
RepositorySourceLocation   : https://www.powershellgallery.com/api/v2/
Repository                 : PSGallery
PackageManagementProvider  : NuGet
AdditionalMetadata         : {Created, ItemType, copyright, PackageSize...}




PS C:\WINDOWS\system32> $obj.AdditionalMetadata

Name                           Value                                                                                                                                                                                                                          
----                           -----                                                                                                                                                                                                                          
Created                        2016-03-04T03:04:49.27                                                                                                                                                                                                         
ItemType                       Module                                                                                                                                                                                                                         
copyright                      Microsoft Corporation. All rights reserved.                                                                                                                                                                                    
PackageSize                    14810                                                                                                                                                                                                                          
CompanyName                    Microsoft Corporation                                                                                                                                                                                                          
tags                           PSModule                                                                                                                                                                                                                       
DotNetFrameworkVersion         4.0                                                                                                                                                                                                                            
published                      3/4/2016 3:04:49 AM -08:00                                                                                                                                                                                                     
developmentDependency          False                                                                                                                                                                                                                          
IsPrerelease                   false                                                                                                                                                                                                                          
SourceName                     PSGallery                                                                                                                                                                                                                      
NormalizedVersion              1.2.2                                                                                                                                                                                                                          
GUID                           B433E830-B479-4F7F-9C80-9CC6C28E1B51                                                                                                                                                                                           
updated                        2016-03-16T19:51:10Z                                                                                                                                                                                                           
GalleryDetailsUrl              https://www.powershellgallery.com/packages/AzureRM/1.2.2                                                                                                                                                                       
ProcessorArchitecture          None                                                                                                                                                                                                                           
Functions                      Test-AdminRights CheckIncompatibleVersion Install-ModuleWithVersionCheck Update-AzureRM Import-AzureRM Uninstall-ModuleWithVersionCheck Uninstall-AzureRM                                                                      
summary                        Azure Resource Manager Module                                                                                                                                                                                                  
PowerShellVersion              3.0                                                                                                                                                                                                                            
Type                           Module                                                                                                                                                                                                                         
CLRVersion                     4.0                                                                                                                                                                                                                            
description                    Azure Resource Manager Module                                                                                                                                                                                                  
FileList                       AzureRM.nuspec|AzureRM.psd1|AzureRM.psm1|AzureRM.psm1-help.xml                                                                                                                                                                 
VersionDownloadCount           3094                                                                                                                                                                                                                           
PackageManagementProvider      NuGet                                                                                                                                                                                                                          

@kilasuit
Copy link

From a PowerShell mindset though I expect to have to drill down into the objects to see the whole item and its property and with that I can't understand why you would want to nor expect us to work with this in a different manner.

I suppose what I'm trying to say is from my point of view your trying to fix something that in my opinion isn't broken because you think it will be easier for other end users to understand.

The problem I see with this approach is that your attempting to reinvent the already existing wheel and turn it into a square which is a reoccurring theme across the whole of these modules and in my opinion this is a very bad anti-pattern for users to get to grips with PowerShell in general and this set of Azure Modules as these could be the first entry into using PowerShell so anything they learn from here they would expect to work in other areas with other modules and this just isn't the case - which will cause frustration and people will then drop using PowerShell because of it.

Again that's just my opinion but I believe this is shared with the majority of the wider community.

@singhkays
Copy link

@kilasuit

From a PowerShell mindset though I expect to have to drill down into the objects to see the whole item and its property and with that I can't understand why you would want to nor expect us to work with this in a different manner.

From the GET VM object you'll still be able to drill down in the object and access the sub-properties. For example you'll be able to do $vm.StorageProfile.OSDisk.OSType to get the OS for the VM. In this case. the problem as I see it is that users new to the platform might not have a good understanding of how to get the os type of the VM so expanding all objects by default adds a great amount of value to the cmdlet return. There are many other critical VM properties that I think make sense which is why I'm favoring the expanded view rather than force everyone to adhere to powershell patterns to drill down into the objects to find each and every detail about the VM.

@jeffpatton1971
Copy link

@singhkay This is getting weird. Kay, the default behavior of nigh every other powershell cmdlet is to return the straight objects. By returning json strings we are now going against the current. While it sounds like it would make sense, you actually will create a hurdle as these users will expect other cmdlets to return similar output and they will not.

I love the discussion around this, but at the end of the day, I don't know if azure powershell should be a snowflake. I think azure powershell should really fall in lock step with how the rest of the cmdlets work by default. I will re-iterate what I said earlier, by all means leave your json strings in the object, just change the output format to be the regular objects that we have all come to love, use, depend and emulate in our own code.

@singhkays
Copy link

By returning json strings we are now going against the current

It won't be returning JSON strings in the proposals above. It'll be a PowerShell object with formatting applied using the format file. I've run this by the PowerShell team who like the idea of #2 proposal above.

While it sounds like it would make sense, you actually will create a hurdle as these users will expect other cmdlets to return similar output and they will not.

This is confusing to me. How does applying a different visual of the object using a format file break things? Can you share an example of your usage where you think this'll break. That will probably help me understand this better.

The thing is we're discussing a changing to a compute cmdlet. Unless the other teams see a clear value in presenting outputs in more PS way (it hides critical properties from top level is the current feedback from me and what I'm hearing from other teams as well), this is likely going to end up with Compute GET output out of sync with other Azure services. IMO what I need is concrete scripting examples and workarounds you folks are having to do to work around the current output format. A scripting example of how the Find-Module AzureRM | Select-object * output pattern would solve things for you would be a good starting point.

@trondhindenes
Copy link
Author

I have to agree with @kilasuit on this one. Please look at history, and the disasterous results from every attempt the Azure team has made in coming up with something "new and easy". This is the exact line of thought that lead to the "Switch-AzureMode" fiasco. Please just give us plain PowerShell objects. Look at the object output from a VM in System Center VMM (which is also a very complex type). We want Azure VMs to behave exactly like that. We do not want "shortcuts" that are well-meant for accomodating beginners, because this would differ from pretty much all other PS modules, hurting beginners in the long term.

This thread has been heavily commented by some of the top-notch folks in the PS community. Please listen to them.

@pcgeek86
Copy link
Contributor

Honestly, I'm not terribly concerned about this anymore, since I started an external project to simplify formatting of output from the Azure PowerShell module. One of the format.ps1xml formatting file that I intend to add is for ARM Virtual Machines. I've already got one for Resource Groups.

https://github.com/pcgeek86/azure-powershell-extensions

@pcgeek86
Copy link
Contributor

Tracking the issue here. It's already been fixed.

pcgeek86/azure-powershell-extensions#2

@trondhindenes
Copy link
Author

Nice one @pcgeek86. Tho I'd still like to have correct formatting in-box without any dependencies.

@jeffpatton1971
Copy link

@pcgeek86 that's amazing, but honestly you shouldn't have to do something like that just to make the azure flavor of powershell...gee...look like powershell.

@trondhindenes makes an excellent point, we appreciate the idea of helping out the new guy but I think the @singhkay is proposing is wrong. help the new guy but fixing the documentation. One of the ABSOLUTE worst things about powershell is the lack of adequate documentation.

@singhkay you want to help the beginner? Bring the powershell documentation to GitHub, have guys like from the community like @pcgeek86 and @trondhindenes edit it like we do for your azure documentation. I know I actively read that and when I find problems I make changes, and I think @pcgeek86 has as well.

You all figure that out, you won't have to waste cycles developing intricate and complex formatting files, you won't force us to write formatting files to fix your formatting, and you will help the new guy in more ways than you can even begin to think about.

@pcgeek86
Copy link
Contributor

Thanks guys. I've spent so many (multiple hundreds?) of hours giving feedback that gets ignored, that I've taken it upon myself to solve problems. Better to spend the time writing things that work, instead of influencing others to make good decisions, that they ultimately don't make. I'm just shifting my time investment to something that's ultimately more positive, and that's something that @trondhindenes has done as well, with his Blue PowerShell module.

@markcowl
Copy link
Member

markcowl commented Apr 29, 2016

@jeffpatton1971 I think we have heard this feedback loud and clear. Are you specifically talking about the help documentation? The msdn reference documentation, or conceptual documentation?

Help documentation is on GitHub now, just not in a form that would encourage anyone to edit it, and this content is actually used for the reference documentation. At //BUILD, we showed an early version of tools to move the documentation to MarkDown, which should help encourage contributions. This is due to roll out once the PowerShell core team has solidified their new MarkDown format and supporting tools next Month.

On cponceptual documentation, we have an overhaul underway. I would like all of this to be fixed yesterday, but you should start really seeing the effects over the late Spring and Summer.

@jeffpatton1971
Copy link

@markcowl I am talking about a number of things, but the effort here seems to be to try and simplify something for users when it's not needed. My solution to this over-simplification of powershell cmdlets is to create more extensive documentation.

Specifically I talking about PowerShell documentation, when this all started with PowerShell v1 the documentation wasn't too bad. There was the regular online help documentation specific to the cmdlet, then there were a whole series of "using" documents.

Let's let PowerShell do what PowerShell does best, pipe objects (not json) to the pipeline. To aid the new users to PowerShell (and Azure PowerShell specifically) let's all come up with some really good documentation. Educate the user on how to use the tools, not the other way around.

PowerShell does need to work for all levels of people, but making the tool do this is NOT the answer.

I know that this will come off as bitchy, but there is a whole community of PowerShell folks and I like to think that a large majority of us feel very strongly about the language. In fact I know that a great many of us have become accustom to precisely how it works, and it REALLY feels as though the Azure PowerShell group is literally choosing to go a different direction.

I just got back from Redmond where the OMS group pulled in several customers and sat down with us to get our opinions on what they thought was the right direction. Did something like this happen? Did someone post in the Azure Advisors PowerShell group, hey we've decided to drop object output from Azure Powershell and instead plan to drop straight json? Perhaps I missed the memo?

PowerShell is an object oriented scripting language, if I want json I will get json.

Going to stop my ranting now.

@jeffpatton1971
Copy link

@markcowl let me come back to this and approach it this way. If PowerShell wasn't such an excellent tool, if many of us didn't (quite literally) use it as a source of our livelihood, then we wouldn't have this passion about it. We wouldn't care. You want to output unicorns on the pipe? meh...whatev

But it's an amazing and powerful tool, it's a credit to Mr. Snover and all the programmers who work on it. And speaking for myself as a person who uses it ALL the time, I feel like it's partially mine, that I have a stake in its future, it's personal.

So when we get kind of crazy and snippy, it's because we care so deeply.

@pcgeek86
Copy link
Contributor

So when we get kind of crazy and snippy, it's because we care so deeply.

Nicely said, sir. It's because we want to work together to make it to succeed, and invest a lot of personal effort in order to make that happen.

@lukeb1961
Copy link

Kay have you guys thought about chatting with Bruce Payette to get his feedback?

Luke

Sent from my Windows Phone


From: Kay Singhmailto:notifications@github.com
Sent: ‎29/‎04/‎2016 8:43
To: Azure/azure-powershellmailto:azure-powershell@noreply.github.com
Cc: lukeb1961mailto:lukebrennan@outlook.com; Mentionmailto:mention@noreply.github.com
Subject: Re: [Azure/azure-powershell] AzureRM cmdlets return object with a json-like format (#1384)

@jeffpatton1971 PowerShell needs to work for a broad set of customers, experts and beginners so it's always a fine line to balance the both. Let's look at some example Q&A

I want my Linux VM to be secure and only accessible through SSH. Is password authentication disabled?

Current scenario

The answer would be

  1. Run Get-AzureRmVm -ResourceGroupName <rgname> -Name <vmname>
  2. Look under LinuxConfiguration and see what the value of DisablePasswordAuthentication is.

Number of commands run to get this information: 1

Object type output scenario

The answer would be

  1. Run Get-AzureRmVm -ResourceGroupName <rgname> -Name <vmname>

    At this point a new user doesn't see the expected information but sees a bunch of objects in the output. Now the user needs to go and learn about objects in PowerShell and know how to save the return of this cmdlet into a variable. So essentially what the user now needs to run $vm = Get-AzureRmVm -ResourceGroupName <rgname> -Name <vmname> This means already they've run 1 more command than the last time.

  2. After learning about the object model the user now knows how to access properties with a . so the user runs $vm.OSProfile.LinuxConfiguration

  3. Voila! There is the information the user wanted under the value of DisablePasswordAuthentication but the user has already invested time in learning about the object model PS and run 2 or 3 commands depending on familiarity with the object model

Number of commands run to get this information: 2 or 3 depending on previous familiarity with PS objects


Let's ask a combination of questions this time

I want my Linux VM to be secure and only accessible through SSH. Is password authentication disabled? What storage account is my osdisk in? How many NICs are on my VM? What image was used for the VM?

Current scenario

The answer would be

  1. Run Get-AzureRmVm -ResourceGroupName <rgname> -Name <vmname>
  2. Look under LinuxConfiguration and see what the value of DisablePasswordAuthentication is.
  3. Look under StorageProfile->OsDisk and see what the value of Vhd->Uri is. The string before blob.core.windows.net is the storage account name the VHD is in.
  4. Look under NetworkProfile. The number of NetworkInterfaces->Id is the number of NICs attached to the VM.
  5. Look under StorageProfile and see what the value of ImageReference is.

Number of commands run to get this information: 1

Object type output scenario

The answer would be

  1. Run $vm = Get-AzureRmVm -ResourceGroupName <rgname> -Name <vmname> assuming user remembers object model from last time around
  2. Run $vm.OSProfile.LinuxConfiguration and note the value of DisablePasswordAuthentication
  3. Run $vm.StorageProfile.OsDisk.Vhd.Uri and see what the value is. The string before blob.core.windows.net is the storage account name the VHD is in.
  4. Run $vm.NetworkProfile.NetworkInterfaces.Count and see what the number is. That's the NIC count.
  5. Run $vm.StorageProfile.ImageReference and note the value.

Number of commands run to get this information: 5


NOTE: All the above commands work in the upcoming release. Then the question for us is why would we want to increase the time it takes for the user to answer a question by having to run more commands? As an expert PowerShell user if all the objects and properties can be accessed in a PS way with a . for automation like you would expect to, what does expanding them out take away from you?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#1384 (comment)

@trondhindenes
Copy link
Author

trondhindenes commented Apr 30, 2016

@singhkay just an additional comment on the examples you've provided above: There's an object attribute called "ProvisioningState", however, the format-table output shows this as "Provisioning State". This is exactly what we're talking about: Design decisions that are not thought thru. I'm pretty sure everyone in this thread agrees with me when I say that formatters that rename the "true" attribute name of an object are pretty much the worst, and this is a pretty clear sign the redesigned cmdlets have not been subject to proper end-user testing (Specifically, If I see at ft column name called "Provisioning State" I would expect to be able to do bla | group-object 'Provisioning State', which I can't since the attribute is really called ProvisioningState. You guys haven't thought stuff thru.
Please let PowerShell be PowerShell and stop attempting to sprinkle "niceness" on top of it, it will just hurt everyone.

@pcgeek86
Copy link
Contributor

formatters that rename the "true" attribute name of an object are pretty much the worst

In most cases, yes, I agree with that. There are some rare cases where renaming a property in the formatted output is appropriate, but it should be thought through prior to making a decision.

@trondhindenes

@singhkays
Copy link

@lukeb1961 This was checked with the PS team but I'll check with Bruce as well although it looks like he's been OOF for a while.

@kilasuit @trondhindenes @jeffpatton1971 It'd be good for the team to see an example of the Get-AzureRmVm output you are proposing. I think that might make things more clearer of what the community expectations are around the amount of information returned.

@kilasuit
Copy link

@singhkay - I've given my example above numerous times so I'm struggling with this

@kilasuit @trondhindenes @jeffpatton1971 It'd be good for the team to see an example of the Get-AzureRmVm output you are proposing. I think that might make things more clearer of what the community expectations are around the amount of information returned.

Seriously I would suggest having a full re-read of this thread and having a look at the suggestions given prior including these ones that clearly point out what you guys need to be doing as these are a few of the points that others have made

Let's let PowerShell do what PowerShell does best, pipe objects (not json) to the pipeline. To aid the new users to PowerShell (and Azure PowerShell specifically) let's all come up with some really good documentation. Educate the user on how to use the tools, not the other way around.

PowerShell does need to work for all levels of people, but making the tool do this is NOT the answer.

I have to agree with @kilasuit on this one. Please look at history, and the disasterous results from every attempt the Azure team has made in coming up with something "new and easy".

PowerShell is an object oriented scripting language, if I want json I will get json.

Please let PowerShell be PowerShell and stop attempting to sprinkle "niceness" on top of it, it will just hurt everyone.

So the format that I expect as default output would be

Id                :/subscriptions/XXX/resourceGroups/ws2016/providers/Microsoft.Compute/virtualMachines/ws2016
ProvisioningState : Succeeded
Name              : ws2016
Location          : westus
Type              : Microsoft.Compute/virtualMachines
HardwareProfile   : {Size}
StorageProfile    : {Imagereference, OSDisk}
OSProfile         : {ComputerName, UserName, WindowsConfiguration}
NetworkProfile    : {NetworkInterfaces}

As previously noted 2 months ago

@singhkays
Copy link

@kilasuit Thanks Ryan

@trondhindenes @jeffpatton1971 @lukeb1961 @pcgeek86 Are you agreed on the above format?

@markcowl
Copy link
Member

Personally, I think striking a balance between displaying the most useful information by default and leaving other information in the default format makes sense, but it seems like that isn't the consensus view on this thread.

@jeffpatton1971
Copy link

@markcowl I think all we're trying to say is let PowerShell be PowerShell, it outputs objects. I really like the JSON and I get why it's there, why not allow the object output from get-azurermvm be passed into convertto-json so that it outputs the proper json azure needs.

But most of us who have been griping in this thread have been using powershell since before it was called powershell. We see and use the cmdlets that all the other groups from inside Microsoft publish and the azure group just seems like they collectively said, " I see what you did there, we're not doing that."

The general gist of this discussion has been around making the powershell more accessible to folks who are new to it. I get that, I think that's important, but I think making an entire collection of cmdlets that output data in a totally different way than any other cmdlet is not right.

Look at it this way, we have a new administrator and we introduce them to powershell by having them open up powershell, running a few cmdlets so they can see how things work. Then we have them load up some of the admin modules say for active directory, exchange, and walk them through some basic admin type things. As they work through they begin to realize that these blocks of text are actually objects, and many objects have properties and methods that can be called directly from them.

Then we say, here is azure, the first time they run get-azurermvm ( I pick on that one for some reason ) they get an ENTIRELY different output. the learning curve just took a steep angle up, for no good reason.

I said early on, I love the json output, but give me a switch param -asjson or some such, that way I can see the json when I want to see/use it. One of the guys in here went out and just wrote his own set of cmdlets/formatters to not have to deal with this.

It all just seems...odd. You all have my contact info, i'm happy to hop on a call or something, i'm not trying to be a jerk, but we are passionate about how things are, and sometimes that spills out.

@trondhindenes
Copy link
Author

@singhkay I agree with the proposed format from @kilasuit (which is basically no format at all)
@jeffpatton1971 well put, I completely agree.

@kilasuit
Copy link

kilasuit commented Jul 4, 2016

Is there any further update on this @singhkay as its now been 6 weeks since the last comment was made on this thread

@kilasuit
Copy link

@singhkay / @markcowl - Can we get an update on this one way or another please?

We are 8 & 1/2 months on since this was initially raised surely this should be able to be prioritised, fixed and closed soon enough?

@singhkays
Copy link

@kilasuit Sorry, been busy with non-PS priorities. Here's the design being currently discussed with the PS team. This is based on existing Get-Date cmdlet that has a parameter DisplayHint that can display various different output formats.

Get-Date -DisplayHint Date
Thursday, July 14, 2016

Get-Date -DisplayHint DateTime
Thursday, July 14, 2016 10:50:33 AM

Get-Date -DisplayHint Time
10:50:35 AM

The proposal is to add a -DisplayHint parameter to Get-AzureRmVm so that the cmdlet can display the current output as well as your proposed output above. What do you think?

@trondhindenes
Copy link
Author

trondhindenes commented Jul 14, 2016

I'm not opposed to a displayhint parameter, but your reply seems to indicate that the current json output would be the default. I don't understand why you would believe that to be the preferred output for most users - I seriously believe it's the other way around. Maybe it would be a good idea to do a survey on the Azure insiders group / powershell slack group to get a broader group's opinion on this.

@singhkays
Copy link

@trondhindenes The discussion is not closed on the default view but IMO we have an opportunity to experiment here a bit on what should be the default provided the return object is not changed so that we don't have breaking changes to scripts. Here's an example experiment that could be done to further this discussion:

  • Add DisplayHint with two values
    • Compact
    • Expand
  • Set Object view (Compact value above) as default
  • Monitor GIthub issues, DLs, MSDN forums, Yammer, Stack Overflow and any other signals for feedback
  • Respond to user feedback

Thoughts??

@trondhindenes
Copy link
Author

My first thougt is that that would make an extremely long-running issue even more long-running since we're not actually fixing the problem. Again I don't see the problem: Thousands if not millions of Powershell cmdlets have already set precedence for how Powershell should work in terms of output. All you guys need to do is align to that precedence.

@kilasuit
Copy link

kilasuit commented Sep 19, 2016

@singhkays - Now I'm working more and more with Azure this format is really starting to irritate me.

This isnt a great UX and from a design pov it just screams out that it is just a cluttered mess of output which is 95% of the time unnecessary to output all of that information.

So please I ask of you to please get this sorted out!

@singhkays
Copy link

singhkays commented Sep 30, 2016

@kilasuit We have had limited dev resources to focus on the format but we're working on getting feedback from a larger community on the proposals outlined in this thread in the meantime. Here's a survey that's been sent out to different communities with more than 1000+ members (PS experts and non-experts) https://www.surveymonkey.com/r/HF5X9R8

Additionally we've been experimenting with the display format for the Get-AzureRmVm cmdlet (without parameters). Here's a preview

PS C:\Users\kay> get-azurermvm

ResourceGroupName                 Name  Location      VmSize  OsType                  NIC ProvisioningState
-----------------                 ----  --------      ------  ------                  --- -----------------
CUSTOMSCRIPTTESTRG customscriptLinuxVM    westus Standard_D2   Linux customscriptLinuxNic         Succeeded
CUSTOMSCRIPTTESTRG          resizetest    westus    Basic_A2   Linux        resizetest789         Succeeded
KAYRGUB                     MyubuntuVM    westus Standard_D3   Linux              myVMNic         Succeeded
PSHELP                          pshelp centralus    Basic_A2 Windows            pshelp524         Succeeded
KDOCKERRG                    kDockerVM   westus2 Standard_F2   Linux         kdockervm852         Succeeded
MD-TEST                          win10   westus2 Standard_F2 Windows             win10Nic         Succeeded

We explored showing the current running status of the VM in this view but that means that we have to call the Instance View API on each of the VMs returned in the subscription which increased the execution time on the cmdlet and could also cause customers with large number of VMs in the subscription to run into hourly API throttling limits.

@singhkays
Copy link

singhkays commented Dec 16, 2016

We've released these improvements in PS release 3.3.0. Now Get-AzureRmVm -ResourceGroupName rg -Name vmname has a compact display. Marking this as closed.

ResourceGroupName   : KDOCKERRG
Id                  : /subscriptions/***/resourceGroups/KDOCKERRG/providers/Microsoft.Compute/virtualMachines/kDockerVM
VmId                : 6d8nndbh-4e5d-484d-1875-0d4c0849npew
Name                : kDockerVM
Type                : Microsoft.Compute/virtualMachines
Location            : westus2
Tags                : {}
DiagnosticsProfile  : {BootDiagnostics}
Extensions          : {LinuxAsm, Microsoft.Insights.VMDiagnosticsSettings}
HardwareProfile     : {VmSize}
NetworkProfile      : {NetworkInterfaces}
OSProfile           : {ComputerName, AdminUsername, LinuxConfiguration, Secrets}
ProvisioningState   : Succeeded
StorageProfile      : {ImageReference, OsDisk, DataDisks}
NetworkInterfaceIDs : {/subscriptions/***/resourceGroups/kDockerRG/providers/Microsoft.Network/networkInterfaces/kdockervm852}

https://github.com/Azure/azure-powershell/releases/tag/v3.3.0-December2016

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute Network Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests