diff --git a/Services/AzureManagementAdapter/AzureManagementAdapter.cs b/Services/AzureManagementAdapter/AzureManagementAdapter.cs index 2b116054..72debf0e 100644 --- a/Services/AzureManagementAdapter/AzureManagementAdapter.cs +++ b/Services/AzureManagementAdapter/AzureManagementAdapter.cs @@ -84,7 +84,17 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.AzureManagement this.ThrowIfError(response); - return JsonConvert.DeserializeObject(response.Content); + var metricsResponseList = JsonConvert.DeserializeObject(response.Content); + + foreach (var responseModel in metricsResponseList.Responses) + { + if (responseModel.Content.Error != null) + { + throw new ExternalDependencyException(responseModel.Content.Error.Message); + } + } + + return metricsResponseList; } private bool AccessTokenIsNullOrEmpty() diff --git a/Services/AzureManagementAdapter/MetricsModel.cs b/Services/AzureManagementAdapter/MetricsModel.cs index 293c583c..d1819a0d 100644 --- a/Services/AzureManagementAdapter/MetricsModel.cs +++ b/Services/AzureManagementAdapter/MetricsModel.cs @@ -33,6 +33,18 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.AzureManagement [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } + + [JsonProperty("error", NullValueHandling = NullValueHandling.Ignore)] + public MetricContentErrorModel Error { get; set; } + } + + public class MetricContentErrorModel + { + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("message")] + public string Message { get; set; } } public class MetricValueModel diff --git a/WebService/v1/Models/SimulationApiModel/SimulationApiModel.cs b/WebService/v1/Models/SimulationApiModel/SimulationApiModel.cs index b868aa34..e57abea0 100644 --- a/WebService/v1/Models/SimulationApiModel/SimulationApiModel.cs +++ b/WebService/v1/Models/SimulationApiModel/SimulationApiModel.cs @@ -157,9 +157,9 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Models.Sim Running = value.ShouldBeRunning, ActiveNow = value.IsActiveNow, DeleteDevicesWhenSimulationEnds = value.DeleteDevicesWhenSimulationEnds, - StartTime = value.StartTime.ToString(), - EndTime = value.EndTime.ToString(), - StoppedTime = value.StoppedTime.ToString(), + StartTime = value.StartTime?.ToString(DATE_FORMAT), + EndTime = value.EndTime?.ToString(DATE_FORMAT), + StoppedTime = value.StoppedTime?.ToString(DATE_FORMAT), IotHubs = new List() };