Announcing Az Predictor
Published Nov 10 2020 03:11 PM 33.9K Views
Microsoft

The Azure PowerShell modules expose over 4,000 cmdlets and, on average, ten parameters per cmdlet. Experienced PowerShell users will find the right cmdlet and parameter to achieve their goal but this can be more complicated for casual users.

I have rarely seen people experimenting with a new module being able to execute a command successfully on their first attempt. With time, this is no more an issue as people get accustomed to the cmdlet and remember the associated parameters, unless you have a terrible memory like me and need to refer to the documentation frequently.

 

Az Predictor annimated GIFAz Predictor annimated GIF

Goals

We built Az Predictor, an intelligent command completion module for Azure Powershell. Az Predictor helps our Azure developers find the cmdlet they are looking for efficiently, identify the required parameters quickly, and experience fewer errors.

We worked closely with the PowerShell team to have Az be the first module that leverages this new interface and bring suggestions to the developer’s fingertips. Az Predictor takes the context of the current session into account in its suggestions. With Az Predictor’s context-aware suggestions users will be guided through the discovery of cmdlets and will not need to go to the online help as often.

To satisfy different working styles, we are offering two modes:

 

  • Inline mode: a suggestion with parameters and values will appear with some opacity on the rest of the command line. We expect this mode to be more suited for the experienced developers who already understand the cmdlets.
    Az Predictor inline mode screen captureAz Predictor inline mode screen capture

     

  • Listview mode: several suggestions will appear below the command line with the complete parameter set displayed. This mode should be more suited to folks who need to see the command’s full line to know the parameters.
    Az Predictor listview mode screen captureAz Predictor listview mode screen capture

 

Technical details

Az Predictor is currently a module in preview in the PowerShell gallery. We are looking for feedback on this first preview, and based on what we will hear from customers, we are considering making it part of the Az wrapper module.

The inline view and list view modes are provided by PSReadline to manage the user’s interactions. The plugin is responsible for providing the suggestions to be used by PSReadline.

Az Predictor is built on top of the subsystem plugin model that is available after PowerShell 7.1-preview7 and used by PSReadline 2.2.0-beta1; hence the following configuration is required to try Az Predictor:

March 9, 2021 update: The second preview of Az.Tools.Predictor requires PowerShell 7.2-preview3 and PS readline 2.2.0-beta2. More information on the announcement https://techcommunity.microsoft.com/t5/azure-tools/announcing-az-predictor-preview-2/ba-p/2197744 

 

Note: If you are using Windows PowerShell (5.1), you can install PowerShell 7.1 side by side. More information on this page: https://docs.microsoft.com/en-us/powershell/scripting/install/migrating-from-windows-powershell-51-t....

 

To provide the suggestions to PSReadline, Az Predictor makes regular calls to an API that will return suggested commands based on the session’s context.

The full functionality of Az Predictor requires internet access. We are planning to add support for environments with limited or no network capacity (for example, mobile connectivity or Wi-Fi in airplanes).

Once loaded, Az Predictor will identify the value or variable used for resource group name and location and use it in the subsequent suggestions. When you start typing a command, Az Predictor will search for the cmdlet that you are the most likely to use based on the session’s context. As you type, we refine the search and display more accurate examples to use.

Az Predictor understands parametersets, required, and optional parameters and leverages the Azure PowerShell examples in the reference documentation as suggestions. The suggestions will then be adjusted based on the possible parametersets and parameters that have already been typed

The code of Azure PowerShell, including this module, is opensource. If you find a bug and want to contribute, you can submit an issue or open a PR (pull request).

 

Getting started with preview 2

If you have installed the first preview:

  • Close all your PowerShell sessions
  • Remove the Az.Tools.Predictor module

To install the second preview of Az.Tools.Predictor follow these steps:

  1. Install PowerShell 7.2-preview 3
    Go to: https://github.com/PowerShell/PowerShell/releases/tag/v7.2.0-preview.3
    Select the binary that corresponds to your platform in the assets list.

  2. Launch PowerShell 7.2-preview 3 and Install PSReadline 2.2 beta 2 with the following:
    Install-Module -Name PSReadLine -AllowPrerelease
    More details about PSReadline: https://www.powershellgallery.com/packages/PSReadLine/2.2.0-beta2

  3. Install Az.Tools.Predictor preview 2
    Install-module -name Az.Tools.Predictor -RequiredVersion 0.2.0
    More details about Az.Tools.Predictor: https://www.powershellgallery.com/packages/Az.Tools.Predictor/0.2.0

  4. Enable Az Predictor
    Enable-AzPredictor -AllSession
    This command will enable Az Predictor in all further sessions of the current user.

 

March 9, 2021 update: The second preview of Az.Tools.Predictor requires PowerShell 7.2-preview3 and PS readline 2.2.0-beta2. More information on the announcement https://techcommunity.microsoft.com/t5/azure-tools/announcing-az-predictor-preview-2/ba-p/2197744 

 

Log issues, feature requests, or design changes on GitHub: https://github.com/Azure/azure-powershell/issues

 

We are at the early stage of the module and want to hear from you; please take a moment to fill this brief survey: http://aka.ms/azpredictorsurvey

 

Tell us about the following:

  • Are the predictions useful?
  • Would you like to have Az Predictor turned on by default?
  • Which mode is the most valuable?

 

7 Comments
Co-Authors
Version history
Last update:
‎Apr 21 2021 09:55 AM
Updated by: