MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.47k forks source link

MMA removal tool LogAnalyticsAgentUninstallUtilityScript.ps1 throws error when running GetInventory on Arc machines #124259

Open Kat-nya opened 2 months ago

Kat-nya commented 2 months ago

Link to the document - MMA Discovery and Removal Utility - Azure Monitor | Microsoft Learn

When running .\LogAnalyticsAgentUninstallUtilityScript.ps1 GetInventory, the following error messages are printed:

ERROR: the following arguments are required: --resource-group/-g

Cannot get the Arc server list
Transcript stopped, output file is C:\...\LogAnalyticsAgentUninstallUtilityScriptLog.log

The line causing this error is as following: https://github.com/MicrosoftDocs/azure-docs/blob/155f2c963fb4fb46026dbf5a83c36bd7f6abae1e/articles/azure-monitor/agents/azure-monitor-agent-mma-removal-tool.md?plain=1#L78

According to the AzCli docs, it seems that --resource-group ... is required when querying for a list of Arc machines with az connectedmachine list. This is not the case for az vm list or az vmss list, which makes argument --resource-group optional thus does not produce the same error.

The AzPowershell equivalent Get-AzConnectedMachine does not require specifying the resource group to list all Arc-enabled VMs. Maybe this could be an AzCli issue?

Many thanks

Document Details

ms.topic: conceptual author: guywi-ms ms.author: @guywi-ms ms.reviewer: jeffwo ms.date: 07/30/2024

ManoharLakkoju-MSFT commented 2 months ago

@Kat-nya Thanks for your feedback! We will investigate and update as appropriate.

TPavanBalaji commented 2 months ago

@Kat-nya For an issue like this, I'd recommend you reach support team create a support ticket since the support team will be able to respond much more quickly and have a conversation with you to figure out what could be going on.

TPavanBalaji commented 2 months ago

@Kat-nya Thanks for your feedback and your contribution to Azure docs. Feedback for this repository is moving away from GitHub to a system specific to the Microsoft Learn platform. Issues for this repository will soon be disabled, and additional comments from GitHub will no longer be possible. However, we are now tracking and triaging this issue in the new feedback system. To learn more about our feedback systems, please see Provide feedback for Microsoft Learn content.

TPavanBalaji commented 2 months ago

@Kat-nya We are going to close this thread, if there are any further questions regarding the documentation, please tag me in your reply and we will be happy to continue the conversation.

JeffreyWolford commented 2 months ago

We looked at this and it seems the az connectedmachine list command will work without specifying the resource group. I tested it and it worked on my machine.

To double check this, can you try running this on powershell on your machine and see If it returned any errors

az connectedmachine list --query "[].{ResourceId:id, ResourceGroup:resourceGroup, ServerName:name}" | ConvertFrom-Json

Kat-nya commented 2 months ago

Thanks for your reply. I attempted to run the above commands on both my local machine and the Cloud Shell, both of which printed the error messages below:

PS /home/kat> az connectedmachine list --query "[].{ResourceId:id, ResourceGroup:resourceGroup, ServerName:name}" | ConvertFrom-Json
ERROR: the following arguments are required: --resource-group/-g

Examples from AI knowledge base:
az connectedmachine list --resource-group myResourceGroup az connectedmachine list
Sample command for list

https://aka.ms/cli_ref
Read more about the command in reference docs
A more verbose output (with the `--debug` flag on) is shown as below: ```bash kat [ ~ ]$ az connectedmachine list --debug --query "[].{ResourceId:id, ResourceGroup:resourceGroup, ServerName:name}" cli.knack.cli: Command arguments: ['connectedmachine', 'list', '--debug', '--query', '[].{ResourceId:id, ResourceGroup:resourceGroup, ServerName:name}'] cli.knack.cli: __init__ debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'connectedmachine': ['azext_connectedmachine'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: ai-examples 0.162 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples cli.azure.cli.core: connectedmachine 0.149 7 14 /home/kat/.azure/cliextensions/connectedmachine cli.azure.cli.core: Total (2) 0.311 8 15 cli.azure.cli.core: Loaded 8 groups, 15 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : connectedmachine list cli.azure.cli.core: Command table: connectedmachine list cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/kat/.azure/commands/2024-09-04.01-53-20.connectedmachine_list.5469.log'. az_command_data_logger: command args: connectedmachine list --debug --query {} cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7f4a1c557e50>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7f4a1c57de50>, .add_cache_arguments at 0x7f4a1c519d30>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443 urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22connectedmachine+list%22%2C+%22parameters%22%3A+%22--query%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.63.0%22%2C+%22errorType%22%3A+%22MissingRequiredParameters%22%2C+%22correlationId%22%3A+%22[correlationId redacted]%22%2C+%22subscriptionId%22%3A+%22[subscriptionID redacted]%22%2C+%22eventId%22%3A+%22[eventID redacted]%22%7D HTTP/1.1" 200 None cli.azure.cli.core.azclierror: NoneType: None cli.azure.cli.core.azclierror: the following arguments are required: --resource-group/-g az_command_data_logger: the following arguments are required: --resource-group/-g Examples from AI knowledge base: az connectedmachine list --resource-group myResourceGroup az connectedmachine list Sample command for list https://aka.ms/cli_ref Read more about the command in reference docs cli.knack.cli: Event: Cli.PostExecute [] az_command_data_logger: exit code: 2 cli.__main__: Command ran in 0.678 seconds (init: 0.164, invoke: 0.514) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 4033 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/__init__.py /home/kat/.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process. ```
TPavanBalaji commented 2 months ago

@Kat-nya Thank you for bringing this to our attention. I've delegated this to content author, who will review it and offer their insightful opinions.