如何在Azure CLI启用az security assessment及解决扩展缺失问题
I’ve run into this exact issue before—here’s how to get the az security assessment commands working properly:
Step 1: Update your Azure CLI first
Chances are, your Azure CLI version is outdated and doesn’t include the assessment subcommand in the core az security group. Updating to the latest version will often resolve this automatically. Run:
az upgrade
This command updates both the CLI itself and any installed extensions to their latest versions. Once it finishes, try running az security assessment --help—if the command now shows up, you’re good to go!
Step 2: Install the security extension (if updating isn’t enough)
If updating the CLI doesn’t add the assessment commands, you’ll need to install the dedicated security extension. This extension adds extra security-related commands that aren’t in the core CLI yet. Install it with:
az extension add --name security
To confirm the extension was installed correctly, run:
az extension list --query "[].name"
You should see security in the output list. Now your az security assessment commands should work as expected.
Step 3: Double-check permissions and subscription
If you still have issues, make sure you’re logged into the right Azure subscription with az account show, and that your account has permissions like Security Reader or Owner to access security assessments. Without the right permissions, even the correct commands will fail.
内容的提问来源于stack exchange,提问作者Jason

