Azure-sdk-for-net: [BUG] Resource graph query throws Microsoft.Azure.Management.ResourceGraph.Models.ErrorResponseException

Created on 16 Jun 2020  路  3Comments  路  Source: Azure/azure-sdk-for-net

Describe the bug
Calling resourceGraphClient.Resources throws ErrorResponseException.

Expected behavior
No exception should be thrown. I can run the same query from PowerShell and it works.

Search-AzGraph -Query 'Resources | project name, type | limit 5'

Actual behavior (include Exception or Stack Trace)
Stach trace:

Microsoft.Azure.Management.ResourceGraph.Models.ErrorResponseException
  HResult=0x80131500
  Message=Operation returned an invalid status code 'BadRequest'
  Source=Microsoft.Azure.Management.ResourceGraph
  StackTrace:
   at Microsoft.Azure.Management.ResourceGraph.ResourceGraphClient.<ResourcesWithHttpMessagesAsync>d__48.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Azure.Management.ResourceGraph.ResourceGraphClientExtensions.<ResourcesAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Azure.Management.ResourceGraph.ResourceGraphClientExtensions.Resources(IResourceGraphClient operations, QueryRequest query)
   at ConsoleAppAzureServices.Program.<RunResourceGraphQuery>d__1.MoveNext() in C:\Users\N16263.NEWDAY\source\repos\linuxvm-msi-keyvault-arm-dotnet\ConsoleAppAzureServices\ConsoleAppAzureServices\Program.cs:line 38

  This exception was originally thrown at this call stack:
    [External Code]
    ConsoleAppAzureServices.Program.RunResourceGraphQuery(Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider) in Program.cs

To Reproduce
Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Unzip ConsoleAppAzureServices.zip
  2. Build & debug

Environment:
Details on attached csproj.

Graph Mgmt customer-reported needs-team-attention question

All 3 comments

Thanks for reporting the issue. I will follow up.

Hi @realrubberduckdev your sample code seemed to have misspelled "Resources". Fixed it and I got the correct response.

Annotation 2020-06-17 141214

Closing the issue for now. Feel free to reopen if you find it not working.

@isra-fel Wow! Thanks a lot, it works for me now and apologies for this bug, unsure how such a small mistake went unnoticed.

Was this page helpful?
0 / 5 - 0 ratings