Query request invalid

Diptesh Kumar 101 Reputation points
2024-05-17T09:49:02.72+00:00

I am trying to execute following query from resource graph explorer and giving error as below

Resources
| where type =~ 'microsoft.compute/virtualmachines'
| project id, type, maintenanceConfigurationId = tostring(coalesce(properties.maintenanceConfigurationId, ''))
| where isnotempty(maintenanceConfigurationId)


Please provide below info when asking for support: timestamp = 2024-05-17T09:45:05.8891707Z, correlationId = 84dd3eda-0de6-4a81-9d74-03c29a31884c. (Code:BadRequest) Details: Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying. (Code:InvalidQuery) ParserFailure (Code:ParserFailure)

Please suggest

Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
319 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. tbgangav-MSFT 10,416 Reputation points
    2024-05-17T16:36:42.93+00:00

    Hi @Diptesh Kumar ,

    It might just be an issue with case-sensitive "Resources" versus "resources". Try the lower-case "resources" table name.

    User's image


  2. Sohail Ali 320 Reputation points Microsoft Employee
    2024-05-28T06:57:01.22+00:00

    @Diptesh Kumar I am assuming you want to get the machines which are not attached to any machine configuration, below is the query which you can exute adding the correct values within it and would provide you the results

    resources

    | where type == 'microsoft.compute/virtualmachines'

    | extend vmId = tolower(id)

    | join kind=leftouter (

        maintenanceresources

        | where type == 'microsoft.maintenance/configurationassignments'

        | extend resourceId = tolower(properties.resourceId)

        | project resourceId

    ) on $left.vmId == $right.resourceId

    | where resourceId == ""

    | project vmId

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.