-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Description
Attempting to use Search-AzGraph and when using the -Include parameter with either DisplayName or DisplayNames generates a query parser error.
When checking the values expected for the Enum:
❯❯ [System.Enum]::GetValues([Microsoft.Azure.Commands.ResourceGraph.Utilities.IncludeOptionsEnum])
None
DisplayNamesExample 3 & 4 in the documentation shows the value as DisplayName rather than the plural DisplayNames that the enum values show.
The -Include parameter section of the docs doesn't have the parameter listed at all but not sure if this is just because the module is still not a v1 release.
There was discussion around the docs being fixed during generation #10069 (comment) but that mustn't have been happened.
I can work around this for the time being by looping through the subscriptions. I can open a PR to fix the docs once this works but the parameter should technically be singular so that
Steps to reproduce
$searchAzGraphSplat = @{
Query = "Resources | where type =~ 'Microsoft.ClassicCompute/virtualMachines'"
First = 5000
Subscription = $subscriptions
}
$classicVMs = Search-AzGraph @searchAzGraphSplat -Include DisplayNamesThis gives me the following error:
Search-AzGraph: {
"error": {
"code": "BadRequest",
"message": "Please provide below info when asking for support: timestamp = 2020-10-01T10:39:57.7870485Z, correlationId = 68b010ab-3b9a-48e4-85b4-66705309dab9.",
"details": [
{
"code": "InvalidQuery",
"message": "Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying."
},
{
"code": "ParserFailure",
"message": "ParserFailure",
"line": 1,
"characterPositionInLine": 3015,
"token": "Resources"
}
]
}
}Environment data
Name Value
---- -----
PSVersion 7.1.0-preview.5
PSEdition Core
GitCommitId 7.1.0-preview.5
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 18 20:50:10 PDT 2020; root:xnu-4903.278.43~1/REL…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Module versions
❯❯ Get-Module -ListAvailable -Name Az.ResourceGraph, Az.Resources, Az.Accounts Directory: /Users/brett.miller/.local/share/powershell/Modules ModuleType Version PreRelease Name PSEdition ExportedCommands ---------- ------- ---------- ---- --------- ---------------- Script 1.9.4 Az.Accounts Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave… Script 0.7.7 Az.ResourceGraph Core,Desk Search-AzGraph Script 2.5.1 Az.Resources Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, G…Debug output
Debug Output
DEBUG: 14:49:52 - SearchAzureRmGraph begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 14:49:52 - using account id 'brett.miller@domain.com'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'brett.miller@domain.com', environment: 'AzureCloud', tenant: '78113ca0-d693-4fc9-9269-292d2f07f5ae'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '78113ca0-d693-4fc9-9269-292d2f07f5ae', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/78113ca0-d693-4fc9-9269-292d2f07f5ae/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '78113ca0-d693-4fc9-9269-292d2f07f5ae', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9181740Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9182090Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9182310Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: === Token Acquisition started:
CacheType: null
Authentication Target: User
, Authority Host: login.microsoftonline.com
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9182400Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: === Token Acquisition started:
Authority: https://login.microsoftonline.com/78113ca0-d693-4fc9-9269-292d2f07f5ae/
Resource: https://management.core.windows.net/
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
CacheType: null
Authentication Target: User
DEBUG: [ADAL]: Verbose: 2020-10-01T13:49:52.9183290Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Verbose: 2020-10-01T13:49:52.9183370Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9202920Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 18 items to token cache.
DEBUG: [ADAL]: Verbose: 2020-10-01T13:49:52.9203990Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Verbose: 2020-10-01T13:49:52.9204290Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205060Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205160Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205780Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: 57.19969045 minutes left until token in cache expires
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205830Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: 57.19969045 minutes left until token in cache expires
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205880Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9205920Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9206470Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 01/10/2020 14:47:04 +00:00
DEBUG: [ADAL]: Information: 2020-10-01T13:49:52.9206530Z: 3d28199e-966a-4850-998d-174cfd8c785b - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 01/10/2020 14:47:04 +00:00Access Token Hash: jduZWhbS1bJ/yPANrss8Kj86P0OSAgdxqrPDWwKA61Y=
User id: 09501ef4-6b7f-477f-99e4-a28cae2d074c
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '10/01/2020 14:47:04 +00:00', MultipleResource? 'True', Tenant: '78113ca0-d693-4fc9-9269-292d2f07f5ae', UserId: 'brett.miller@domain.com'
DEBUG: [Common.Authentication]: User info for token DisplayId: 'brett.miller@domain.com', Name: Brett Miller, IdProvider: 'https://sts.windows.net/3e32dd7c-41f6-492d-a1a3-c58eb02cf4f8/', Uid: '09501ef4-6b7f-477f-99e4-a28cae2d074c'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '10/01/2020 14:47:04 +00:00' Comparing to '10/01/2020 13:49:52 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:57:11.9765540'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2019-04-01
Headers:
x-ms-client-request-id : 8171729f-5106-4daf-8340-e4147a145641
Accept-Language : en-US
Body:
{
"subscriptions": [
"9278291a-8875-40c5-979f-be8cae3e8d37",
"ab71b169-0802-4653-aba5-efb2fa9f652e"
],
"query": "extend subscriptionDisplayName=case($subscriptions)| Resources | where type =~ 'Microsoft.ClassicCompute/virtualMachines'",
"options": {
"$top": 1000,
"$skip": 0,
"resultFormat": "objectArray"
}
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Cache-Control : no-cache
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-tenant-resource-requests: 14
x-ms-user-quota-remaining : 14
x-ms-user-quota-resets-after : 00:00:05
Server : Kestrel
x-ms-ratelimit-remaining-tenant-reads: 11999
x-ms-request-id : 2383f0e8-179c-4624-b123-13ce8bbd9580
x-ms-correlation-request-id : 2383f0e8-179c-4624-b123-13ce8bbd9580
x-ms-routing-request-id : NORTHEUROPE:20201001T134953Z:2383f0e8-179c-4624-b123-13ce8bbd9580
X-Content-Type-Options : nosniff
Date : Thu, 01 Oct 2020 13:49:52 GMT
Body:
{
"error": {
"code": "BadRequest",
"message": "Please provide below info when asking for support: timestamp = 2020-10-01T13:49:53.4744329Z, correlationId = 2383f0e8-179c-4624-b123-13ce8bbd9580.",
"details": [
{
"code": "InvalidQuery",
"message": "Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying."
},
{
"code": "ParserFailure",
"message": "ParserFailure",
"line": 1,
"characterPositionInLine": 3015,
"token": "Resources"
}
]
}
}