Skip to content

[BUG] GetElasticMonitorResources() throws UriFormatException #50974

@Sebbs128

Description

@Sebbs128

Library name and version

Azure.ResourceManager.Elastic 1.0.0

Describe the bug

Calling ArmClient.GetElasticMonitorResource().Get() or SubscriptionResource.GetElasticMonitorResources() (and their async variants) throw a UriFormatException "Invalid URI: The format of the URI could not be determined".

I believe this is probably due to ElasticCloudDeployment.KibanaSsoUri being of type Uri, however the value being returned (e.g. from az elastic monitor list) is a relative url, which causes the exception when trying to deserialize to Uri

Expected behavior

Methods should not throw an exception and should successfully return the ElasticMonitorResource/ElasticMonitorResourceCollection

Actual behavior

Throws UriFormatException "Invalid URI: The format of the URI could not be determined."

Stack trace:

   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Azure.ResourceManager.Elastic.Models.ElasticCloudDeployment.DeserializeElasticCloudDeployment(JsonElement element, ModelReaderWriterOptions options)
   at Azure.ResourceManager.Elastic.Models.ElasticCloudProperties.DeserializeElasticCloudProperties(JsonElement element, ModelReaderWriterOptions options)
   at Azure.ResourceManager.Elastic.Models.ElasticMonitorProperties.DeserializeElasticMonitorProperties(JsonElement element, ModelReaderWriterOptions options)
   at Azure.ResourceManager.Elastic.ElasticMonitorData.DeserializeElasticMonitorData(JsonElement element, ModelReaderWriterOptions options)
   at Azure.ResourceManager.Elastic.MonitorsRestOperations.Get(String subscriptionId, String resourceGroupName, String monitorName, CancellationToken cancellationToken)
   at Azure.ResourceManager.Elastic.ElasticMonitorResource.Get(CancellationToken cancellationToken)
   at Program.<<Initialize>>d__0.MoveNext() in :line 11
--- End of stack trace from previous location ---
   at Program.<Main>()

Reproduction Steps

using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Elastic;

var resourceId = ResourceIdentifier.Parse("..."); // insert your resource id here

var client = new ArmClient(new DefaultAzureCredential());

client.GetElasticMonitorResource(resourceId).Get();

Environment

dotnet --info
.NET SDK:
 Version:           9.0.301
 Commit:            a596cd22e2
 Workload version:  9.0.300-manifests.e42facbb
 MSBuild version:   17.14.5+edd3bbf37

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.301\

Visual Studio 17.14.7

Metadata

Metadata

Assignees

Labels

ElasticMgmtThis issue is related to a management package.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions