install oms extension on linux, CLI ERROR

Arif Usman 421 Reputation points
2022-08-03T15:37:19.467+00:00

FOLKS: I want to install OMS extension on Linux VMs using Azure CLI and for this I am using below code. but getting error
Failed to parse JSON: {workspaceKey: "efasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf=="}
Error detail: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
here is my code: (i replace original workspacekey, workspaceid,rg, vm name)
az vm extension set --name OmsAgentForLinux --publisher Microsoft.EnterpriseCloud.Monitoring --version 1.* --no-auto-upgrade --no-wait --force-update --protected-settings '{"workspaceKey": "efasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf=="}' --settings '{"workspaceId":"1111111-1111-1111-b111-00fb111111111"}' --resource-group "myresourcegroup-rg" --vm-name "MYVM03"

227776-oms-cli-error.png

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,106 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. KarishmaTiwari-MSFT 18,352 Reputation points Microsoft Employee
    2022-08-04T02:12:51.807+00:00

    @Arif Usman You can add --debug parameter to Azure CLI command to get further details on the same or you can use --help to see the example commands.

    One of the suggestions based on the stack overflow posts below, that worked is escaping the quotes with \"
    Please try that and let me know if you are still seeing issues.

    Here are few other threads on Stack overflow for the same issue that might help:

    https://stackoverflow.com/questions/60819537/expecting-property-name-enclosed-in-double-quotes-when-passing-json-string-to-az

    https://stackoverflow.com/questions/43119958/azure-cli-2-how-to-provide-parameters-in-az-group-deployment-create-command

    https://stackoverflow.com/questions/58100088/create-azure-vm-with-artifact-switch

    0 comments No comments

  2. Arif Usman 421 Reputation points
    2022-08-04T14:32:53.787+00:00

    @KarishmaTiwari-MSFT thanks for your reply.
    This is what i have tried.

    ======================================================================================================

    $logsSetting = '{"workspaceKey": "efasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf=="}'.Replace("'",'\"')
    $metricsSetting = '{"workspaceId":"1111111-1111-1111-b111-00fb111111111"}'.Replace("'",'\"')

    az vm extension set --name OmsAgentForLinux `  
        --publisher Microsoft.EnterpriseCloud.Monitoring --version 1.* --no-auto-upgrade --no-wait --force-update `  
        --protected-settings $logsSetting `  
        --settings $metricsSetting `  
        --resource-group "myresourcegroup-rg" `  
        --vm-name "MYVM03"  
    

    ==========================================================================================================

    this is the error i am getting:

    Error detail: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
    The JSON may have been parsed by the shell. See https://learn.microsoft.com/cli/azure/use-cli-effectively#use-quotation-marks-in-arguments