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.37k stars 4.79k forks source link

[BUG] Not able to fetch Hybrid Connections for App Service Plan #34745

Closed JagodaMika closed 1 year ago

JagodaMika commented 1 year ago

Library name and version

Azure.ResourceManager.AppService v1.0.1

Describe the bug

Not able to retrieve all Hybrid Connections in use in given App Service plan.

Expected behavior

Being able to get a list of Hybrid Connections from App Service plan

Actual behavior

When trying to iterate over a result from method GetHybridConnectionRelaysAsync() I receive an error: Invalid URI: The format of the URI could not be determined.

at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString) at Azure.ResourceManager.AppService.HybridConnectionData.DeserializeHybridConnectionData(JsonElement element) at Azure.Core.PageableHelpers.PageableImplementation`1.d__17.MoveNext()

Reproduction Steps

  1. Get appServicePlan from ResourceGroup - ResourceGroup.GetAppServicePlanAsync();
  2. Invoke GetHybridConnectionRelaysAsync() on returned appServicePlan
  3. Try to iterate over result (according to Microsoft documentation - https://learn.microsoft.com/pl-pl/dotnet/api/azure.asyncpageable-1?view=azure-dotnet

Environment

No response

jsquire commented 1 year ago

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

ArcturusZhang commented 1 year ago

Hi @JagodaMika This is probably caused by the inconsistent format on one of the properties on this HybridConnectionData, highly probable to be this property which says it is an "ArmUri" but actually means an arm resource id instead of Uri.

To confirm, could you please provide some log around that request? You could have the raw request and response by adding this listener before you run the problematic code:

using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger(System.Diagnostics.Tracing.EventLevel.Verbose);

And add this ClientOptions when you are constructing the ArmClient instance

new ArmClientOptions()
{
    Diagnostics = {
        IsLoggingContentEnabled = true
    }
}

By doing these two, you should be able to see the request log and could you please paste the response of request GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionRelays here so that we could confirm the root cause of this issue?

ArcturusZhang commented 1 year ago

OK never mind, I am able to reproduce the response and it looks like this:

{
  "value": [
    {
      "id": "/subscriptions/{subId}/resourceGroups/arcturus-test/providers/Microsoft.Web/serverfarms/arcturus-plan2/hybridConnectionNamespaces/arcturus-servicebus/relays/arcturusConnection",
      "name": "arcturusConnection",
      "type": "Microsoft.Web/serverfarms/hybridConnectionNamespaces/relays",
      "location": "East US",
      "properties": {
        "serviceBusNamespace": "arcturus-servicebus",
        "relayName": "arcturusConnection",
        "relayArmUri": "/subscriptions/{subId}/resourceGroups/arcturus-test/providers/Microsoft.Relay/namespaces/arcturus-servicebus/HybridConnections/arcturusConnection",
        "hostname": "arcturusHost",
        "port": 999,
        "sendKeyName": "defaultSender",
        "sendKeyValue": "",
        "serviceBusSuffix": ".servicebus.windows.net"
      }
    }
  ],
  "nextLink": null,
  "id": null
}

We will come up to a fix very soon.

JagodaMika commented 1 year ago

Great, thanks!