Skip to content

[BUG] QueryResourceAsync causing error if used with TimeRange of QueryTimeRange(Datetime, Datetime) #40047

Closed
@egressyk

Description

Library name and version

Azure.Monitor.Query 1.2.0

Describe the bug

Using MetricsQueryClient.QueryResourceAsync() with option TimeRange of QueryTimeRange(startTime, endTime) causes and error, opposed to TimeRange of QueryTimeRange(duration).

Exception or Stack Trace
'Detected invalid time interval input: 2023-11-15T10:12:25.4174057 01:00/2023-11-15T11:12:25.4174057 01:00, supported Iso 8601 time interval format: (Datetime/Datetime, Datetime/Duration, Duration/Datetime, Duration)
Status: 400 (Bad Request)
ErrorCode: BadRequest

Expected behavior

Receive the same result as if used with

var options = new MetricsQueryOptions
{
    Aggregations = { MetricAggregationType.Average },
    Granularity = TimeSpan.FromMinutes(1),
    TimeRange = new QueryTimeRange(TimeSpan.FromHours(1))
};

Actual behavior

Receiving Status: 400 (Bad Request)

Reproduction Steps

var metricsQueryClient = new MetricsQueryClient(new DefaultAzureCredential());
var endTime = DateTimeOffset.Now;
var startTime = endTime.AddHours(-1);

var resourceId = <someAppServiceResourceId>;
var metricsNames  = new List<string> { "HttpResponseTime" };
var options = new MetricsQueryOptions
{
    Aggregations = { MetricAggregationType.Average },
    Granularity = TimeSpan.FromMinutes(1),
    TimeRange = new QueryTimeRange(startTime, endTime)
};

var result = await metricsQueryClient.QueryResourceAsync(resourceId, metricsNames, options);

Environment

  • Windows 10

  • VisualStudio 17.6.4

  • .NET 7.0

  • Azure.Monitor.Query 1.2.0

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.MonitorMonitor, Monitor Ingestion, Monitor Querycustomer-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