[BUG] QueryResourceAsync causing error if used with TimeRange of QueryTimeRange(Datetime, Datetime) #40047
Closed
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
This issue points to a problem in the data-plane of the library.Monitor, Monitor Ingestion, Monitor QueryIssues that are reported by GitHub users external to the Azure organization.Workflow: This issue needs attention from Azure service team or SDK teamThe issue doesn't require a change to the product in order to be resolved. Most issues start as that