Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[BUG] ApplicationInsightsManagementClient throws exception on WebTestLocations.ListAsync #16316

Closed erik-hooper closed 2 years ago

erik-hooper commented 4 years ago

Describe the bug Unable to deserialize the response ApplicationInsightsManagementClient.WebTestLocations.ListAsync

Expected behavior I would not expect an errors

Actual behavior (include Exception or Stack Trace) Microsoft.Rest.SerializationException HResult=0x80131500 Message=Unable to deserialize the response. Source=Microsoft.Azure.Management.ApplicationInsights StackTrace: at Microsoft.Azure.Management.ApplicationInsights.Management.WebTestLocationsOperations.d5.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Management.ApplicationInsights.Management.WebTestLocationsOperationsExtensions.d1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at AppInsightsApi.Program.

d__0.MoveNext() in C:\Users\sesa220553\source\repos\AppInsightsApi\AppInsightsApi\Program.cs:line 55

This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Microsoft.Azure.Management.ApplicationInsights.Management.Models.Page1`1[Microsoft.Azure.Management.ApplicationInsights.Management.Models.ApplicationInsightsComponentWebTestLocation]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path '', line 1, position 1.

It does return an expected response just seems like the sdk can't deal with it. The response is similar to [{"DisplayName":"North Central US","Tag":"us-il-ch1-azr"},{"DisplayName":"West Europe","Tag":"emea-nl-ams-azr"},{"DisplayName":"Southeast Asia","Tag":"apac-sg-sin-azr"},{"DisplayName":"West US","Tag":"us-ca-sjc-azr"},{"DisplayName":"South Central US","Tag":"us-tx-sn1-azr"},{"DisplayName":"East US","Tag":"us-va-ash-azr"},{"DisplayName":"East Asia","Tag":"apac-hk-hkn-azr"},{"DisplayName":"North Europe","Tag":"emea-gb-db3-azr"},{"DisplayName":"Japan East","Tag":"apac-jp-kaw-edge"},{"DisplayName":"Australia East","Tag":"emea-au-syd-edge"},{"DisplayName":"France Central (Formerly France South)","Tag":"emea-ch-zrh-edge"},{"DisplayName":"France Central","Tag":"emea-fr-pra-edge"},{"DisplayName":"UK South","Tag":"emea-ru-msa-edge"},{"DisplayName":"UK West","Tag":"emea-se-sto-edge"},{"DisplayName":"Brazil South","Tag":"latam-br-gru-edge"},{"DisplayName":"Central US","Tag":"us-fl-mia-edge"}]

I can get this info by using ServiceClientTracing and intercepting the response and calling response.Content.ReadAsStringAsync().Result.

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

  1. Create new ApplicationInsightsManagementClient
    var creds = SdkContext.AzureCredentialsFactory.FromServicePrincipal(_azureClientId, _azureClientSecret, _directoryId, _azureGlobalCloud);
    AppInsights = new ApplicationInsightsManagementClient(creds){SubscriptionId = _subscriptionId};
    // Will throw on the below line
    var locations = await AppInsights.WebTestLocations.ListAsync("common", "MyAppinsights Instance");

    Environment:

    • Microsoft.Azure.Management.ApplicationInsight 0.3.0-preview
    • Net core 3.1 or Framework 4.8
    • IDE and version : Visual Studio 16.7.2
ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @azmonapplicationinsights.

jsquire commented 4 years ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

ghost commented 3 years ago

Hi @erik-hooper. Thank you, for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

erik-hooper commented 3 years ago

Is there any update on this?

ghost commented 2 years ago

Hi @erik-hooper. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 2 years ago

Hi @erik-hooper, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.