Starting with Az v8.2.0 we are providing suggestions when PowerShell cannot find a command, as shown in the animated GIF. We not only detect typos, but also many other use cases such as when the required module is not installed.
Azure PowerShell gives a suggestion against a typo in the command name.
For typos, Azure PowerShell tries to find commands that are similar to the input. If any are found, the candidates will be displayed as recommendations.
To do this, we maintain a static table of mappings from all the commands to modules. The table ships with each release of Az.Accounts module. Because of this, no network requests are involved in the recommendation process. The file to store the mappings takes around 300 KB of disk space after installation. But the size of the package is increased by merely 60 KB.
Module not Installed or Outdated
One of the biggest reason a command cannot be found is that the corresponding module is not installed. It could be the module is in preview, so it is not included in the Az rollup module. Or the modules were installed separately rather than via the rollup module. A similar case is that an older version of the module is installed but the command is introduced in a newer version. In both cases, Azure PowerShell tries to figure out which Az module needs to be installed or updated. Suggestions are displayed accordingly.
Azure PowerShell suggests user to install the module when a command is not recognized.
Breaking changes are sometimes inevitable. To reduce the effort of upgrading, Azure PowerShell displays warning messages for the upcoming breaking changes. We also created migration guides for each major release. Now, leveraging this feature, we have added real-time inline suggestions for deprecated commands. In such case, Azure PowerShell displays a message to explain the reason and guide user to the migration documents.
Azure PowerShell warns about deprecated commands.
Note that the message is only for commands that have been deprecated. There is another system to preannounce upcoming breaking changes, and that will not be affected.
Quick response. In our test, the worst-case end-to-end time is no longer than 150 milliseconds. The latency introduced by intelligent recommendation was not noticeable.
Compatibility. Both PowerShell 7 and Windows PowerShell are supported.
The intelligent recommendation system is triggered only when the command matches Azure PowerShell pattern (“*-Az*”) due to performance considerations.
To enable the feature, the Az.Accounts module needs to be imported.
This feature is already available. Feel free to share your experience in the comments below or GitHub discussions. We welcome your feedbacks!