From bf15555062dd798dd236b45be59e7ff6bded9776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Calder=C3=B3n=5FMeza?= Date: Tue, 24 Mar 2015 12:51:00 -0700 Subject: [PATCH 1/5] BUG: 3539827 Create Powershell Commandlets for Insights Metrics --- .../Commands.Insights.Test.csproj | 15 + .../FormatMetricsAsTableCommandTests.cs | 95 + .../GetMetricDefinitionsCommandTests.cs | 82 + .../Metrics/GetMetricsCommandTests.cs | 112 + .../ScenarioTests/MetricsTests.cs | 36 + .../ScenarioTests/MetricsTests.ps1 | 60 + .../TestGetMetricDefinitions.json | 38 + .../TestGetMetrics.json | 64 + .../Commands.Insights.Test/Utilities.cs | 30 + .../Alerts/AddAlertRuleCommandBase.cs | 15 +- .../Alerts/GetAlertRuleCommand.cs | 29 +- .../Alerts/RemoveAlertRuleCommand.cs | 13 +- .../Autoscale/AddAutoscaleSettingCommand.cs | 15 +- .../Autoscale/GetAutoscaleSettingCommand.cs | 27 +- .../RemoveAutoscaleSettingCommand.cs | 13 +- .../Commands.Insights.csproj | 18 +- .../Commands.Insights/EventCmdletBase.cs | 49 +- .../InsightsClientCmdletBase.cs | 4 +- .../Commands.Insights/InsightsCmdletBase.cs | 45 + .../Commands.Insights/ManagementCmdletBase.cs | 5 +- .../Metrics/FormatMetricsAsTableCommand.cs | 82 + .../Metrics/GetMetricDefinitionsCommand.cs | 85 + .../Metrics/GetMetricsCommand.cs | 141 ++ ...osoft.Azure.Commands.Insights.dll-Help.xml | 1919 ++++++++++++----- .../OutputClasses/IPSRuleCondition.cs | 4 + .../OutputClasses/PSAutoscaleSetting.cs | 10 +- .../OutputClasses/PSAvailabilityCollection.cs | 45 + .../OutputClasses/PSDictionaryElement.cs | 20 + .../OutputClasses/PSDimensionCollection.cs | 45 + .../OutputClasses/PSMetric.cs | 53 + .../OutputClasses/PSMetricDefinition.cs | 65 + .../PSMetricDefinitionNoDetails.cs | 47 + .../OutputClasses/PSMetricNoDetails.cs | 62 + .../OutputClasses/PSMetricTabularResult.cs | 100 + .../OutputClasses/PSMetricValue.cs | 46 + .../OutputClasses/PSMetricValuesCollection.cs | 46 + .../OutputClasses/PSToStringExtensions.cs | 176 ++ 37 files changed, 3055 insertions(+), 656 deletions(-) create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Metrics/FormatMetricsAsTableCommandTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricsCommandTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.ps1 create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetricDefinitions.json create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetrics.json create mode 100644 src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAvailabilityCollection.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDimensionCollection.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetric.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinition.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinitionNoDetails.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricNoDetails.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricTabularResult.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValuesCollection.cs diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj index 25b8cf99c98e..270d46058b97 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj @@ -125,10 +125,16 @@ + + + + + PreserveNewest + @@ -161,6 +167,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -200,6 +209,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/FormatMetricsAsTableCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/FormatMetricsAsTableCommandTests.cs new file mode 100644 index 000000000000..177341748f19 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/FormatMetricsAsTableCommandTests.cs @@ -0,0 +1,95 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Management.Automation; +using Microsoft.Azure.Commands.Insights.Metrics; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.Metrics +{ + public class FormatMetricsAsTableCommandTests + { + private readonly FormatMetricsAsTableCommand cmdlet; + private Mock commandRuntimeMock; + + public FormatMetricsAsTableCommandTests() + { + commandRuntimeMock = new Mock(); + cmdlet = new FormatMetricsAsTableCommand() + { + CommandRuntime = commandRuntimeMock.Object, + }; + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void FormatMetricsAsTableCommandParametersProcessing() + { + // Null parameter + var result = cmdlet.ProcessParameter(); + Assert.True(result != null, "Non-null expected"); + Assert.True(result.Length == 0, "0 length expected"); + + // Empty parameter + cmdlet.Metrics = new Metric[] {}; + result = cmdlet.ProcessParameter(); + Assert.True(result != null, "Non-null expected"); + Assert.True(result.Length == 0, "0 length expected"); + + // Non empty parameter + DateTime timeStamp = DateTime.Parse("2015/03/01 01:30:00"); + DateTime endTime = DateTime.Parse("2015/03/01 02:00:00"); + DateTime startTime = DateTime.Parse("2015/03/01 00:00:00"); + TimeSpan timeGrain = TimeSpan.FromMinutes(1); + + cmdlet.Metrics = new Metric[] + { + new Metric() + { + EndTime = endTime, + Name = new LocalizableString() { Value = "metric1", LocalizedValue = "metric1" }, + MetricValues = new MetricValue[] + { + new MetricValue() + { + Count = 1, + Timestamp = timeStamp, + }, + }, + Properties = new Dictionary(), + ResourceId = "\\resourceid\\", + StartTime = startTime, + TimeGrain = timeGrain, + Unit = Unit.Count, + } + }; + result = cmdlet.ProcessParameter(); + Assert.True(result != null, "Non-null expected"); + Assert.True(result.Length == 1, "length = 1 expected"); + Assert.Equal("metric1", result[0].Name); + Assert.Equal("\\resourceid\\", result[0].ResourceId); + Assert.Equal(1, result[0].Count); + Assert.Equal(timeStamp.ToUniversalTime().ToString("u"), result[0].TimestampUTC); + Assert.Equal(endTime.ToUniversalTime().ToString("u"), result[0].EndTimeUTC); + Assert.Equal(startTime.ToUniversalTime().ToString("u"), result[0].StartTimeUTC); + Assert.Equal(timeGrain, result[0].TimeGrain); + Assert.Equal(Unit.Count, result[0].Unit); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs new file mode 100644 index 000000000000..de0b7abd2eb5 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs @@ -0,0 +1,82 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Commands.Insights.Metrics; +using Microsoft.Azure.Insights; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.Metrics +{ + public class GetMetricDefinitionsCommandTests + { + private readonly GetMetricDefinitionsCommand cmdlet; + private readonly Mock insightsClientMock; + private readonly Mock insightsMetricDefinitionOperationsMock; + private Mock commandRuntimeMock; + private MetricDefinitionListResponse response; + private string resourceId; + private string filter; + + public GetMetricDefinitionsCommandTests() + { + insightsMetricDefinitionOperationsMock = new Mock(); + insightsClientMock = new Mock(); + commandRuntimeMock = new Mock(); + cmdlet = new GetMetricDefinitionsCommand() + { + CommandRuntime = commandRuntimeMock.Object, + InsightsClient = insightsClientMock.Object + }; + + response = Utilities.InitializeMetricDefinitionResponse(); + + insightsMetricDefinitionOperationsMock.Setup(f => f.GetMetricDefinitionsAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(response)) + .Callback((string f, string s, CancellationToken t) => + { + resourceId = f; + filter = s; + }); + + insightsClientMock.SetupGet(f => f.MetricDefinitionOperations).Returns(this.insightsMetricDefinitionOperationsMock.Object); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetMetricDefinitionsCommandParametersProcessing() + { + // Testting defaults and required parameters + cmdlet.ResourceId = Utilities.ResourceUri; + + cmdlet.ExecuteCmdlet(); + Assert.True(string.IsNullOrWhiteSpace(filter)); + Assert.Equal(Utilities.ResourceUri, resourceId); + + // Testing with optional parameters + cmdlet.MetricNames = new[] { "n1", "n2" }; + const string expected = "name.value eq 'n1' or name.value eq 'n2'"; + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricsCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricsCommandTests.cs new file mode 100644 index 000000000000..ef726da7a6df --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricsCommandTests.cs @@ -0,0 +1,112 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Commands.Insights.Metrics; +using Microsoft.Azure.Insights; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.Metrics +{ + public class GetMetricsCommandTests + { + private readonly GetMetricsCommand cmdlet; + private readonly Mock insightsClientMock; + private readonly Mock insightsMetricOperationsMock; + private Mock commandRuntimeMock; + private MetricListResponse response; + private string resourceId; + private string filter; + + public GetMetricsCommandTests() + { + insightsMetricOperationsMock = new Mock(); + insightsClientMock = new Mock(); + commandRuntimeMock = new Mock(); + cmdlet = new GetMetricsCommand() + { + CommandRuntime = commandRuntimeMock.Object, + InsightsClient = insightsClientMock.Object + }; + + response = Utilities.InitializeMetricResponse(); + + insightsMetricOperationsMock.Setup(f => f.GetMetricsAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(response)) + .Callback((string f, string s, CancellationToken t) => + { + resourceId = f; + filter = s; + }); + + insightsClientMock.SetupGet(f => f.MetricOperations).Returns(this.insightsMetricOperationsMock.Object); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetMetricsCommandParametersProcessing() + { + // Testting defaults and required parameters + cmdlet.ResourceId = Utilities.ResourceUri; + cmdlet.TimeGrain = TimeSpan.FromMinutes(1); + + cmdlet.ExecuteCmdlet(); + Assert.True(filter != null && filter.Contains("timeGrain eq duration'PT1M'") && filter.Contains(" and startTime eq ") && filter.Contains(" and endTime eq ")); + Assert.Equal(Utilities.ResourceUri, resourceId); + + cmdlet.TimeGrain = TimeSpan.FromMinutes(5); + + cmdlet.ExecuteCmdlet(); + Assert.True(filter != null && filter.Contains("timeGrain eq duration'PT5M'") && filter.Contains(" and startTime eq ") && filter.Contains(" and endTime eq ")); + Assert.Equal(Utilities.ResourceUri, resourceId); + + var endDate = DateTime.Now.AddMinutes(-1); + cmdlet.TimeGrain = TimeSpan.FromMinutes(5); + cmdlet.EndTime = endDate; + + var startTime = endDate.Subtract(GetMetricsCommand.DefaultTimeRange).ToString("O"); + var endTime = endDate.ToString("O"); + var expected = "timeGrain eq duration'PT5M' and startTime eq " + startTime + " and endTime eq " + endTime; + + // Remove the value assigned in the last execution + cmdlet.StartTime = default(DateTime); + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + + cmdlet.StartTime = endDate.Subtract(GetMetricsCommand.DefaultTimeRange).Subtract(GetMetricsCommand.DefaultTimeRange); + startTime = cmdlet.StartTime.ToString("O"); + expected = "timeGrain eq duration'PT5M' and startTime eq " + startTime + " and endTime eq " + endTime; + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + + // Testing with optional parameters + cmdlet.MetricNames = new[] {"n1", "n2"}; + expected = "(name.value eq 'n1' or name.value eq 'n2') and " + expected; + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.cs new file mode 100644 index 000000000000..eee6547fac76 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.cs @@ -0,0 +1,36 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests +{ + public class MetricsTests + { + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestGetMetrics() + { + TestsController.NewInstance.RunPsTest("Test-GetMetrics"); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestGetMetricDefinitions() + { + TestsController.NewInstance.RunPsTest("Test-GetMetricDefinitions"); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.ps1 b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.ps1 new file mode 100644 index 000000000000..957bb7bca825 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/MetricsTests.ps1 @@ -0,0 +1,60 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.SYNOPSIS +Tests getting metrics values for a particular resource. +#> +function Test-GetMetrics +{ + # Setup + $rscname = '/subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/garyyang1' + + try + { + # Test + $actual = Get-Metrics -ResourceId $rscname -timeGrain 00:01:00 -starttime 2015-03-23T15:00:00 -endtime 2015-03-23T15:30:00 + + # Assert TODO add more asserts + Assert-AreEqual $actual.Count 15 + } + finally + { + # Cleanup + # No cleanup needed for now + } +} + +<# +.SYNOPSIS +Tests getting metrics definitions. +#> +function Test-GetMetricDefinitions +{ + # Setup + $rscname = '/subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/garyyang1' + + try + { + $actual = Get-MetricDefinitions -ResourceId $rscname + + # Assert TODO add more asserts + Assert-AreEqual $actual.Count 15 + } + finally + { + # Cleanup + # No cleanup needed for now + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetricDefinitions.json b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetricDefinitions.json new file mode 100644 index 000000000000..96d66045789d --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetricDefinitions.json @@ -0,0 +1,38 @@ +{ + "Entries": [ + { + "RequestUri": "/%2Fsubscriptions%2Fa93fb07c-6c93-40be-bf3b-4f0deba10f4b%2FresourceGroups%2FDefault-Web-EastUS%2Fproviders%2Fmicrosoft.web%2Fsites%2Fgaryyang1/metricDefinitions?api-version=2014-04-01&$filter=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept": [ "application/json" ], + "User-Agent": [ "Microsoft.Azure.Insights.InsightsClient/0.9.0.0 AzurePowershell/v0.8.15" ], + "x-ms-version": [ "2014-04-01" ], + "Connection": [ "Keep-Alive" ] + }, + "ResponseBody": "{\"value\":[{\"name\":{\"value\":\"CpuTime\",\"localizedValue\":\"CPU Time\"},\"unit\":\"Seconds\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Requests\",\"localizedValue\":\"Requests\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"BytesReceived\",\"localizedValue\":\"Data In\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"BytesSent\",\"localizedValue\":\"Data Out\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http2xx\",\"localizedValue\":\"Http 2xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http3xx\",\"localizedValue\":\"Http 3xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http401\",\"localizedValue\":\"Http 401\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http403\",\"localizedValue\":\"Http 403\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http404\",\"localizedValue\":\"Http 404\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http406\",\"localizedValue\":\"Http 406\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http4xx\",\"localizedValue\":\"Http 4xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http5xx\",\"localizedValue\":\"Http Server Errors\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"MemoryWorkingSet\",\"localizedValue\":\"Memory working set\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"AverageMemoryWorkingSet\",\"localizedValue\":\"Average memory working set\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Average\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"AverageResponseTime\",\"localizedValue\":\"Average Response Time\"},\"unit\":\"Seconds\",\"primaryAggregationType\":\"Average\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]}]}", + "ResponseHeaders": { + "Cache-Control": [ "no-cache" ], + "Date": [ "Mon, 23 Mar 2015 20:57:46 GMT" ], + "Expires": [ "-1" ], + "Pragma": [ "no-cache" ], + "Content-Length": [ "4360" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "31999" ], + "x-ms-request-id": [ "63575ceb-f8d2-4a28-a571-edc783166245" ], + "x-ms-correlation-request-id": [ "4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "x-ms-routing-request-id": [ "WESTUS:20150323T205747Z:4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ] + }, + "StatusCode": 200 + } + ], + "Names": { + "Test-GetMetricDefinitions": [ + "" + ] + }, + "Variables": { + "SubscriptionId": "a93fb07c-6c93-40be-bf3b-4f0deba10f4b" + } +} \ No newline at end of file diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetrics.json b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetrics.json new file mode 100644 index 000000000000..58fa6b9fc3c0 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.MetricsTests/TestGetMetrics.json @@ -0,0 +1,64 @@ +{ + "Entries": [ + { + "RequestUri": "/%2Fsubscriptions%2Fa93fb07c-6c93-40be-bf3b-4f0deba10f4b%2FresourceGroups%2FDefault-Web-EastUS%2Fproviders%2Fmicrosoft.web%2Fsites%2Fgaryyang1/metricDefinitions?api-version=2014-04-01&$filter=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept": [ "application/json" ], + "User-Agent": [ "Microsoft.Azure.Insights.InsightsClient/0.9.0.0 AzurePowershell/v0.8.15" ], + "x-ms-version": [ "2014-04-01" ], + "Connection": [ "Keep-Alive" ] + }, + "ResponseBody": "{\"value\":[{\"name\":{\"value\":\"CpuTime\",\"localizedValue\":\"CPU Time\"},\"unit\":\"Seconds\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Requests\",\"localizedValue\":\"Requests\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"BytesReceived\",\"localizedValue\":\"Data In\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"BytesSent\",\"localizedValue\":\"Data Out\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http2xx\",\"localizedValue\":\"Http 2xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http3xx\",\"localizedValue\":\"Http 3xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http401\",\"localizedValue\":\"Http 401\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http403\",\"localizedValue\":\"Http 403\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http404\",\"localizedValue\":\"Http 404\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http406\",\"localizedValue\":\"Http 406\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http4xx\",\"localizedValue\":\"Http 4xx\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"Http5xx\",\"localizedValue\":\"Http Server Errors\"},\"unit\":\"Count\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"MemoryWorkingSet\",\"localizedValue\":\"Memory working set\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Total\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"AverageMemoryWorkingSet\",\"localizedValue\":\"Average memory working set\"},\"unit\":\"Bytes\",\"primaryAggregationType\":\"Average\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]},{\"name\":{\"value\":\"AverageResponseTime\",\"localizedValue\":\"Average Response Time\"},\"unit\":\"Seconds\",\"primaryAggregationType\":\"Average\",\"resourceUri\":null,\"metricAvailabilities\":[{\"timeGrain\":\"PT1M\",\"retention\":\"P2D\"},{\"timeGrain\":\"PT1H\",\"retention\":\"P30D\"},{\"timeGrain\":\"P1D\",\"retention\":\"P90D\"}],\"properties\":[]}]}", + "ResponseHeaders": { + "Cache-Control": [ "no-cache" ], + "Date": [ "Mon, 23 Mar 2015 20:57:46 GMT" ], + "Expires": [ "-1" ], + "Pragma": [ "no-cache" ], + "Content-Length": [ "4360" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "31999" ], + "x-ms-request-id": [ "63575ceb-f8d2-4a28-a571-edc783166245" ], + "x-ms-correlation-request-id": [ "4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "x-ms-routing-request-id": [ "WESTUS:20150323T205747Z:4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Fa93fb07c-6c93-40be-bf3b-4f0deba10f4b%2FresourceGroups%2FDefault-Web-EastUS%2Fproviders%2Fmicrosoft.web%2Fsites%2Fgaryyang1/metrics?api-version=2014-04-01&$filter=%28name.value%20eq%20%27CpuTime%27%20or%20name.value%20eq%20%27Requests%27%20or%20name.value%20eq%20%27BytesReceived%27%20or%20name.value%20eq%20%27BytesSent%27%20or%20name.value%20eq%20%27Http2xx%27%20or%20name.value%20eq%20%27Http3xx%27%20or%20name.value%20eq%20%27Http401%27%20or%20name.value%20eq%20%27Http403%27%20or%20name.value%20eq%20%27Http404%27%20or%20name.value%20eq%20%27Http406%27%20or%20name.value%20eq%20%27Http4xx%27%20or%20name.value%20eq%20%27Http5xx%27%20or%20name.value%20eq%20%27MemoryWorkingSet%27%20or%20name.value%20eq%20%27AverageMemoryWorkingSet%27%20or%20name.value%20eq%20%27AverageResponseTime%27%29%20and%20timeGrain%20eq%20duration%27PT1M%27%20and%20startTime%20eq%202015-03-23T15%3A00%3A00.0000000%20and%20endTime%20eq%202015-03-23T15%3A30%3A00.0000000", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept": [ "application/json" ], + "User-Agent": [ "Microsoft.Azure.Insights.InsightsClient/0.9.0.0 AzurePowershell/v0.8.15" ], + "x-ms-version": [ "2014-04-01" ] + }, + "ResponseBody": "{\"value\":[{\"name\":{\"value\":\"AverageResponseTime\",\"localizedValue\":\"Average Response Time\"},\"unit\":\"Seconds\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.062,\"minimum\":null,\"maximum\":null,\"total\":0.062,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.046,\"minimum\":null,\"maximum\":null,\"total\":0.046,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.031,\"minimum\":null,\"maximum\":null,\"total\":0.031,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.031,\"minimum\":null,\"maximum\":null,\"total\":0.031,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.017,\"minimum\":null,\"maximum\":null,\"total\":0.017,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.078,\"minimum\":null,\"maximum\":null,\"total\":0.078,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.036000000000000004,\"minimum\":null,\"maximum\":null,\"total\":0.036000000000000004,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"AverageMemoryWorkingSet\",\"localizedValue\":\"Average memory working set\"},\"unit\":\"Bytes\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":33126400.0,\"minimum\":null,\"maximum\":null,\"total\":33126400.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":33128448.0,\"minimum\":null,\"maximum\":null,\"total\":33128448.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":33127424.0,\"minimum\":null,\"maximum\":null,\"total\":33127424.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":33128448.0,\"minimum\":null,\"maximum\":null,\"total\":33128448.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":33126400.0,\"minimum\":null,\"maximum\":null,\"total\":33126400.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":33122986.0,\"minimum\":null,\"maximum\":null,\"total\":33122986.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":33132544.0,\"minimum\":null,\"maximum\":null,\"total\":33132544.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":33126400.0,\"minimum\":null,\"maximum\":null,\"total\":33126400.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":33129813.0,\"minimum\":null,\"maximum\":null,\"total\":33129813.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":33126400.0,\"minimum\":null,\"maximum\":null,\"total\":33126400.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":33124352.0,\"minimum\":null,\"maximum\":null,\"total\":33124352.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":33128448.0,\"minimum\":null,\"maximum\":null,\"total\":33128448.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":33128448.0,\"minimum\":null,\"maximum\":null,\"total\":33128448.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":33125376.0,\"minimum\":null,\"maximum\":null,\"total\":33125376.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":33126400.0,\"minimum\":null,\"maximum\":null,\"total\":33126400.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":33112064.0,\"minimum\":null,\"maximum\":null,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":33128448.0,\"minimum\":null,\"maximum\":null,\"total\":33128448.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"MemoryWorkingSet\",\"localizedValue\":\"Memory working set\"},\"unit\":\"Bytes\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33140736.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33112064.0,\"total\":33112064.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":33112064.0,\"minimum\":33112064.0,\"maximum\":33144832.0,\"total\":33112064.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http5xx\",\"localizedValue\":\"Http Server Errors\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http4xx\",\"localizedValue\":\"Http 4xx\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http406\",\"localizedValue\":\"Http 406\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http404\",\"localizedValue\":\"Http 404\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http403\",\"localizedValue\":\"Http 403\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http401\",\"localizedValue\":\"Http 401\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http3xx\",\"localizedValue\":\"Http 3xx\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Http2xx\",\"localizedValue\":\"Http 2xx\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"BytesSent\",\"localizedValue\":\"Data Out\"},\"unit\":\"Bytes\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":58734.0,\"minimum\":null,\"maximum\":null,\"total\":58734.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"BytesReceived\",\"localizedValue\":\"Data In\"},\"unit\":\"Bytes\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":863.0,\"minimum\":null,\"maximum\":null,\"total\":863.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":837.0,\"minimum\":null,\"maximum\":null,\"total\":837.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":863.0,\"minimum\":null,\"maximum\":null,\"total\":863.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":837.0,\"minimum\":null,\"maximum\":null,\"total\":837.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":863.0,\"minimum\":null,\"maximum\":null,\"total\":863.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":863.0,\"minimum\":null,\"maximum\":null,\"total\":863.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":838.0,\"minimum\":null,\"maximum\":null,\"total\":838.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"Requests\",\"localizedValue\":\"Requests\"},\"unit\":\"Count\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":1.0,\"minimum\":null,\"maximum\":null,\"total\":1.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]},{\"name\":{\"value\":\"CpuTime\",\"localizedValue\":\"CPU Time\"},\"unit\":\"Seconds\",\"timeGrain\":\"PT1M\",\"startTime\":\"2015-03-23T15:00:00Z\",\"endTime\":\"2015-03-23T15:30:00Z\",\"metricValues\":[{\"timestamp\":\"2015-03-23T15:00:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:01:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:02:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:03:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:05:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:07:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:08:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:09:00Z\",\"average\":0.031,\"minimum\":null,\"maximum\":null,\"total\":0.031,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:11:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:12:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:13:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:14:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:15:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:16:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:17:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:18:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:23:00Z\",\"average\":0.031,\"minimum\":null,\"maximum\":null,\"total\":0.031,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:25:00Z\",\"average\":0.015,\"minimum\":null,\"maximum\":null,\"total\":0.015,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:26:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:27:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:28:00Z\",\"average\":0.031,\"minimum\":null,\"maximum\":null,\"total\":0.031,\"count\":1,\"properties\":[]},{\"timestamp\":\"2015-03-23T15:29:00Z\",\"average\":0.0,\"minimum\":null,\"maximum\":null,\"total\":0.0,\"count\":1,\"properties\":[]}],\"resourceId\":null,\"properties\":[]}]}", + "ResponseHeaders": { + "Cache-Control": [ "no-cache" ], + "Date": [ "Mon, 02 Mar 2015 19:47:14 GMT" ], + "Expires": [ "-1" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "Content-Length": [ "43589" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "31997" ], + "x-ms-request-id": [ "8e430569-842a-4b86-a954-0fda5fe1576f" ], + "x-ms-correlation-request-id": [ "095a4225-2fcb-4f72-87a8-0ea4e11bfb7a" ], + "x-ms-routing-request-id": [ "WESTUS:20150323T223347Z:095a4225-2fcb-4f72-87a8-0ea4e11bfb7a" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ] + }, + "StatusCode": 200 + } + ], + "Names": { + "Test-GetAzureCorrelationIdLog": [ + "" + ] + }, + "Variables": { + "SubscriptionId": "a93fb07c-6c93-40be-bf3b-4f0deba10f4b" + } +} \ No newline at end of file diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs index e1e898232a85..1cb0ac46ef9f 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs @@ -127,6 +127,36 @@ public static EventDataListResponse InitializeResponse() }; } + public static MetricListResponse InitializeMetricResponse() + { + // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet + EventData eventData = Utilities.CreateFakeEvent(); + return new MetricListResponse + { + MetricCollection = new MetricCollection + { + Value = new List() + }, + RequestId = Guid.NewGuid().ToString(), + StatusCode = HttpStatusCode.OK + }; + } + + public static MetricDefinitionListResponse InitializeMetricDefinitionResponse() + { + // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet + EventData eventData = Utilities.CreateFakeEvent(); + return new MetricDefinitionListResponse + { + MetricDefinitionCollection = new MetricDefinitionCollection + { + Value = new MetricDefinition[] {} + }, + RequestId = Guid.NewGuid().ToString(), + StatusCode = HttpStatusCode.OK + }; + } + public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs index f0ed2561255d..006e89124c6d 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs @@ -114,18 +114,11 @@ public abstract class AddAlertRuleCommandBase : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try - { - RuleCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); - var result = this.InsightsManagementClient.AlertOperations.CreateOrUpdateRuleAsync(resourceGroupName: this.ResourceGroup, parameters: parameters).Result; - WriteObject(result); - } - catch (AggregateException ex) - { - throw ex.Flatten().InnerException; - } + RuleCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); + var result = this.InsightsManagementClient.AlertOperations.CreateOrUpdateRuleAsync(resourceGroupName: this.ResourceGroup, parameters: parameters).Result; + WriteObject(result); } /// diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs index ac278ec82bee..db4a361de769 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; @@ -70,28 +69,22 @@ public class GetAlertRuleCommand : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try + if (string.IsNullOrWhiteSpace(this.Name)) { - if (string.IsNullOrWhiteSpace(this.Name)) - { - // Retrieve all the AlertRules for a ResourceGroup - RuleListResponse result = this.InsightsManagementClient.AlertOperations.ListRulesAsync(resourceGroupName: this.ResourceGroup, targetResourceUri: this.TargetResourceId).Result; + // Retrieve all the AlertRules for a ResourceGroup + RuleListResponse result = this.InsightsManagementClient.AlertOperations.ListRulesAsync(resourceGroupName: this.ResourceGroup, targetResourceUri: this.TargetResourceId).Result; - var records = result.RuleResourceCollection.Value.Select(e => this.DetailedOutput.IsPresent ? (PSManagementItemDescriptor)new PSAlertRule(e) : new PSAlertRuleNoDetails(e)); - WriteObject(sendToPipeline: records, enumerateCollection: true); - } - else - { - // Retrieve a single AlertRule determined by the ResourceGroup and the rule name - RuleGetResponse result = this.InsightsManagementClient.AlertOperations.GetRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; - WriteObject(sendToPipeline: this.DetailedOutput.IsPresent ? (PSManagementItemDescriptor)new PSAlertRule(result) : new PSAlertRuleNoDetails(result)); - } + var records = result.RuleResourceCollection.Value.Select(e => this.DetailedOutput.IsPresent ? (PSManagementItemDescriptor)new PSAlertRule(e) : new PSAlertRuleNoDetails(e)); + WriteObject(sendToPipeline: records.ToList()); } - catch (AggregateException ex) + else { - throw ex.Flatten().InnerException; + // Retrieve a single AlertRule determined by the ResourceGroup and the rule name + RuleGetResponse result = this.InsightsManagementClient.AlertOperations.GetRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; + var finalResult = new List { this.DetailedOutput.IsPresent ? (PSManagementItemDescriptor)new PSAlertRule(result) : new PSAlertRuleNoDetails(result) }; + WriteObject(sendToPipeline: finalResult); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs index 039419c49ce8..b866f4e01374 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs @@ -48,17 +48,10 @@ public class RemoveAlertRuleCommand : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try - { - AzureOperationResponse result = this.InsightsManagementClient.AlertOperations.DeleteRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; - WriteObject(result); - } - catch (AggregateException ex) - { - throw ex.Flatten().InnerException; - } + AzureOperationResponse result = this.InsightsManagementClient.AlertOperations.DeleteRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; + WriteObject(result); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs index 954d3d3d0d65..24904a3eeeec 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs @@ -92,19 +92,12 @@ public class AddAutoscaleSettingCommand : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try - { - AutoscaleSettingCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); - var result = this.InsightsManagementClient.AutoscaleOperations.CreateOrUpdateSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name, parameters: parameters).Result; + AutoscaleSettingCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); + var result = this.InsightsManagementClient.AutoscaleOperations.CreateOrUpdateSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name, parameters: parameters).Result; - WriteObject(result); - } - catch (AggregateException ex) - { - throw ex.Flatten().InnerException; - } + WriteObject(result); } private AutoscaleSettingCreateOrUpdateParameters CreateSdkCallParameters() diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs index ad4f9cf6f35f..ed03ea082697 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs @@ -57,28 +57,21 @@ public class GetAutoscaleSettingCommand : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try + if (string.IsNullOrWhiteSpace(this.Name)) { - if (string.IsNullOrWhiteSpace(this.Name)) - { - // Retrieve all the Autoscale settings for a resource group - AutoscaleSettingListResponse result = this.InsightsManagementClient.AutoscaleOperations.ListSettingsAsync(resourceGroupName: this.ResourceGroup, targetResourceUri: null).Result; + // Retrieve all the Autoscale settings for a resource group + AutoscaleSettingListResponse result = this.InsightsManagementClient.AutoscaleOperations.ListSettingsAsync(resourceGroupName: this.ResourceGroup, targetResourceUri: null).Result; - var records = result.AutoscaleSettingResourceCollection.Value.Select(e => this.DetailedOutput.IsPresent ? new PSAutoscaleSetting(e) : e); - WriteObject(sendToPipeline: records, enumerateCollection: true); - } - else - { - // Retrieve a single Autoscale setting determined by the resource group and the rule name - AutoscaleSettingGetResponse result = this.InsightsManagementClient.AutoscaleOperations.GetSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; - WriteObject(sendToPipeline: this.DetailedOutput.IsPresent ? new PSAutoscaleSetting(result) : result.ToAutoscaleSettingGetResponse()); - } + var records = result.AutoscaleSettingResourceCollection.Value.Select(e => this.DetailedOutput.IsPresent ? new PSAutoscaleSetting(e) : e); + WriteObject(sendToPipeline: records, enumerateCollection: true); } - catch(AggregateException ex) + else { - throw ex.Flatten().InnerException; + // Retrieve a single Autoscale setting determined by the resource group and the rule name + AutoscaleSettingGetResponse result = this.InsightsManagementClient.AutoscaleOperations.GetSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; + WriteObject(sendToPipeline: this.DetailedOutput.IsPresent ? new PSAutoscaleSetting(result) : result.ToAutoscaleSettingGetResponse()); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs index d5ecc81fa550..22b66d73aeb5 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs @@ -48,17 +48,10 @@ public class RemoveAutoscaleSettingCommand : ManagementCmdletBase /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try - { - AzureOperationResponse result = this.InsightsManagementClient.AutoscaleOperations.DeleteSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; - WriteObject(result); - } - catch (AggregateException ex) - { - throw ex.Flatten().InnerException; - } + AzureOperationResponse result = this.InsightsManagementClient.AutoscaleOperations.DeleteSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; + WriteObject(result); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj index 4ab5e39f6f03..68923b1f04df 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj +++ b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj @@ -80,6 +80,7 @@ + @@ -101,16 +102,22 @@ + + + + - - + + + + @@ -120,6 +127,13 @@ + + + + + + + diff --git a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs index b999f8574ff5..5d382f215414 100644 --- a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs @@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.Insights { /// - /// Base class for the Azure SDK EventService Cmdlets + /// Base class for the Azure Insights SDK EventService Cmdlets /// public abstract class EventCmdletBase : InsightsClientCmdletBase { @@ -185,36 +185,29 @@ protected virtual bool KeepTheRecord(EventData record) /// /// Execute the cmdlet /// - public override void ExecuteCmdlet() + protected override void ExecuteCmdletInternal() { - try - { - string queryFilter = this.ProcessParameters(); - - // Retrieve the records - var fullDetails = this.DetailedOutput.IsPresent; - - // Call the proper API methods to return a list of raw records. In the future this pattern can be extended to include DigestRecords - // If fullDetails is present do not select fields, if not present fetch only the SelectedFieldsForQuery - EventDataListResponse response = this.InsightsClient.EventOperations.ListEventsAsync(filterString: queryFilter, selectedProperties: fullDetails ? null : PSEventDataNoDetails.SelectedFieldsForQuery, cancellationToken: CancellationToken.None).Result; - var records = new List(response.EventDataCollection.Value.Where(this.KeepTheRecord).Select(e => fullDetails ? (IPSEventData)new PSEventData(e) : (IPSEventData)new PSEventDataNoDetails(e))); - string nextLink = response.EventDataCollection.NextLink; - - // Adding a safety check to stop returning records if too many have been read already. - while (!string.IsNullOrWhiteSpace(nextLink) && records.Count < MaxNumberOfReturnedRecords) - { - response = this.InsightsClient.EventOperations.ListEventsNextAsync(nextLink: nextLink, cancellationToken: CancellationToken.None).Result; - records.AddRange(response.EventDataCollection.Value.Select(e => fullDetails ? (IPSEventData)new PSEventData(e) : (IPSEventData)new PSEventDataNoDetails(e))); - nextLink = response.EventDataCollection.NextLink; - } - - // Returns an object that contains a link to the set of subsequent records or null if not more records are available, called Next, and an array of records, called Value - WriteObject(sendToPipeline: records, enumerateCollection: true); - } - catch (AggregateException ex) + string queryFilter = this.ProcessParameters(); + + // Retrieve the records + var fullDetails = this.DetailedOutput.IsPresent; + + // Call the proper API methods to return a list of raw records. In the future this pattern can be extended to include DigestRecords + // If fullDetails is present do not select fields, if not present fetch only the SelectedFieldsForQuery + EventDataListResponse response = this.InsightsClient.EventOperations.ListEventsAsync(filterString: queryFilter, selectedProperties: fullDetails ? null : PSEventDataNoDetails.SelectedFieldsForQuery, cancellationToken: CancellationToken.None).Result; + var records = new List(response.EventDataCollection.Value.Where(this.KeepTheRecord).Select(e => fullDetails ? (IPSEventData)new PSEventData(e) : (IPSEventData)new PSEventDataNoDetails(e))); + string nextLink = response.EventDataCollection.NextLink; + + // Adding a safety check to stop returning records if too many have been read already. + while (!string.IsNullOrWhiteSpace(nextLink) && records.Count < MaxNumberOfReturnedRecords) { - throw ex.Flatten().InnerException; + response = this.InsightsClient.EventOperations.ListEventsNextAsync(nextLink: nextLink, cancellationToken: CancellationToken.None).Result; + records.AddRange(response.EventDataCollection.Value.Select(e => fullDetails ? (IPSEventData)new PSEventData(e) : (IPSEventData)new PSEventDataNoDetails(e))); + nextLink = response.EventDataCollection.NextLink; } + + // Returns an object that contains a link to the set of subsequent records or null if not more records are available, called Next, and an array of records, called Value + WriteObject(sendToPipeline: records, enumerateCollection: true); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/InsightsClientCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/InsightsClientCmdletBase.cs index d99a024512fa..8d6b1f3237c8 100644 --- a/src/ResourceManager/Insights/Commands.Insights/InsightsClientCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/InsightsClientCmdletBase.cs @@ -21,9 +21,9 @@ namespace Microsoft.Azure.Commands.Insights { /// - /// Base class for the Azure SDK EventService Cmdlets + /// Base class for the Azure Insights SDK Cmdlets based on the InsightsClient /// - public abstract class InsightsClientCmdletBase : AzurePSCmdlet, IDisposable + public abstract class InsightsClientCmdletBase : InsightsCmdletBase, IDisposable { #region General declarations diff --git a/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs new file mode 100644 index 000000000000..1487e1d86052 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs @@ -0,0 +1,45 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using Microsoft.WindowsAzure.Commands.Utilities.Common; + +namespace Microsoft.Azure.Commands.Insights +{ + /// + /// Base class for the Azure Insights SDK Cmdlets + /// + public abstract class InsightsCmdletBase : AzurePSCmdlet + { + /// + /// Executes the Cmdlet. This is a callback function to simplify the execption handling + /// + protected abstract void ExecuteCmdletInternal(); + + /// + /// Execute the cmdlet + /// + public override void ExecuteCmdlet() + { + try + { + this.ExecuteCmdletInternal(); + } + catch (AggregateException ex) + { + throw ex.Flatten().InnerException; + } + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs index 09c2515ef151..c6d456e3c769 100644 --- a/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs @@ -16,14 +16,13 @@ using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; using Microsoft.Azure.Management.Insights; -using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.Insights { /// - /// Base for the Management-oriented Insights Cmdlets + /// Base class for the Azure Insights SDK Cmdlets based on the InsightsManagementClient /// - public abstract class ManagementCmdletBase : AzurePSCmdlet, IDisposable + public abstract class ManagementCmdletBase : InsightsCmdletBase, IDisposable { #region General declarations diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs new file mode 100644 index 000000000000..4c5cf34a0c14 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs @@ -0,0 +1,82 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using Microsoft.Azure.Commands.Insights.OutputClasses; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.Utilities.Common; + +namespace Microsoft.Azure.Commands.Insights.Metrics +{ + /// + /// Get the list of metric definition for a resource. + /// + [Cmdlet(VerbsCommon.Format, "MetricsAsTable"), OutputType(typeof(PSMetricTabularResult[]))] + public class FormatMetricsAsTableCommand : AzurePSCmdlet + { + /// + /// Gets or sets the array of metrics of the cmdlet + /// + [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The array of metrics")] + public Metric[] Metrics { get; set; } + + /// + /// Processes the Metrics parameter flatting it and converting it to a tabular format + /// + /// A tabular format of the input parameters + public PSMetricTabularResult[] ProcessParameter() + { + var metricsTable = new List(); + foreach (var metric in this.Metrics ?? Enumerable.Empty()) + { + metricsTable.AddRange( + metric.MetricValues.Select( + metricValue => + new PSMetricTabularResult + { + // Values common to the metric spec + Name = metric.Name != null ? metric.Name.Value : null, + DimensionName = metric.DimensionName != null ? metric.DimensionName.Value : null, + DimensionValue = metric.DimensionValue != null ? metric.DimensionValue.Value : null, + ResourceId = metric.ResourceId, + TimeGrain = metric.TimeGrain, + Unit = metric.Unit, + EndTimeUTC = metric.EndTime.ToUniversalTime().ToString("u"), + StartTimeUTC = metric.StartTime.ToUniversalTime().ToString("u"), + + // Values from a single metricValue record + Average = metricValue.Average, + Count = metricValue.Count, + Last = metricValue.Last, + Maximum = metricValue.Maximum, + Minimum = metricValue.Minimum, + TimestampUTC = metricValue.Timestamp.ToUniversalTime().ToString("u"), + Total = metricValue.Total + })); + } + + return metricsTable.ToArray(); + } + + /// + /// Execute the cmdlet + /// + public override void ExecuteCmdlet() + { + WriteObject(this.ProcessParameter()); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs new file mode 100644 index 000000000000..7f979ceecd0a --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs @@ -0,0 +1,85 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Threading; +using Microsoft.Azure.Commands.Insights.OutputClasses; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.Metrics +{ + /// + /// Get the list of metric definitions for a resource. + /// + [Cmdlet(VerbsCommon.Get, "MetricDefinitions"), OutputType(typeof(MetricDefinition[]))] + public class GetMetricDefinitionsCommand : InsightsClientCmdletBase + { + /// + /// Gets or sets the ResourceId parameter of the cmdlet + /// + [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource Id")] + [ValidateNotNullOrEmpty] + public string ResourceId { get; set; } + + /// + /// Gets or sets the metricnames parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The metric names of the query")] + [ValidateNotNullOrEmpty] + public string[] MetricNames { get; set; } + + /// + /// Gets or sets the detailedoutput parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the records (the default is to return only some attributes, i.e. no detail)")] + public SwitchParameter DetailedOutput { get; set; } + + /// + /// Process the general parameters (i.e. defined in this class) and the particular parameters (i.e. the parameters added by the descendants of this class). + /// + /// The final query filter to be used by the cmdlet + protected string ProcessParameters() + { + var buffer = new StringBuilder(); + if (this.MetricNames != null) + { + var metrics = this.MetricNames + .Select(n => string.Concat("name.value eq '", n, "'")) + .Aggregate((a, b) => string.Concat(a, " or ", b)); + buffer.Append(metrics); + } + + return buffer.ToString().Trim(); + } + + /// + /// Execute the cmdlet + /// + protected override void ExecuteCmdletInternal() + { + string queryFilter = this.ProcessParameters(); + bool fullDetails = this.DetailedOutput.IsPresent; + + // Call the proper API methods to return a list of raw records. + // If fullDetails is present full details of the records are displayed, otherwise only a summary of the records is displayed + MetricDefinitionListResponse response = this.InsightsClient.MetricDefinitionOperations.GetMetricDefinitionsAsync(resourceUri: this.ResourceId, filterString: queryFilter, cancellationToken: CancellationToken.None).Result; + var records = response.MetricDefinitionCollection.Value.Select(e => fullDetails ? (MetricDefinition)new PSMetricDefinition(e) : new PSMetricDefinitionNoDetails(e)).ToArray(); + + WriteObject(sendToPipeline: records); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs new file mode 100644 index 000000000000..3759055d9f6e --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs @@ -0,0 +1,141 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Threading; +using System.Xml; +using Microsoft.Azure.Commands.Insights.OutputClasses; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.Metrics +{ + /// + /// Get the list of metric definition for a resource. + /// + [Cmdlet(VerbsCommon.Get, "Metrics"), OutputType(typeof(Metric[]))] + public class GetMetricsCommand : InsightsClientCmdletBase + { + /// + /// Default value of the timerange to search for metrics + /// + public static readonly TimeSpan DefaultTimeRange = TimeSpan.FromHours(1); + + /// + /// Gets or sets the ResourceId parameter of the cmdlet + /// + [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource Id")] + [ValidateNotNullOrEmpty] + public string ResourceId { get; set; } + + /// + /// Gets or sets the timegrain parameter of the cmdlet + /// + [Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The time grain of the query")] + [ValidateNotNullOrEmpty] + public TimeSpan TimeGrain { get; set; } + + /// + /// Gets or sets the starttime parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The start time of the query")] + public DateTime StartTime { get; set; } + + /// + /// Gets or sets the endtime parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The end time of the query")] + public DateTime EndTime { get; set; } + + /// + /// Gets or sets the metricnames parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The metric names of the query")] + [ValidateNotNullOrEmpty] + public string[] MetricNames { get; set; } + + /// + /// Gets or sets the detailedoutput parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the records (the default is to return only some attributes, i.e. no detail)")] + public SwitchParameter DetailedOutput { get; set; } + + /// + /// Process the general parameters (i.e. defined in this class). The particular parameters are a responsibility of the descendants after adding a method to process more parameters. + /// + /// The query filter to be used by the cmdlet + protected string ProcessParameters() + { + var buffer = new StringBuilder(); + if (this.MetricNames != null) + { + var metrics = this.MetricNames.Select(n => string.Concat("name.value eq '", n, "'")).Aggregate((a, b) => string.Concat(a, " or ", b)); + + buffer.Append("("); + buffer.Append(metrics); + buffer.Append(")"); + } + + if (this.TimeGrain != default(TimeSpan)) + { + buffer.Append(" and timeGrain eq duration'"); + buffer.Append(XmlConvert.ToString(this.TimeGrain)); + buffer.Append("'"); + } + + // EndTime defaults to Now + if (this.EndTime == default(DateTime)) + { + this.EndTime = DateTime.Now; + } + + // StartTime defaults to EndTime - DefaultTimeRange (NOTE: EndTime defaults to Now) + if (this.StartTime == default(DateTime)) + { + this.StartTime = this.EndTime.Subtract(DefaultTimeRange); + } + + buffer.Append(" and startTime eq "); + buffer.Append(this.StartTime.ToString("O")); + buffer.Append(" and endTime eq "); + buffer.Append(this.EndTime.ToString("O")); + + string queryFilter = buffer.ToString(); + if (queryFilter.StartsWith(" and ")) + { + queryFilter = queryFilter.Substring(4); + } + + return queryFilter.Trim(); + } + + /// + /// Execute the cmdlet + /// + protected override void ExecuteCmdletInternal() + { + string queryFilter = this.ProcessParameters(); + bool fullDetails = this.DetailedOutput.IsPresent; + + // Call the proper API methods to return a list of raw records. + // If fullDetails is present full details of the records displayed, otherwise only a summary of the values is displayed + MetricListResponse response = this.InsightsClient.MetricOperations.GetMetricsAsync(resourceUri: this.ResourceId, filterString: queryFilter, cancellationToken: CancellationToken.None).Result; + var records = response.MetricCollection.Value.Select(e => fullDetails ? (Metric)new PSMetric(e) : new PSMetricNoDetails(e)).ToArray(); + + WriteObject(sendToPipeline: records); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml index fa2894d1c8c4..920bbf2a71cd 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml +++ b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml @@ -41,60 +41,18 @@ String - EventName - - The name of the event the rule is monitoring. This is used only in the event-based rules. - - String - - - EventSource - - The source of the event the rule is monitoring. This is used only in the event-based rules. - - String - - - Level - - The level of the event the rule is monitoring. This is used only in the event-based rules. - - String - - - OperationName - - The operation name - - String - - - ResourceProvider - - The resource provider - - String - - - Status - - The status - - String - - - SubStatus + MetricName - The substatus + The metric (name) the rule is monitoring. This is only used in metric-based rules. String - - EmailAddress + + TimeAggregationOperator - The e-mail address to use when reporting rule activation. + The aggregation operator to apply to the time window when the rule is being evaluated. - String + Nullable`1[TimeAggregationOperator] RuleType @@ -191,18 +149,60 @@ String - MetricName + EventName - The metric (name) the rule is monitoring. This is only used in metric-based rules. + The name of the event the rule is monitoring. This is used only in the event-based rules. String - - TimeAggregationOperator + + EventSource - The aggregation operator to apply to the time window when the rule is being evaluated. + The source of the event the rule is monitoring. This is used only in the event-based rules. - Nullable`1[TimeAggregationOperator] + String + + + Level + + The level of the event the rule is monitoring. This is used only in the event-based rules. + + String + + + OperationName + + The operation name + + String + + + ResourceProvider + + The resource provider + + String + + + Status + + The status + + String + + + SubStatus + + The substatus + + String + + + EmailAddress + + The e-mail address to use when reporting rule activation. + + String RuleType @@ -394,81 +394,9 @@ - EventName - - The name of the event the rule is monitoring. This is used only in the event-based rules. - - String - - String - - - - - - EventSource - - The source of the event the rule is monitoring. This is used only in the event-based rules. - - String - - String - - - - - - Level - - The level of the event the rule is monitoring. This is used only in the event-based rules. - - String - - String - - - - - - OperationName - - The operation name - - String - - String - - - - - - ResourceProvider - - The resource provider - - String - - String - - - - - - Status - - The status - - String - - String - - - - - - SubStatus + MetricName - The substatus + The metric (name) the rule is monitoring. This is only used in metric-based rules. String @@ -477,14 +405,14 @@ - - EmailAddress + + TimeAggregationOperator - The e-mail address to use when reporting rule activation. + The aggregation operator to apply to the time window when the rule is being evaluated. - String + Nullable`1[TimeAggregationOperator] - String + Nullable`1[TimeAggregationOperator] @@ -610,9 +538,9 @@ - MetricName + EventName - The metric (name) the rule is monitoring. This is only used in metric-based rules. + The name of the event the rule is monitoring. This is used only in the event-based rules. String @@ -621,57 +549,129 @@ - - TimeAggregationOperator + + EventSource - The aggregation operator to apply to the time window when the rule is being evaluated. + The source of the event the rule is monitoring. This is used only in the event-based rules. - Nullable`1[TimeAggregationOperator] + String - Nullable`1[TimeAggregationOperator] + String - FailedLocationCount + Level - The failed location count for the webtest rules. This is similar to the threshold in the other types of rules. + The level of the event the rule is monitoring. This is used only in the event-based rules. - Int32 + String - Int32 + String - - - + + OperationName + + The operation name + + String - - - + String + + + + + ResourceProvider - - + The resource provider - - - - + String - - - + String + + + + + Status - - + The status - - + String + + String + + + + + + SubStatus + + The substatus + + String + + String + + + + + + EmailAddress + + The e-mail address to use when reporting rule activation. + + String + + String + + + + + + FailedLocationCount + + The failed location count for the webtest rules. This is similar to the threshold in the other types of rules. + + Int32 + + Int32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -763,6 +763,10 @@ If the rule exists, then it just disables it. Remove-AlertRule + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + @@ -1049,6 +1053,148 @@ add-autoscalesetting -Location "East US" -Name MySetting -ResourceGrou Get-AutoscaleHistory + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + + + + + Format-MetricsAsTable + + Formats the output of the Get-Metrics Cmdlet as an array of records, one for each metric value to be used by the Export-csv Cdmlet. + + + + + Format + MetricsAsTable + + + + Formats the output of the Get-Metrics Cmdlet as an array of records, one for each metric value. +The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet. + + + + Format-MetricsAsTable + + Metrics + + An array of Metric objects. This is usually the output of the Get-Metrics Cmdlet. + + Metric[] + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + + + + Metrics + + An array of Metric objects. This is usually the output of the Get-Metrics Cmdlet. + + Metric[] + + Metric[] + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Typical use to export to Excel -------------------------- + + PS C:\> + + $s = get-metrics -res /subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/garyyang1 -time 00:01:00 -det +$s2 = format-metricsastable $s +foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInformation} + + Export the output of Get-Metrics to a csv file that is readable by Excel. + + + "Name","TimestampUTC","Count","Last","Maximum","Minimum","Total","Average","StartTimeUTC","EndTimeUTC","TimeGrain","Unit","DimensionName","DimensionValue","ResourceId" +"AverageResponseTime","2015-03-20 16:15:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" +"AverageResponseTime","2015-03-20 16:17:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" +"AverageResponseTime","2015-03-20 16:18:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-Metrics + + + + + + @@ -1528,6 +1674,10 @@ SubStatus : Get-AlertRule + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + @@ -1558,9 +1708,9 @@ SubStatus : String - TargetResourceId + Name - The Id of the target resource + The name of the alert rule String @@ -1588,6 +1738,13 @@ SubStatus : String + + TargetResourceId + + The Id of the target resource + + String + DetailedOutput @@ -1612,13 +1769,6 @@ SubStatus : String - - Name - - The name of the alert rule - - String - DetailedOutput @@ -1649,9 +1799,9 @@ SubStatus : - TargetResourceId + Name - The Id of the target resource + The name of the alert rule String @@ -1685,9 +1835,9 @@ SubStatus : - Name + TargetResourceId - The name of the alert rule + The Id of the target resource String @@ -1807,6 +1957,10 @@ The output contains only basic information about the alert rule. Remove-AlertRule + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + @@ -2188,6 +2342,10 @@ SubStatus : Remove-AutoscaleSetting + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + @@ -2438,108 +2596,664 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - -------------------------- Example 2: GetAutoscaleSetting by resource name -------------------------- + -------------------------- Example 2: GetAutoscaleSetting by resource name -------------------------- + + PS C:\> + + get-autoscaleSetting -res Default-Web-EastUS -name DefaultServerFarm-Default-Web-EastUS -det + + This command retrieves the autoscale settings associated to a resource group and a resource + + + Id : /subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft. + insights/autoscalesettings/DefaultServerFarm-Default-Web-EastUS +Location : East US +Name : DefaultServerFarm-Default-Web-EastUS +Properties : + Enabled : True + Profiles : + + Capacity : + Default : 1 + Minimum : 3 + Maximum : 1 + FixedDate : + + Name : No scheduled times + Recurrence : + + Rules : + + MetricTrigger : + MetricName : CpuPercentage + MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 + b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm + Operator : GreaterThanOrEqual + Statistic : Average + Threshold : 14 + TimeAggregation : Average + TimeGrain : 00:01:00 + TimeWindow : 00:45:00 + ScaleAction : + Cooldown : 00:05:00 + Direction : Increase + Type : ChangeCount + Value : 1 + + + MetricTrigger : + MetricName : CpuPercentage + MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 + b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm + Operator : LessThanOrEqual + Statistic : Average + Threshold : 4 + TimeAggregation : Average + TimeGrain : 00:01:00 + TimeWindow : 00:45:00 + ScaleAction : + Cooldown : 02:00:00 + Direction : Decrease + Type : ChangeCount + Value : 1 + + + MetricTrigger : + MetricName : BytesReceived + MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 + b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm + Operator : LessThanOrEqual + Statistic : Average + Threshold : 50 + TimeAggregation : Average + TimeGrain : 00:01:00 + TimeWindow : 00:10:00 + ScaleAction : + Cooldown : 00:10:00 + Direction : Decrease + Type : ChangeCount + Value : 1 + + + MetricTrigger : + MetricName : BytesReceived + MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 + b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm + Operator : GreaterThanOrEqual + Statistic : Average + Threshold : 100 + TimeAggregation : Average + TimeGrain : 00:01:00 + TimeWindow : 00:05:00 + ScaleAction : + Cooldown : 00:10:00 + Direction : Increase + Type : ChangeCount + Value : 1 + + + TargetResourceId : /subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/ + providers/microsoft.web/serverFarms/DefaultServerFarm +Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, + Microsoft.WindowsAzure.Management.Common.Storage], [hidden-link:/subscriptions/a93fb07c-6c93-40be-bf3b-4f0 + deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm, + Resource]} + + + + + + + + + + + + + Add-AutoscaleSetting + + + + Get-AutoscaleHistory + + + + Remove-AutoscaleSetting + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + + + + + Get-AzureCorrelationIdLog + + Gets the operations associated with a CorrelationId + + + + + Get + AzureCorrelationIdLog + + + + Gets the operations associated with a CorrelationId. + + + + Get-AzureCorrelationIdLog + + CorrelationId + + Specifies a filter by correlationId. This parameter is mandatory. + + String + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + + + + CorrelationId + + Specifies a filter by correlationId. This parameter is mandatory. + + String + + String + + + + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + Nullable`1[DateTime] + + + EndTime minus one hour + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + Nullable`1[DateTime] + + + Current time + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + String + + + + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + String + + + + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + SwitchParameter + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: GetAzureCorrelationIdLog -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + + This command lists all the operations associated to the given CorrelationId that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 2: GetAzureCorrelationIdLog with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + + This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 3: GetAzureCorrelationIdLog with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + + This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-AzureSubscriptionIdLog + + + + Get-AzureResourceGroupLog + + + + Get-AzureResourceLog + + + + Get-AzureResourceProviderLog + + + + + + + + Get-AzureResourceGroupLog + + Gets the operations associated with a Resource Group + + + + + Get + AzureResourceGroupLog + + + + Gets the operations associated with a Resource Group. + + + + Get-AzureResourceGroupLog + + ResourceGroup + + Specifies a filter by ResourceGroup. This parameter is mandatory. + + String + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + + + + ResourceGroup + + Specifies a filter by ResourceGroup. This parameter is mandatory. + + String + + String + + + + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + Nullable`1[DateTime] + + + EndTime minus one hour + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + Nullable`1[DateTime] + + + Current time + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + String + + + + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + String + + + + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + SwitchParameter + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: GetAzureResourceGroupLog -------------------------- + + PS C:\> + + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS + + This command lists all the operations associated to the given Resource Group that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 2: GetAzureResourceGroupLog with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 + + This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 3: GetAzureResourceGroupLog with start and end times -------------------------- PS C:\> - get-autoscaleSetting -res Default-Web-EastUS -name DefaultServerFarm-Default-Web-EastUS -det + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 - This command retrieves the autoscale settings associated to a resource group and a resource + This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. - Id : /subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft. - insights/autoscalesettings/DefaultServerFarm-Default-Web-EastUS -Location : East US -Name : DefaultServerFarm-Default-Web-EastUS -Properties : - Enabled : True - Profiles : - - Capacity : - Default : 1 - Minimum : 3 - Maximum : 1 - FixedDate : - - Name : No scheduled times - Recurrence : - - Rules : - - MetricTrigger : - MetricName : CpuPercentage - MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 - b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm - Operator : GreaterThanOrEqual - Statistic : Average - Threshold : 14 - TimeAggregation : Average - TimeGrain : 00:01:00 - TimeWindow : 00:45:00 - ScaleAction : - Cooldown : 00:05:00 - Direction : Increase - Type : ChangeCount - Value : 1 - - - MetricTrigger : - MetricName : CpuPercentage - MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 - b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm - Operator : LessThanOrEqual - Statistic : Average - Threshold : 4 - TimeAggregation : Average - TimeGrain : 00:01:00 - TimeWindow : 00:45:00 - ScaleAction : - Cooldown : 02:00:00 - Direction : Decrease - Type : ChangeCount - Value : 1 - - - MetricTrigger : - MetricName : BytesReceived - MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 - b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm - Operator : LessThanOrEqual - Statistic : Average - Threshold : 50 - TimeAggregation : Average - TimeGrain : 00:01:00 - TimeWindow : 00:10:00 - ScaleAction : - Cooldown : 00:10:00 - Direction : Decrease - Type : ChangeCount - Value : 1 - - - MetricTrigger : - MetricName : BytesReceived - MetricResourceId : /subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4 - b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm - Operator : GreaterThanOrEqual - Statistic : Average - Threshold : 100 - TimeAggregation : Average - TimeGrain : 00:01:00 - TimeWindow : 00:05:00 - ScaleAction : - Cooldown : 00:10:00 - Direction : Increase - Type : ChangeCount - Value : 1 - - - TargetResourceId : /subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/ - providers/microsoft.web/serverFarms/DefaultServerFarm -Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, - Microsoft.WindowsAzure.Management.Common.Storage], [hidden-link:/subscriptions/a93fb07c-6c93-40be-bf3b-4f0 - deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/serverFarms/DefaultServerFarm, - Resource]} + @@ -2552,15 +3266,23 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - Add-AutoscaleSetting + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-AzureSubscriptionIdLog - Get-AutoscaleHistory + Get-AzureCorrelationIdLog - Remove-AutoscaleSetting + Get-AzureResourceLog + + + + Get-AzureResourceProviderLog @@ -2568,34 +3290,34 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - Get-AzureCorrelationIdLog + Get-AzureResourceLog - Gets the operations associated with a CorrelationId + Gets the operations associated with a ResourceId Get - AzureCorrelationIdLog + AzureResourceLog - Gets the operations associated with a CorrelationId. + Gets the operations associated with a ResourceId. - Get-AzureCorrelationIdLog + Get-AzureResourceLog - CorrelationId + ResourceId - Specifies a filter by correlationId. This parameter is mandatory. + Specifies a filter by ResoruceId. This parameter is mandatory. String StartTime - Specifies the start time of the query in local time. This parameter is optional. + Specifies the start time of the query in local time. This parameter is optional. The default is EndTime minus one hour. Nullable`1[DateTime] @@ -2640,9 +3362,9 @@ The value must be earlier than StartTime, but not more than 15 days. - CorrelationId + ResourceId - Specifies a filter by correlationId. This parameter is mandatory. + Specifies a filter by ResoruceId. This parameter is mandatory. String @@ -2654,7 +3376,7 @@ The value must be earlier than StartTime, but not more than 15 days. StartTime - Specifies the start time of the query in local time. This parameter is optional. + Specifies the start time of the query in local time. This parameter is optional. The default is EndTime minus one hour. Nullable`1[DateTime] @@ -2762,13 +3484,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureCorrelationIdLog -------------------------- + -------------------------- Example 1: GetAzureResourceLog -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 - This command lists all the operations associated to the given CorrelationId that took place in the last hour. + This command lists all the operations associated to the given ResourceId that took place in the last hour. @@ -2782,13 +3504,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureCorrelationIdLog with starttime only -------------------------- + -------------------------- Example 2: GetAzureResourceLog with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 - This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. + This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. @@ -2802,13 +3524,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureCorrelationIdLog with start and end times -------------------------- + -------------------------- Example 3: GetAzureResourceLog with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 - This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -2832,11 +3554,11 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureResourceGroupLog + Get-AzureCorrelationIdLog - Get-AzureResourceLog + Get-AzureResourceGroupLog @@ -2848,27 +3570,27 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureResourceGroupLog + Get-AzureResourceProviderLog - Gets the operations associated with a Resource Group + Gets the operations associated with a Resource Provider Get - AzureResourceGroupLog + AzureResourceProviderLog - Gets the operations associated with a Resource Group. + Gets the operations associated with a Resource Provider. - Get-AzureResourceGroupLog + Get-AzureResourceProviderLog - ResourceGroup + ResourceProvider - Specifies a filter by ResourceGroup. This parameter is mandatory. + Specifies a filter by ResourceProvider. This parameter is mandatory. String @@ -2920,9 +3642,9 @@ The value must be earlier than StartTime, but not more than 15 days. - ResourceGroup + ResourceProvider - Specifies a filter by ResourceGroup. This parameter is mandatory. + Specifies a filter by ResourceProvider. This parameter is mandatory. String @@ -3042,13 +3764,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureResourceGroupLog -------------------------- + -------------------------- Example 1: GetAzureResourceProviderLog -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web - This command lists all the operations associated to the given Resource Group that took place in the last hour. + This command lists all the operations associated to the given Resource Provider that took place in the last hour. @@ -3062,13 +3784,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureResourceGroupLog with starttime only -------------------------- + -------------------------- Example 2: GetAzureResourceProviderLog with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 - This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. + This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. @@ -3082,13 +3804,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceGroupLog with start and end times -------------------------- + -------------------------- Example 3: GetAzureResourceProviderLog with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 - This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -3116,11 +3838,11 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureResourceLog + Get-AzureResourceGroupLog - Get-AzureResourceProviderLog + Get-AzureResourceLog @@ -3128,30 +3850,23 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureResourceLog + Get-AzureSubscriptionIdLog - Gets the operations associated with a ResourceId + Gets the operations associated with the current subscriptionId Get - AzureResourceLog + AzureSubscriptionIdLog - Gets the operations associated with a ResourceId. + Gets the operations associated with the current subscriptionId. - Get-AzureResourceLog - - ResourceId - - Specifies a filter by ResoruceId. This parameter is mandatory. - - String - + Get-AzureSubscriptionIdLog StartTime @@ -3199,18 +3914,6 @@ The value must be earlier than StartTime, but not more than 15 days. - - ResourceId - - Specifies a filter by ResoruceId. This parameter is mandatory. - - String - - String - - - - StartTime @@ -3222,7 +3925,7 @@ The default is EndTime minus one hour. Nullable`1[DateTime] - EndTime minus one hour + EndTime @@ -3322,13 +4025,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureResourceLog -------------------------- + -------------------------- Example 1: GetAzureSubscriptionIdLog -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 + PS C:\>Get-AzureSubscriptionIdLog - This command lists all the operations associated to the given ResourceId that took place in the last hour. + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. @@ -3342,13 +4045,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureResourceLog with starttime only -------------------------- + -------------------------- Example 2: GetAzureSubscriptionIdLog with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 - This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time. @@ -3362,13 +4065,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceLog with start and end times -------------------------- + -------------------------- Example 3: GetAzureSubscriptionIdLog with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 - This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -3388,15 +4091,15 @@ The value must be earlier than StartTime, but not more than 15 days. http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureSubscriptionIdLog + Get-AzureCorrelationIdLog - Get-AzureCorrelationIdLog + Get-AzureResourceGroupLog - Get-AzureResourceGroupLog + Get-AzureResourceLog @@ -3408,64 +4111,41 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureResourceProviderLog + Get-MetricDefinitions - Gets the operations associated with a Resource Provider + Retrieves the metric definitions. Get - AzureResourceProviderLog + MetricDefinitions - Gets the operations associated with a Resource Provider. + Retrieves the metric definitions. - Get-AzureResourceProviderLog + Get-MetricDefinitions - ResourceProvider + ResourceId - Specifies a filter by ResourceProvider. This parameter is mandatory. + The id of the resource the metric is associated to. String - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - - Caller + MetricNames - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + An array of names of metrics to retrieve their definitions. - String + String[] DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter @@ -3480,9 +4160,9 @@ The value must be earlier than StartTime, but not more than 15 days. - ResourceProvider + ResourceId - Specifies a filter by ResourceProvider. This parameter is mandatory. + The id of the resource the metric is associated to. String @@ -3492,51 +4172,13 @@ The value must be earlier than StartTime, but not more than 15 days. - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - EndTime minus one hour - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - Current time - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - String - - - - - - Caller + MetricNames - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + An array of names of metrics to retrieve their definitions. - String + String[] - String + String[] @@ -3544,14 +4186,14 @@ The value must be earlier than StartTime, but not more than 15 days. DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter SwitchParameter - + false Profile @@ -3569,26 +4211,24 @@ The value must be earlier than StartTime, but not more than 15 days. - None + - - + - None + - - + @@ -3602,16 +4242,35 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureResourceProviderLog -------------------------- + -------------------------- Example 1: Summarized output -------------------------- PS C:\> - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 + - This command lists all the operations associated to the given Resource Provider that took place in the last hour. + Gets all the metrics definitions for the given resource (identified by the ResourceId) - + Name : CpuTime +Dimensions : {} +MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability} +PrimaryAggregationType : Total +Properties : {} +ResourceUri : +Unit : Seconds + +Name : Requests +Dimensions : {} +MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability} +PrimaryAggregationType : Total +Properties : {} +ResourceUri : +Unit : Count @@ -3622,16 +4281,48 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureResourceProviderLog with starttime only -------------------------- + -------------------------- Example 2: Detailed output -------------------------- PS C:\> - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det - This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. + Gets all the metrics definitions for the given resource (identified by the ResourceId). The results are detailed. - + Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : CpuTime +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Seconds + +Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : Requests +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Count @@ -3642,16 +4333,48 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceProviderLog with start and end times -------------------------- + -------------------------- Example 3: Filtered detailed output -------------------------- PS C:\> - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det -met BytesSent,CpuTime - This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + Gets one two metric definitions for the given resource (identified by the ResourceId). The results are detailed. - + Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : CpuTime +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Seconds + +Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : BytesSent +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Bytes @@ -3668,19 +4391,7 @@ The value must be earlier than StartTime, but not more than 15 days. http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureSubscriptionIdLog - - - - Get-AzureCorrelationIdLog - - - - Get-AzureResourceGroupLog - - - - Get-AzureResourceLog + Get-Metrics @@ -3688,57 +4399,63 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureSubscriptionIdLog + Get-Metrics - Gets the operations associated with the current subscriptionId + Retrieves the metric values of a resource. Get - AzureSubscriptionIdLog + Metrics - Gets the operations associated with the current subscriptionId. + Retrieves the metric values of a resource that comply with certain criteria. - Get-AzureSubscriptionIdLog - - StartTime + Get-Metrics + + ResourceId - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. + The id of the resource the metric is associated to. - Nullable`1[DateTime] + String - - EndTime + + TimeGrain - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - Nullable`1[DateTime] + TimeSpan - Status + StartTime - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + Earliest Date/Time to search for metric values. - String + DateTime - Caller + EndTime - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + Latest Time/Date to search for metric values. + - String + DateTime + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter @@ -3752,52 +4469,63 @@ The value must be earlier than StartTime, but not more than 15 days. - - StartTime + + ResourceId - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. + The id of the resource the metric is associated to. - Nullable`1[DateTime] + String - Nullable`1[DateTime] + String - - EndTime + + TimeGrain - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - Nullable`1[DateTime] + TimeSpan - Nullable`1[DateTime] + TimeSpan - Current time + - Status + StartTime - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + Earliest Date/Time to search for metric values. - String + DateTime - String + DateTime - + EndTime - 1 hour - Caller + EndTime - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + Latest Time/Date to search for metric values. + - String + DateTime - String + DateTime + + + Now + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] + + String[] @@ -3805,14 +4533,14 @@ The value must be earlier than StartTime, but not more than 15 days. DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter SwitchParameter - + false Profile @@ -3830,26 +4558,24 @@ The value must be earlier than StartTime, but not more than 15 days. - None + - - + - None + - - + @@ -3863,16 +4589,39 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureSubscriptionIdLog -------------------------- + -------------------------- Example 1: Summarized output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. + Retrieves the metric values for website3 with a time grain of 1 minute - + DimensionName : +DimensionValue : +Name : AverageResponseTime +EndTime : 3/20/2015 6:40:46 PM +MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, + Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} +Properties : {} +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:40:00 PM +TimeGrain : 00:01:00 +Unit : Seconds + +DimensionName : +DimensionValue : +Name : AverageMemoryWorkingSet +EndTime : 3/20/2015 6:40:46 PM +MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, + Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} +Properties : {} +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:40:00 PM +TimeGrain : 00:01:00 +Unit : Bytes + @@ -3883,16 +4632,50 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureSubscriptionIdLog with starttime only -------------------------- + -------------------------- Example 2: Detailed output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time. + Retrieves the metric values for website3 with a time grain of 1 minute. The output is detailed. - + MetricValues : + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:37:00 PM + Total : 0 + Average : 0.106 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:39:00 PM + Total : 0.106 + Average : 0.064 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:41:00 PM + Total : 0.064 +Properties : +DimensionName : +DimensionValue : +Name : AverageResponseTime +EndTime : 3/20/2015 6:43:33 PM +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:43:00 PM +TimeGrain : 00:01:00 +Unit : Seconds + @@ -3903,16 +4686,66 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureSubscriptionIdLog with start and end times -------------------------- + -------------------------- Example 3: Filtered detailed output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det -met Requests - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. - + + MetricValues : + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:39:00 PM + Total : 1 + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:41:00 PM + Total : 1 + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:43:00 PM + Total : 0 + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:44:00 PM + Total : 1 + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:45:00 PM + Total : 0 +Properties : +DimensionName : +DimensionValue : +Name : Requests +EndTime : 3/20/2015 6:47:56 PM +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:47:00 PM +TimeGrain : 00:01:00 +Unit : Count + @@ -3929,19 +4762,11 @@ The value must be earlier than StartTime, but not more than 15 days. http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureCorrelationIdLog - - - - Get-AzureResourceGroupLog - - - - Get-AzureResourceLog + Get-MetricDefinitions - Get-AzureResourceProviderLog + Format-MetricsAsTable @@ -4510,8 +5335,8 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity - Unknown - + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 @@ -4891,8 +5716,8 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - Unknown - + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 @@ -5048,6 +5873,10 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana Get-AlertHistory + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + @@ -5180,6 +6009,10 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana Get-AutoscaleHistory + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + \ No newline at end of file diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/IPSRuleCondition.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/IPSRuleCondition.cs index 194e89fcf753..91cfc6b75fe9 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/IPSRuleCondition.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/IPSRuleCondition.cs @@ -14,6 +14,10 @@ namespace Microsoft.Azure.Commands.Insights.OutputClasses { + /// + /// Wrapps around the RuleCondition and exposes all the localized strings as invariant/localized properties + /// It is an empty interface to allow for different types of outputs for the cmdlets, i.e. all the specific output types will implement this interface and the base cmdlet always returns lists of this type. + /// public interface IPSRuleCondition { } diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAutoscaleSetting.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAutoscaleSetting.cs index 8c97d86aa530..a9391632ba56 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAutoscaleSetting.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAutoscaleSetting.cs @@ -19,7 +19,7 @@ namespace Microsoft.Azure.Commands.Insights.OutputClasses /// /// Wrapps around the AutoscaleSettingGetResponse and AutoscaleSettingResource /// - public class PSAutoscaleSetting : AutoscaleSettingResource + public sealed class PSAutoscaleSetting : AutoscaleSettingResource { /// /// Gets or sets the Propeties of the object. @@ -39,6 +39,10 @@ public class PSAutoscaleSetting : AutoscaleSettingResource /// The autoscale setting spec public PSAutoscaleSetting(AutoscaleSettingGetResponse autoscaleSettingSpec) { + // Keep the original values (types) in the base class + base.Properties = autoscaleSettingSpec.Properties; + base.Tags = autoscaleSettingSpec.Tags; + this.Id = autoscaleSettingSpec.Id; this.Location = autoscaleSettingSpec.Location; this.Name = autoscaleSettingSpec.Name; @@ -52,6 +56,10 @@ public PSAutoscaleSetting(AutoscaleSettingGetResponse autoscaleSettingSpec) /// The autoscale setting spec public PSAutoscaleSetting(AutoscaleSettingResource autoscaleSettingSpec) { + // Keep the original values (types) in the base class + base.Properties = autoscaleSettingSpec.Properties; + base.Tags = autoscaleSettingSpec.Tags; + this.Id = autoscaleSettingSpec.Id; this.Location = autoscaleSettingSpec.Location; this.Name = autoscaleSettingSpec.Name; diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAvailabilityCollection.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAvailabilityCollection.cs new file mode 100644 index 000000000000..fb2ba5f1955b --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSAvailabilityCollection.cs @@ -0,0 +1,45 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wraps around a list of Dimension objects to display them with indentation + /// + public class PSAvailabilityCollection + { + private IList metricAvailabilities; + + /// + /// Initializes a new instance of the PSAvailabilityCollection class + /// + /// The list of metric availabilities + public PSAvailabilityCollection(IList metricAvailabilities) + { + this.metricAvailabilities = metricAvailabilities; + } + + /// + /// A string representation of the list MetricAvailability objects including indentation + /// + /// A string representation of the list of MetricAvailability objects including indentation + public override string ToString() + { + return this.metricAvailabilities.ToString(indentationTabs: 1); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDictionaryElement.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDictionaryElement.cs index 901552d56123..ab6d0daa3b35 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDictionaryElement.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDictionaryElement.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using System.Collections.Generic; +using System.Globalization; using System.Text; namespace Microsoft.Azure.Commands.Insights.OutputClasses @@ -53,5 +54,24 @@ public override string ToString() } return output.ToString(); } + + /// + /// A string representation of the contained dictionary + /// + /// The number of tabs to insert in front of each member + /// A string representation of the contained dictionary + public string ToString(int indentationTabs) + { + var output = new StringBuilder(); + if (this.Content != null && this.Content.Count > 0) + { + foreach (var keyValuePair in this.Content) + { + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).Append(string.Format(CultureInfo.InvariantCulture, "{0, -15}: {1}", keyValuePair.Key, keyValuePair.Value)); + } + } + return output.ToString(); + } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDimensionCollection.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDimensionCollection.cs new file mode 100644 index 000000000000..a802c5b5b975 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSDimensionCollection.cs @@ -0,0 +1,45 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wraps around a list of Dimension objects to display them with indentation + /// + public class PSDimensionCollection + { + private IList metricDimensions; + + /// + /// Initializes a new instance of the PSDimensionCollection class + /// + /// The list of metric dimensions + public PSDimensionCollection(IList metricDimensions) + { + this.metricDimensions = metricDimensions; + } + + /// + /// A string representation of the list Dimension objects including indentation + /// + /// A string representation of the list of Dimension objects including indentation + public override string ToString() + { + return this.metricDimensions.ToString(indentationTabs: 1); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetric.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetric.cs new file mode 100644 index 000000000000..e34b71944073 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetric.cs @@ -0,0 +1,53 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wrapps around the PSMetricNoDetails and exposes all the localized strings as invariant/localized properties + /// + public sealed class PSMetric : PSMetricNoDetails + { + /// + /// Gets or sets the MetricValues collection of the metric + /// + public new PSMetricValuesCollection MetricValues { get; set; } + + /// + /// Gets or sets the Properties of the metric + /// + public new PSDictionaryElement Properties { get; set; } + + /// + /// Initializes a new instance of the PSMetric class. + /// + /// The input Metric object + public PSMetric(Metric metric) + : base(metric) + { + this.DimensionName = metric.DimensionName == null ? null : metric.DimensionName.Value; + this.DimensionValue = metric.DimensionValue == null ? null : metric.DimensionValue.Value; + this.EndTime = metric.EndTime; + this.MetricValues = new PSMetricValuesCollection(metric.MetricValues); + this.Name = metric.Name == null ? null : metric.Name.Value; + this.Properties = new PSDictionaryElement(metric.Properties); + this.ResourceId = metric.ResourceId; + this.StartTime = metric.StartTime; + this.TimeGrain = metric.TimeGrain; + this.Unit = metric.Unit; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinition.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinition.cs new file mode 100644 index 000000000000..3985e10f6bec --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinition.cs @@ -0,0 +1,65 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wraps around MetricDefinition to provide detailed data about it + /// + public class PSMetricDefinition : MetricDefinition + { + /// + /// Gets or sets the Dimensions of the metric + /// + public new PSDimensionCollection Dimensions { get; set; } + + /// + /// Gets or sets the MetricAvailabilties of the metric + /// + public new PSAvailabilityCollection MetricAvailabilities { get; set; } + + /// + /// Gets or sets the Name of the metric + /// + public new string Name { get; set; } + + /// + /// Gets or sets the Proterties of the metric + /// + public new PSDictionaryElement Properties { get; set; } + + /// + /// Initializes an new instance of the PSMetricDefinition class + /// + /// The MetricDefinition + public PSMetricDefinition(MetricDefinition metricDefinition) + { + // Keep the original value (localized string, Dictionary, List) in the base + base.Dimensions = metricDefinition.Dimensions; + base.MetricAvailabilities = metricDefinition.MetricAvailabilities; + base.Name = metricDefinition.Name; + base.Properties = metricDefinition.Properties; + + this.Dimensions = new PSDimensionCollection(metricDefinition.Dimensions); + this.MetricAvailabilities = new PSAvailabilityCollection(metricDefinition.MetricAvailabilities); + this.Name = metricDefinition.Name.ToString(localizedValue: false); + this.PrimaryAggregationType = metricDefinition.PrimaryAggregationType; + this.Properties = new PSDictionaryElement(metricDefinition.Properties); + this.ResourceUri = metricDefinition.ResourceUri; + this.Unit = metricDefinition.Unit; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinitionNoDetails.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinitionNoDetails.cs new file mode 100644 index 000000000000..4e94aef307ed --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricDefinitionNoDetails.cs @@ -0,0 +1,47 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wraps around MetricDefinition to provide summarized data about it + /// + public class PSMetricDefinitionNoDetails : MetricDefinition + { + /// + /// Gets or sets the Name of the metric + /// + public new string Name { get; set; } + + /// + /// Initializes an new instance of the PSMetricDefinitionNoDetails class + /// + /// The MetricDefinition + public PSMetricDefinitionNoDetails(MetricDefinition metricDefinition) + { + // Keep the original value (localized string, Dictionary, List) in the base + base.Name = metricDefinition.Name; + + this.Dimensions = metricDefinition.Dimensions; + this.MetricAvailabilities = metricDefinition.MetricAvailabilities; + this.Name = metricDefinition.Name != null ? metricDefinition.Name.Value : null; + this.PrimaryAggregationType = metricDefinition.PrimaryAggregationType; + this.Properties = metricDefinition.Properties; + this.ResourceUri = metricDefinition.ResourceUri; + this.Unit = metricDefinition.Unit; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricNoDetails.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricNoDetails.cs new file mode 100644 index 000000000000..5249fb1989e4 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricNoDetails.cs @@ -0,0 +1,62 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wrapps around the Metric and exposes a summary of the properties properties + /// + public class PSMetricNoDetails : Metric + { + /// + /// Gets or sets the DimensionName of the metric + /// + public new string DimensionName { get; set; } + + /// + /// Gets or sets the DimensionValue of the metric + /// + public new string DimensionValue { get; set; } + + /// + /// Gets or sets the Name of the metric + /// + public new string Name { get; set; } + + /// + /// Initializes a new instance of the PSMetric class. + /// + /// The input Metric object + public PSMetricNoDetails(Metric metric) + { + // Keep the original value (localized string, Dictionary, List) in the base + base.DimensionName = metric.DimensionName; + base.DimensionValue = metric.DimensionValue; + base.Name = metric.Name; + + this.DimensionName = metric.DimensionName == null ? null : metric.DimensionName.Value; + this.DimensionValue = metric.DimensionValue == null ? null : metric.DimensionValue.Value; + this.EndTime = metric.EndTime; + this.MetricValues = metric.MetricValues; + this.Name = metric.Name == null ? null : metric.Name.Value; + this.Properties = metric.Properties; + this.ResourceId = metric.ResourceId; + this.StartTime = metric.StartTime; + this.TimeGrain = metric.TimeGrain; + this.Unit = metric.Unit; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricTabularResult.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricTabularResult.cs new file mode 100644 index 000000000000..f8bec4ebbde0 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricTabularResult.cs @@ -0,0 +1,100 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Represents a single value of a metric + /// + public class PSMetricTabularResult + { + /// + /// Gets or sets the Name of the metric + /// + public string Name { get; set; } + + /// + /// Gets or sets the TimestampUTC of the metric value + /// + public string TimestampUTC { get; set; } + + /// + /// Gets or sets the Count of the metric + /// + public long? Count { get; set; } + + /// + /// Gets or sets the Last value of the metric + /// + public double? Last { get; set; } + + /// + /// Gets or sets the Maximum value of the metric + /// + public double? Maximum { get; set; } + + /// + /// Gets or sets the Minimum value of the metric + /// + public double? Minimum { get; set; } + + /// + /// Gets or sets the Total of the metric + /// + public double? Total { get; set; } + + /// + /// Gets or sets the Average of the metric + /// + public double? Average { get; set; } + + /// + /// Gets or sets the StartTimeUTC of the metric time range + /// + public string StartTimeUTC { get; set; } + + /// + /// Gets or sets the EndTimeUTC of the metric time range + /// + public string EndTimeUTC { get; set; } + + /// + /// Gets or sets the TimeGrain of the metric + /// + public TimeSpan TimeGrain { get; set; } + + /// + /// Gets or sets the Unit of the metric + /// + public Unit Unit { get; set; } + + /// + /// Gets or sets the DimensionName of the metric + /// + public string DimensionName { get; set; } + + /// + /// Gets or sets the DimensionValue of the metric + /// + public string DimensionValue { get; set; } + + /// + /// Gets or sets the ResourceId of the metric + /// + public string ResourceId { get; set; } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs new file mode 100644 index 000000000000..9e6116f10efa --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Text; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wrapps around the MetricValue and exposes all the localized strings as invariant/localized properties + /// + public class PSMetricValue : MetricValue + { + /// + /// Gets or sets the Properties of the metric value + /// + public new PSDictionaryElement Properties { get; set; } + + /// + /// Initializes a new instance of the PSMetricValue class. + /// + /// The input MetricValue object + public PSMetricValue(MetricValue metricValue) + { + this.Average = metricValue.Average; + this.Count = metricValue.Count; + this.Last = metricValue.Last; + this.Maximum = metricValue.Maximum; + this.Minimum = metricValue.Minimum; + this.Properties = new PSDictionaryElement(metricValue.Properties); + this.Timestamp = metricValue.Timestamp; + this.Total = metricValue.Total; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValuesCollection.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValuesCollection.cs new file mode 100644 index 000000000000..3fab26126ff7 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValuesCollection.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Linq; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wraps around a list of PSMetricValue objects to display them with indentation + /// + public class PSMetricValuesCollection + { + private IList metricValues; + + /// + /// Initializes a new instance of the PSMetricValuesCollection class + /// + /// The list of metric values + public PSMetricValuesCollection(IEnumerable metricValues) + { + this.metricValues = metricValues.Select(mv => new PSMetricValue(mv)).ToList(); + } + + /// + /// A string representation of the list Dimension objects including indentation + /// + /// A string representation of the list of Dimension objects including indentation + public override string ToString() + { + return this.metricValues.ToString(indentationTabs: 1); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs index 0cc31dfdf01d..a7f2455fa6c4 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs @@ -14,6 +14,8 @@ using System.Collections.Generic; using System.Text; +using Hyak.Common; +using Microsoft.Azure.Insights.Models; using Microsoft.Azure.Management.Insights.Models; using Microsoft.WindowsAzure.Commands.Utilities.Common; @@ -42,6 +44,17 @@ public static StringBuilder AddSpacesInFront(this StringBuilder output, int inde return output; } + /// + /// A string representation of the Dimension including indentation + /// + /// The input string + /// Flag to inidicate if the localized value must be printed or not + /// A string representation of the LocalizableString + public static string ToString(this LocalizableString inputString, bool localizedValue) + { + return localizedValue ? inputString.LocalizedValue : inputString.Value; + } + #region Extensions for Alerts /// @@ -311,5 +324,168 @@ public static string ToString(this ScaleRule scaleRule, int indentationTabs) } #endregion + + #region Extensions for Metrics + + /// + /// A string representation of the PSMetricValue + /// + /// A PSMetricValue object + /// The number of tabs to insert in front of each member + /// A string representation of the PSMetricValue + public static string ToString(this PSMetricValue metricValue, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).AppendLine("Average : " + metricValue.Average); + output.AddSpacesInFront(indentationTabs).AppendLine("Count : " + metricValue.Count); + output.AddSpacesInFront(indentationTabs).AppendLine("Last : " + metricValue.Last); + output.AddSpacesInFront(indentationTabs).AppendLine("Maximum : " + metricValue.Maximum); + output.AddSpacesInFront(indentationTabs).AppendLine("Minimum : " + metricValue.Minimum); + output.AddSpacesInFront(indentationTabs).AppendLine("Properties : " + metricValue.Properties.ToString(indentationTabs: indentationTabs + 1)); + output.AddSpacesInFront(indentationTabs).AppendLine("Timestamp : " + metricValue.Timestamp); + output.AddSpacesInFront(indentationTabs).Append("Total : " + metricValue.Total); + return output.ToString(); + } + + + /// + /// A string representation of the list of PSMetricValue objects including indentation + /// + /// The list of PSMetricValue objects + /// The number of tabs to insert in front of each member + /// A string representation of the list of PSMetricValue objects including indentation + public static string ToString(this IList metricValues, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + metricValues.ForEach(value => output.Append(value.ToString(indentationTabs))); + + return output.ToString(); + } + + /// + /// A string representation of the list of Dimension objects including indentation + /// + /// The list of Dimension objects + /// The number of tabs to insert in front of each member + /// A string representation of the list of Dimension objects including indentation + public static string ToString(this IList metricDimensions, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + metricDimensions.ForEach(dimension => output.Append(dimension.ToString(indentationTabs))); + + return output.ToString(); + } + + /// + /// A string representation of the Dimension including indentation + /// + /// The Dimension object + /// The number of tabs to insert in front of each member + /// A string representation of the Dimension including indentation + public static string ToString(this Dimension metricDimension, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + if (metricDimension != null) + { + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).AppendLine("Name : " + metricDimension.Name.ToString(localizedValue: false)); + output.AddSpacesInFront(indentationTabs).Append("Values : " + metricDimension.Values); + } + + return output.ToString(); + } + + /// + /// A string representation of the list of MetricAvailability objects including indentation + /// + /// The list of MetricAvailability objects + /// The number of tabs to insert in front of each member + /// A string representation of the list of MetricAvailability objects including indentation + public static string ToString(this IList metricAvailabilities, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + metricAvailabilities.ForEach(availability => output.Append(availability.ToString(indentationTabs))); + + return output.ToString(); + } + + /// + /// A string representation of the MetricAvailability including indentation + /// + /// The MetricAvailability object + /// The number of tabs to insert in front of each member + /// A string representation of the MetricAvailability including indentation + public static string ToString(this MetricAvailability metricAvailability, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + if (metricAvailability != null) + { + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).AppendLine("Location : " + metricAvailability.Location.ToString(indentationTabs: indentationTabs + 1)); + output.AddSpacesInFront(indentationTabs).AppendLine("Retention : " + metricAvailability.Retention); + output.AddSpacesInFront(indentationTabs).Append("Values : " + metricAvailability.TimeGrain); + } + + return output.ToString(); + } + + /// + /// A string representation of the MetricLocation including indentation + /// + /// The MetricLocation object + /// The number of tabs to insert in front of each member + /// A string representation of the MetricLocation including indentation + public static string ToString(this MetricLocation metricLocation, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + if (metricLocation != null) + { + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).AppendLine("Table endpoint : " + metricLocation.TableEndpoint); + output.AddSpacesInFront(indentationTabs).AppendLine("Table info : " + metricLocation.TableInfo); + output.AddSpacesInFront(indentationTabs).Append("PartitionKey : " + metricLocation.PartitionKey); + } + + return output.ToString(); + } + + /// + /// A string representation of the list of MetricTableInfo objects including indentation + /// + /// The list of MetricTableInfo objects + /// The number of tabs to insert in front of each member + /// A string representation of the list of MetricTableInfo objects including indentation + public static string ToString(this LazyList metricTableInfos, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + metricTableInfos.ForEach(metricTableInfo => output.Append(metricTableInfo.ToString(indentationTabs))); + + return output.ToString(); + } + + /// + /// A string representation of the MetricTableInfo including indentation + /// + /// The MetricTableInfo object + /// The number of tabs to insert in front of each member + /// A string representation of the MetricTableInfo including indentation + public static string ToString(this MetricTableInfo metricTableInfo, int indentationTabs) + { + StringBuilder output = new StringBuilder(); + if (metricTableInfo != null) + { + output.AppendLine(); + output.AddSpacesInFront(indentationTabs).AppendLine("Table name : " + metricTableInfo.TableName); + output.AddSpacesInFront(indentationTabs).AppendLine("Table sas token : " + metricTableInfo.SasToken); + output.AddSpacesInFront(indentationTabs).AppendLine("Table sas token expiration : " + metricTableInfo.SasTokenExpirationTime.ToUniversalTime().ToString("O")); + output.AddSpacesInFront(indentationTabs).AppendLine("Start time : " + metricTableInfo.StartTime.ToUniversalTime().ToString("O")); + output.AddSpacesInFront(indentationTabs).Append("End time : " + metricTableInfo.EndTime.ToUniversalTime().ToString("O")); + } + + return output.ToString(); + } + + #endregion } } From 954a416a3ecf4142efdc2815d3746087f01786a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Calder=C3=B3n-Meza?= Date: Mon, 13 Apr 2015 16:13:18 -0700 Subject: [PATCH 2/5] BUG: 3586662 Powershell - Usage cmdlets for retrieving usage across resources --- .../Commands.Insights.Test.csproj | 14 +- .../ScenarioTests/UsageMetricsTests.cs | 29 ++ .../ScenarioTests/UsageMetricsTests.ps1 | 38 ++ .../TestGetUsageMetrics.json | 64 +++ .../GetUsageMetricsCommandTests.cs | 127 ++++++ .../Commands.Insights.Test/Utilities.cs | 15 + .../Commands.Insights.csproj | 10 +- ...osoft.Azure.Commands.Insights.dll-Help.xml | 418 +++++++++++++----- .../OutputClasses/PSUsageMetric.cs | 46 ++ .../UsageMetrics/GetUsageMetricsCommand.cs | 129 ++++++ .../Commands.Insights/packages.config | 2 +- 11 files changed, 777 insertions(+), 115 deletions(-) create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.ps1 create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.UsageMetricsTests/TestGetUsageMetrics.json create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/UsageMetrics/GetUsageMetricsCommandTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSUsageMetric.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj index 270d46058b97..e1a92b7d69b5 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj @@ -1,4 +1,4 @@ - + @@ -58,7 +58,7 @@ ..\..\..\packages\Microsoft.Azure.Common.2.0.4\lib\net45\Microsoft.Azure.Common.NetFramework.dll - ..\..\..\packages\Microsoft.Azure.Insights.0.7.2-preview\lib\net45\Microsoft.Azure.Insights.dll + ..\..\..\packages\Microsoft.Azure.Insights.0.7.7-preview\lib\net45\Microsoft.Azure.Insights.dll False @@ -136,6 +136,10 @@ PreserveNewest + + PreserveNewest + + @@ -170,6 +174,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -215,6 +222,9 @@ PreserveNewest + + PreserveNewest + diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.cs new file mode 100644 index 000000000000..90f3689ee01a --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.cs @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests +{ + public class UsageMetricsTests + { + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestGetUsageMetrics() + { + TestsController.NewInstance.RunPsTest("Test-GetUsageMetrics"); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.ps1 b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.ps1 new file mode 100644 index 000000000000..91274ac93dc7 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/UsageMetricsTests.ps1 @@ -0,0 +1,38 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.SYNOPSIS +Tests getting usage metrics values for a particular resource. +#> +function Test-GetUsageMetrics +{ + # Setup + $rscname = '/subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/garyyang1' + + try + { + # Test + # -timeGrain 00:01:00 -starttime 2015-03-23T15:00:00 -endtime 2015-03-23T15:30:00 + $actual = Get-UsageMetrics -ResourceId $rscname + + # Assert TODO add more asserts + Assert-AreEqual 11 $actual.Count + } + finally + { + # Cleanup + # No cleanup needed for now + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.UsageMetricsTests/TestGetUsageMetrics.json b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.UsageMetricsTests/TestGetUsageMetrics.json new file mode 100644 index 000000000000..ec793934b0e2 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.UsageMetricsTests/TestGetUsageMetrics.json @@ -0,0 +1,64 @@ +{ + "Entries": [ + { + "RequestUri": "/%2Fsubscriptions%2Fa93fb07c-6c93-40be-bf3b-4f0deba10f4b%2FresourceGroups%2FDefault-Web-EastUS%2Fproviders%2Fmicrosoft.web%2Fsites%2Fgaryyang1%2Fusages?api-version=2014-04-01&$filter=startTime%20eq%202015-04-07T15%3A31%3A28.4590754-07%3A00%20and%20endTime%20eq%202015-04-07T16%3A31%3A28.4590754-07%3A00", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept": [ "application/json" ], + "User-Agent": [ "Microsoft.Azure.Insights.InsightsClient/0.9.0.0 AzurePowershell/v0.8.15" ], + "x-ms-version": [ "2014-04-01" ], + "Connection": [ "Keep-Alive" ] + }, + "ResponseBody": "{\"id\":null,\"name\":\"garyyang1\",\"type\":\"Microsoft.Web/sites\",\"kind\":null,\"location\":\"East US\",\"tags\":null,\"plan\":null,\"properties\":[{\"displayName\":\"CPU Time\",\"name\":\"CpuTime\",\"resourceName\":\"CpuTime\",\"unit\":\"Milliseconds\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Data In\",\"name\":\"BytesReceived\",\"resourceName\":\"BytesReceived\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Data Out\",\"name\":\"BytesSent\",\"resourceName\":\"BytesSent\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Local bytes read\",\"name\":\"LocalBytesRead\",\"resourceName\":\"LocalBytesRead\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Local bytes written\",\"name\":\"LocalBytesWritten\",\"resourceName\":\"LocalBytesWritten\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Network bytes read\",\"name\":\"NetworkBytesRead\",\"resourceName\":\"NetworkBytesRead\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Network bytes written\",\"name\":\"NetworkBytesWritten\",\"resourceName\":\"NetworkBytesWritten\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"WP stop requests\",\"name\":\"WPStopRequests\",\"resourceName\":\"WPStopRequests\",\"unit\":\"Count\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Memory Usage\",\"name\":\"MaxMemoryWorkingSetShortPeriod\",\"resourceName\":\"MaxMemoryWorkingSet\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"CPU Time - Minute Limit\",\"name\":\"CpuTimeShortPeriod\",\"resourceName\":\"CpuTime\",\"unit\":\"Milliseconds\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-07T23:36:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"File System Storage\",\"name\":\"FileSystemStorage\",\"resourceName\":\"FileSystemStorage\",\"unit\":\"Bytes\",\"currentValue\":756736,\"limit\":53687091200,\"nextResetTime\":\"9999-12-31T23:59:59.9999999Z\",\"computeMode\":1,\"siteMode\":null}]}", + "ResponseHeaders": { + "Cache-Control": [ "no-cache" ], + "Date": [ "Tue, 07 Apr 2015 23:31:33 GMT" ], + "Expires": [ "-1" ], + "Pragma": [ "no-cache" ], + "Content-Length": [ "2421" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "31999" ], + "x-ms-request-id": [ "63575ceb-f8d2-4a28-a571-edc783166245" ], + "x-ms-correlation-request-id": [ "4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "x-ms-routing-request-id": [ "WESTUS:20150323T205747Z:4e8d2e93-0895-4cf1-aa40-5af880c3fb52" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Fa93fb07c-6c93-40be-bf3b-4f0deba10f4b%2FresourceGroups%2FDefault-Web-EastUS%2Fproviders%2Fmicrosoft.web%2Fsites%2Fgaryyang1/usages?api-version=2014-04-01&$filter=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept": [ "application/json" ], + "User-Agent": [ "Microsoft.Azure.Insights.InsightsClient/0.9.0.0 AzurePowershell/v0.8.15" ], + "x-ms-version": [ "2014-04-01" ] + }, + "ResponseBody": "{\"id\":null,\"name\":\"garyyang1\",\"type\":\"Microsoft.Web/sites\",\"kind\":null,\"location\":\"East US\",\"tags\":null,\"plan\":null,\"properties\":[{\"displayName\":\"CPU Time\",\"name\":\"CpuTime\",\"resourceName\":\"CpuTime\",\"unit\":\"Milliseconds\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Data In\",\"name\":\"BytesReceived\",\"resourceName\":\"BytesReceived\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Data Out\",\"name\":\"BytesSent\",\"resourceName\":\"BytesSent\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Local bytes read\",\"name\":\"LocalBytesRead\",\"resourceName\":\"LocalBytesRead\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Local bytes written\",\"name\":\"LocalBytesWritten\",\"resourceName\":\"LocalBytesWritten\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Network bytes read\",\"name\":\"NetworkBytesRead\",\"resourceName\":\"NetworkBytesRead\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Network bytes written\",\"name\":\"NetworkBytesWritten\",\"resourceName\":\"NetworkBytesWritten\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"WP stop requests\",\"name\":\"WPStopRequests\",\"resourceName\":\"WPStopRequests\",\"unit\":\"Count\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"Memory Usage\",\"name\":\"MaxMemoryWorkingSetShortPeriod\",\"resourceName\":\"MaxMemoryWorkingSet\",\"unit\":\"Bytes\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-08T00:00:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"CPU Time - Minute Limit\",\"name\":\"CpuTimeShortPeriod\",\"resourceName\":\"CpuTime\",\"unit\":\"Milliseconds\",\"currentValue\":0,\"limit\":-1,\"nextResetTime\":\"2015-04-07T23:41:00\",\"computeMode\":1,\"siteMode\":null},{\"displayName\":\"File System Storage\",\"name\":\"FileSystemStorage\",\"resourceName\":\"FileSystemStorage\",\"unit\":\"Bytes\",\"currentValue\":756736,\"limit\":53687091200,\"nextResetTime\":\"9999-12-31T23:59:59.9999999Z\",\"computeMode\":1,\"siteMode\":null}]}", + "ResponseHeaders": { + "Cache-Control": [ "no-cache" ], + "Date": [ "Tue, 07 Apr 2015 23:31:33 GMT" ], + "Expires": [ "-1" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "Content-Length": [ "2421" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "31997" ], + "x-ms-request-id": [ "8e430569-842a-4b86-a954-0fda5fe1576f" ], + "x-ms-correlation-request-id": [ "095a4225-2fcb-4f72-87a8-0ea4e11bfb7a" ], + "x-ms-routing-request-id": [ "WESTUS:20150323T223347Z:095a4225-2fcb-4f72-87a8-0ea4e11bfb7a" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ] + }, + "StatusCode": 200 + } + ], + "Names": { + "Test-GetAzureCorrelationIdLog": [ + "" + ] + }, + "Variables": { + "SubscriptionId": "a93fb07c-6c93-40be-bf3b-4f0deba10f4b" + } +} \ No newline at end of file diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/UsageMetrics/GetUsageMetricsCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/UsageMetrics/GetUsageMetricsCommandTests.cs new file mode 100644 index 000000000000..c949e4267c5e --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/UsageMetrics/GetUsageMetricsCommandTests.cs @@ -0,0 +1,127 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Commands.Insights.UsageMetrics; +using Microsoft.Azure.Insights; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.Metrics +{ + public class GetUsageMetricsCommandTests + { + private readonly GetUsageMetricsCommand cmdlet; + private readonly Mock insightsClientMock; + private readonly Mock insightsUsageMetricOperationsMock; + private Mock commandRuntimeMock; + private UsageMetricListResponse response; + private string resourceId; + private string filter; + private string apiVersion; + + public GetUsageMetricsCommandTests() + { + insightsUsageMetricOperationsMock = new Mock(); + insightsClientMock = new Mock(); + commandRuntimeMock = new Mock(); + cmdlet = new GetUsageMetricsCommand() + { + CommandRuntime = commandRuntimeMock.Object, + InsightsClient = insightsClientMock.Object + }; + + response = Utilities.InitializeUsageMetricResponse(); + + insightsUsageMetricOperationsMock.Setup(f => f.ListAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(response)) + .Callback((string f, string s, string a, CancellationToken t) => + { + resourceId = f; + filter = s; + apiVersion = a; + }); + + insightsClientMock.SetupGet(f => f.UsageMetricOperations).Returns(this.insightsUsageMetricOperationsMock.Object); + } + + private void CleanParamVariables() + { + resourceId = null; + filter = null; + apiVersion = null; + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetUsageMetricsCommandParametersProcessing() + { + // Testting defaults and required parameters + cmdlet.ResourceId = Utilities.ResourceUri; + + cmdlet.ExecuteCmdlet(); + Assert.True(filter != null && filter.Contains("startTime eq ") && filter.Contains(" and endTime eq ")); + Assert.Equal(Utilities.ResourceUri, resourceId); + Assert.Equal(GetUsageMetricsCommand.DefaultApiVersion, apiVersion); + + this.CleanParamVariables(); + var endDate = DateTime.Now.AddMinutes(-1); + cmdlet.EndTime = endDate; + + var startTime = endDate.Subtract(GetUsageMetricsCommand.DefaultTimeRange).ToString("O"); + var endTime = endDate.ToString("O"); + var expected = "startTime eq " + startTime + " and endTime eq " + endTime; + + // Remove the value assigned in the last execution + cmdlet.StartTime = default(DateTime); + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + Assert.Equal(GetUsageMetricsCommand.DefaultApiVersion, apiVersion); + + this.CleanParamVariables(); + cmdlet.StartTime = endDate.Subtract(GetUsageMetricsCommand.DefaultTimeRange).Subtract(GetUsageMetricsCommand.DefaultTimeRange); + startTime = cmdlet.StartTime.ToString("O"); + expected = "startTime eq " + startTime + " and endTime eq " + endTime; + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + Assert.Equal(GetUsageMetricsCommand.DefaultApiVersion, apiVersion); + + // Testing with optional parameters + this.CleanParamVariables(); + cmdlet.MetricNames = new[] {"n1", "n2"}; + expected = "(name.value eq 'n1' or name.value eq 'n2') and " + expected; + + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + Assert.Equal(GetUsageMetricsCommand.DefaultApiVersion, apiVersion); + + // Testing with another api version + cmdlet.ApiVersion = "2015-01-01"; + cmdlet.ExecuteCmdlet(); + Assert.Equal(expected, filter); + Assert.Equal(Utilities.ResourceUri, resourceId); + Assert.Equal("2015-01-01", apiVersion); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs index 1cb0ac46ef9f..e6808ad58724 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs @@ -157,6 +157,21 @@ public static MetricDefinitionListResponse InitializeMetricDefinitionResponse() }; } + public static UsageMetricListResponse InitializeUsageMetricResponse() + { + // This is effectively testing the conversion EventData -> PSEventData internally in the execution of the cmdlet + // EventData eventData = Utilities.CreateFakeEvent(); + return new UsageMetricListResponse + { + UsageMetricCollection = new UsageMetricCollection + { + Value = new List() + }, + RequestId = Guid.NewGuid().ToString(), + StatusCode = HttpStatusCode.OK + }; + } + public static void VerifyDetailedOutput(EventCmdletBase cmdlet, ref string selected) { // Calling with detailed output diff --git a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj index 68923b1f04df..b7a82e6d09b7 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj +++ b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj @@ -1,4 +1,4 @@ - + @@ -57,7 +57,10 @@ ..\..\..\packages\Microsoft.Azure.Common.2.0.4\lib\net45\Microsoft.Azure.Common.NetFramework.dll - ..\..\..\packages\Microsoft.Azure.Insights.0.7.2-preview\lib\net45\Microsoft.Azure.Insights.dll + ..\..\..\packages\Microsoft.Azure.Insights.0.7.7-preview\lib\net45\Microsoft.Azure.Insights.dll + + + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\Resources\Microsoft.Azure.Management.WebSites.dll ..\..\..\packages\Microsoft.Azure.Management.Resources.2.14.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll @@ -136,6 +139,7 @@ + ResourcesForAlertCmdlets.resx @@ -152,6 +156,7 @@ True ResourcesForAutoscaleCmdlets.resx + @@ -186,6 +191,7 @@ Designer + diff --git a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml index 920bbf2a71cd..b969e9cd67eb 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml +++ b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml @@ -1130,7 +1130,8 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< - + + @@ -1142,7 +1143,8 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< - + + @@ -1170,8 +1172,7 @@ foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInf "Name","TimestampUTC","Count","Last","Maximum","Minimum","Total","Average","StartTimeUTC","EndTimeUTC","TimeGrain","Unit","DimensionName","DimensionValue","ResourceId" "AverageResponseTime","2015-03-20 16:15:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" "AverageResponseTime","2015-03-20 16:17:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" -"AverageResponseTime","2015-03-20 16:18:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" - +"AverageResponseTime","2015-03-20 16:18:00","1",,,,"0","0","2015-03-20 16:14:00","2015-03-20 17:14:35","00:01:00","Seconds",,,"/subscriptions/b91eb07f-89c3-40be-bf3b-40fdcba10f6c/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website1" @@ -1192,7 +1193,7 @@ foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInf - + Unknown @@ -4216,7 +4217,8 @@ The value must be earlier than StartTime, but not more than 15 days. - + + @@ -4228,7 +4230,8 @@ The value must be earlier than StartTime, but not more than 15 days. - + + @@ -4246,8 +4249,7 @@ The value must be earlier than StartTime, but not more than 15 days. PS C:\> - get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 - + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 Gets all the metrics definitions for the given resource (identified by the ResourceId) @@ -4440,8 +4442,7 @@ Unit : Bytes EndTime - Latest Time/Date to search for metric values. - + Latest Time/Date to search for metric values. DateTime @@ -4508,8 +4509,7 @@ Unit : Bytes EndTime - Latest Time/Date to search for metric values. - + Latest Time/Date to search for metric values. DateTime @@ -4563,7 +4563,8 @@ Unit : Bytes - + + @@ -4575,7 +4576,8 @@ Unit : Bytes - + + @@ -4620,8 +4622,7 @@ Properties : {} ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 StartTime : 3/20/2015 5:40:00 PM TimeGrain : 00:01:00 -Unit : Bytes - +Unit : Bytes @@ -4674,8 +4675,7 @@ EndTime : 3/20/2015 6:43:33 PM ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 StartTime : 3/20/2015 5:43:00 PM TimeGrain : 00:01:00 -Unit : Seconds - +Unit : Seconds @@ -4744,8 +4744,7 @@ EndTime : 3/20/2015 6:47:56 PM ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 StartTime : 3/20/2015 5:47:00 PM TimeGrain : 00:01:00 -Unit : Count - +Unit : Count @@ -4772,6 +4771,205 @@ Unit : Count + + + Get-UsageMetrics + + Retrieves the usage metric values of a resource. + + + + + Get + UsageMetrics + + + + Retrieves the usage metric values of a resource that comply with certain criteria. + + + + Get-UsageMetrics + + ResourceId + + The id of the resource the metric is associated to. + + String + + + ApiVersion + + Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. + + String + + + StartTime + + Earliest Date/Time to search for metric values. + + DateTime + + + EndTime + + Latest Time/Date to search for metric values. + + DateTime + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + + + + ResourceId + + The id of the resource the metric is associated to. + + String + + String + + + + + + ApiVersion + + Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. + + String + + String + + + + + + StartTime + + Earliest Date/Time to search for metric values. + + DateTime + + DateTime + + + EndTime - 1 hour + + + EndTime + + Latest Time/Date to search for metric values. + + DateTime + + DateTime + + + Local current date/time. + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] + + String[] + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Querying with resaourceId only -------------------------- + + PS C:\> + + get-usagemetrics -res /subscriptions/bcdeb07f-1c43-20be-1f3b-4f0febc10f5b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/johnsmith + + Query the usage metrics for a website + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + + New-AutoscaleProfile @@ -4820,23 +5018,37 @@ Unit : Count String - StartTimeWindow + RecurrenceFrequency - The start of the time window. + The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. - DateTime + RecurrenceFrequency - - EndTimeWindow + + ScheduleDays - The end of the time window. + A list of days scheduled. - DateTime + List`1[String] + + + ScheduleHours + + A list of scheduled hours. + + List`1[Int32] + + + ScheduleMinutes + + List of scheduled minutes. + + List`1[Int32] - TimeWindowTimeZone + ScheduleTimeZone - The time zone of the time window. + The time zone of the schedule. String @@ -4885,6 +5097,27 @@ Unit : Count String + + StartTimeWindow + + The start of the time window. + + DateTime + + + EndTimeWindow + + The end of the time window. + + DateTime + + + TimeWindowTimeZone + + The time zone of the time window. + + String + Rules @@ -4930,41 +5163,6 @@ Unit : Count String - - RecurrenceFrequency - - The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. - - RecurrenceFrequency - - - ScheduleDays - - A list of days scheduled. - - List`1[String] - - - ScheduleHours - - A list of scheduled hours. - - List`1[Int32] - - - ScheduleMinutes - - List of scheduled minutes. - - List`1[Int32] - - - ScheduleTimeZone - - The time zone of the schedule. - - String - Rules @@ -5031,117 +5229,117 @@ Unit : Count - StartTimeWindow + RecurrenceFrequency - The start of the time window. + The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. - DateTime + RecurrenceFrequency - DateTime + RecurrenceFrequency - - EndTimeWindow + + ScheduleDays - The end of the time window. + A list of days scheduled. - DateTime + List`1[String] - DateTime + List`1[String] - - TimeWindowTimeZone + + ScheduleHours - The time zone of the time window. + A list of scheduled hours. - String + List`1[Int32] - String + List`1[Int32] - Rules + ScheduleMinutes - The list of rules to add to the newly created profile. + List of scheduled minutes. - List`1[ScaleRule] + List`1[Int32] - List`1[ScaleRule] + List`1[Int32] - - Profile + + ScheduleTimeZone - In-memory profile (AzureProfile). + The time zone of the schedule. - AzureProfile + String - AzureProfile + String - - RecurrenceFrequency + + Rules - The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. + The list of rules to add to the newly created profile. - RecurrenceFrequency + List`1[ScaleRule] - RecurrenceFrequency + List`1[ScaleRule] - - ScheduleDays + + Profile - A list of days scheduled. + In-memory profile (AzureProfile). - List`1[String] + AzureProfile - List`1[String] + AzureProfile - - ScheduleHours + + StartTimeWindow - A list of scheduled hours. + The start of the time window. - List`1[Int32] + DateTime - List`1[Int32] + DateTime - - ScheduleMinutes + + EndTimeWindow - List of scheduled minutes. + The end of the time window. - List`1[Int32] + DateTime - List`1[Int32] + DateTime - ScheduleTimeZone + TimeWindowTimeZone - The time zone of the schedule. + The time zone of the time window. String diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSUsageMetric.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSUsageMetric.cs new file mode 100644 index 000000000000..5839ecd1a172 --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSUsageMetric.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.OutputClasses +{ + /// + /// Wrapps around the UsageMetric and exposes a summary of the properties properties + /// + public class PSUsageMetric : UsageMetric + { + /// + /// Gets or sets the Name of the usage metric + /// + public new string Name { get; set; } + + /// + /// Initializes a new instance of the PSUsageMetric class. + /// + /// The input UsageMetric object + public PSUsageMetric(UsageMetric usageMetric) + { + // Keep the original value (localized string, Dictionary, List) in the base + base.Name = usageMetric.Name; + + this.CurrentValue = usageMetric.CurrentValue; + this.Limit = usageMetric.Limit; + this.Name = usageMetric.Name != null ? usageMetric.Name.LocalizedValue : null; + this.NextResetTime = usageMetric.NextResetTime; + this.QuotaPeriod = usageMetric.QuotaPeriod; + this.Unit = usageMetric.Unit; + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs new file mode 100644 index 000000000000..a151c6a56cdb --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs @@ -0,0 +1,129 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Threading; +using Microsoft.Azure.Commands.Insights.OutputClasses; +using Microsoft.Azure.Insights.Models; + +namespace Microsoft.Azure.Commands.Insights.UsageMetrics +{ + /// + /// Get the list of usage metrics for a resource. + /// + [Cmdlet(VerbsCommon.Get, "UsageMetrics"), OutputType(typeof(UsageMetric[]))] + public class GetUsageMetricsCommand : InsightsClientCmdletBase + { + /// + /// Default value of the timerange to search for usage metrics + /// + public static readonly TimeSpan DefaultTimeRange = TimeSpan.FromHours(1); + + public static readonly string DefaultApiVersion = "2014-04-01"; + + /// + /// Gets or sets the ResourceId parameter of the cmdlet + /// + [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource Id")] + [ValidateNotNullOrEmpty] + public string ResourceId { get; set; } + + /// + /// Gets or sets the ApiVersion parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The API version string")] + [ValidateNotNullOrEmpty] + public string ApiVersion { get; set; } + + /// + /// Gets or sets the starttime parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The start time of the query")] + public DateTime StartTime { get; set; } + + /// + /// Gets or sets the endtime parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The end time of the query")] + public DateTime EndTime { get; set; } + + /// + /// Gets or sets the metricnames parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The metric names of the query")] + [ValidateNotNullOrEmpty] + public string[] MetricNames { get; set; } + + /// + /// Process the general parameters (i.e. defined in this class). The particular parameters are a responsibility of the descendants after adding a method to process more parameters. + /// + /// The query filter to be used by the cmdlet + protected string ProcessParameters() + { + var buffer = new StringBuilder(); + if (this.MetricNames != null) + { + var metrics = this.MetricNames.Select(n => string.Concat("name.value eq '", n, "'")).Aggregate((a, b) => string.Concat(a, " or ", b)); + + buffer.Append("("); + buffer.Append(metrics); + buffer.Append(")"); + } + + // EndTime defaults to Now + if (this.EndTime == default(DateTime)) + { + this.EndTime = DateTime.Now; + } + + // StartTime defaults to EndTime - DefaultTimeRange (NOTE: EndTime defaults to Now) + if (this.StartTime == default(DateTime)) + { + this.StartTime = this.EndTime.Subtract(DefaultTimeRange); + } + + buffer.Append(" and startTime eq "); + buffer.Append(this.StartTime.ToString("O")); + buffer.Append(" and endTime eq "); + buffer.Append(this.EndTime.ToString("O")); + + string queryFilter = buffer.ToString(); + if (queryFilter.StartsWith(" and ")) + { + queryFilter = queryFilter.Substring(4); + } + + return queryFilter.Trim(); + } + + /// + /// Execute the cmdlet + /// + protected override void ExecuteCmdletInternal() + { + string queryFilter = this.ProcessParameters(); + string apiVersion = this.ApiVersion ?? DefaultApiVersion; + + // Call the proper API methods to return a list of raw records. + // If fullDetails is present full details of the records displayed, otherwise only a summary of the values is displayed + UsageMetricListResponse response = this.InsightsClient.UsageMetricOperations.ListAsync(resourceUri: this.ResourceId, filterString: queryFilter, apiVersion: apiVersion, cancellationToken: CancellationToken.None).Result; + var records = response.UsageMetricCollection.Value.Select(e => new PSUsageMetric(e)).ToArray(); + + WriteObject(sendToPipeline: records); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/packages.config b/src/ResourceManager/Insights/Commands.Insights/packages.config index 0b3ddacd0b51..f6e87d050123 100644 --- a/src/ResourceManager/Insights/Commands.Insights/packages.config +++ b/src/ResourceManager/Insights/Commands.Insights/packages.config @@ -4,7 +4,7 @@ - + From 09980120189e404bbe4dc0547123c7d6c079d1c1 Mon Sep 17 00:00:00 2001 From: Shibani Medhekar Date: Tue, 15 Sep 2015 15:32:46 -0700 Subject: [PATCH 3/5] WORK: 4668261:[PowerShell][Events] Consolidating the existing cmdlets into a single cmdlet and using parameter set --- .../Commands.Insights.Test.csproj | 8 +- .../GetAzureCorrelationIdLogCommandTests.cs | 82 --------- .../Events/GetAzureLogCommandTests.cs | 171 ++++++++++++++++++ .../GetAzureResourceGroupLogCommandTests.cs | 82 --------- .../Events/GetAzureResourceLogCommandTests.cs | 82 --------- ...GetAzureResourceProviderLogCommandTests.cs | 82 --------- .../GetAzureSubscriptionIdLogCommandTests.cs | 79 -------- .../ScenarioTests/EventsTests.ps1 | 10 +- .../Commands.Insights.csproj | 12 +- .../Commands.Insights/EventCmdletBase.cs | 10 +- .../Events/GetAzureCorrelationIdLogCommand.cs | 44 ----- .../Events/GetAzureLogCommand.cs | 108 +++++++++++ .../Events/GetAzureResourceGroupLogCommand.cs | 44 ----- .../Events/GetAzureResourceLogCommand.cs | 46 ----- .../GetAzureResourceProviderLogCommand.cs | 44 ----- .../GetAzureSubscriptionIdLogCommand.cs | 37 ---- 16 files changed, 295 insertions(+), 646 deletions(-) delete mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureCorrelationIdLogCommandTests.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceGroupLogCommandTests.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceLogCommandTests.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceProviderLogCommandTests.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureSubscriptionIdLogCommandTests.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureCorrelationIdLogCommand.cs create mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceGroupLogCommand.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceLogCommand.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceProviderLogCommand.cs delete mode 100644 src/ResourceManager/Insights/Commands.Insights/Events/GetAzureSubscriptionIdLogCommand.cs diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj index ead9c2d28a85..9a6c6c442cf9 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj @@ -117,7 +117,7 @@ ..\..\..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll - ..\..\..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll + ..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll @@ -147,11 +147,7 @@ - - - - - + diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureCorrelationIdLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureCorrelationIdLogCommandTests.cs deleted file mode 100644 index 194574b0d35c..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureCorrelationIdLogCommandTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Management.Automation; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Events; -using Microsoft.Azure.Insights; -using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Moq; -using Xunit; - -namespace Microsoft.Azure.Commands.Insights.Test.Events -{ - public class GetAzureCorrelationIdLogCommandTests - { - private readonly GetAzureCorrelationIdLogCommand cmdlet; - private readonly Mock insightsClientMock; - private readonly Mock insightsEventOperationsMock; - private Mock commandRuntimeMock; - private EventDataListResponse response; - private string filter; - private string selected; - - public GetAzureCorrelationIdLogCommandTests() - { - insightsEventOperationsMock = new Mock(); - insightsClientMock = new Mock(); - commandRuntimeMock = new Mock(); - cmdlet = new GetAzureCorrelationIdLogCommand() - { - CommandRuntime = commandRuntimeMock.Object, - InsightsClient = insightsClientMock.Object - }; - - response = Utilities.InitializeResponse(); - - insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(response)) - .Callback((string f, string s, CancellationToken t) => - { - filter = f; - selected = s; - }); - - insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void GetAzureCorrelationIdLogCommandParametersProcessing() - { - var startDate = DateTime.Now.AddSeconds(-1); - - // Setting required parameter - cmdlet.CorrelationId = Utilities.Correlation; - - Utilities.ExecuteVerifications( - cmdlet: cmdlet, - insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: "correlationId", - requiredFieldValue: Utilities.Correlation, - filter: ref this.filter, - selected: ref this.selected, - startDate: startDate, - response: response); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs new file mode 100644 index 000000000000..838a636e7fee --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs @@ -0,0 +1,171 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Commands.Insights.Events; +using Microsoft.Azure.Insights; +using Microsoft.Azure.Insights.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Xunit; + +namespace Microsoft.Azure.Commands.Insights.Test.Events +{ + public class GetAzureLogCommandTests + { + private readonly GetAzureLogCommand cmdlet; + private readonly Mock insightsClientMock; + private readonly Mock insightsEventOperationsMock; + private Mock commandRuntimeMock; + private EventDataListResponse response; + private string filter; + private string selected; + + public GetAzureLogCommandTests() + { + insightsEventOperationsMock = new Mock(); + insightsClientMock = new Mock(); + commandRuntimeMock = new Mock(); + cmdlet = new GetAzureLogCommand() + { + CommandRuntime = commandRuntimeMock.Object, + InsightsClient = insightsClientMock.Object + }; + + response = Utilities.InitializeResponse(); + + insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(response)) + .Callback((string f, string s, CancellationToken t) => + { + filter = f; + selected = s; + }); + + insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetAzureSubscriptionIdLogCommandParametersProcessing() + { + var startDate = DateTime.Now.AddSeconds(-1); + + Utilities.ExecuteVerifications( + cmdlet: cmdlet, + insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, + requiredFieldName: null, + requiredFieldValue: null, + filter: ref this.filter, + selected: ref this.selected, + startDate: startDate, + response: response); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetAzureCorrelationIdLogCommandParametersProcessing() + { + var startDate = DateTime.Now.AddSeconds(-1); + + // Setting required parameter + cmdlet.CorrelationId = Utilities.Correlation; + cmdlet.ResourceId = null; + cmdlet.ResourceGroup = null; + cmdlet.ResourceProvider = null; + + Utilities.ExecuteVerifications( + cmdlet: cmdlet, + insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, + requiredFieldName: "correlationId", + requiredFieldValue: Utilities.Correlation, + filter: ref this.filter, + selected: ref this.selected, + startDate: startDate, + response: response); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetAzureResourceGroupLogCommandParametersProcessing() + { + var startDate = DateTime.Now.AddSeconds(-1); + + // Setting required parameter + cmdlet.ResourceGroup = Utilities.ResourceGroup; + cmdlet.CorrelationId = null; + cmdlet.ResourceId = null; + cmdlet.ResourceProvider = null; + + Utilities.ExecuteVerifications( + cmdlet: cmdlet, + insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, + requiredFieldName: "resourceGroupName", + requiredFieldValue: Utilities.ResourceGroup, + filter: ref this.filter, + selected: ref this.selected, + startDate: startDate, + response: response); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetAzureResourceLogCommandParametersProcessing() + { + var startDate = DateTime.Now.AddSeconds(-1); + + // Setting required parameter + cmdlet.ResourceId = Utilities.ResourceUri; + cmdlet.ResourceGroup = null; + cmdlet.CorrelationId = null; + cmdlet.ResourceProvider = null; + + Utilities.ExecuteVerifications( + cmdlet: cmdlet, + insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, + requiredFieldName: "resourceUri", + requiredFieldValue: Utilities.ResourceUri, + filter: ref this.filter, + selected: ref this.selected, + startDate: startDate, + response: response); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetAzureResourceProviderLogCommandParametersProcessing() + { + var startDate = DateTime.Now.AddSeconds(-1); + + // Setting required parameter + cmdlet.ResourceProvider = Utilities.ResourceProvider; + cmdlet.ResourceId = null; + cmdlet.ResourceGroup = null; + cmdlet.CorrelationId = null; + + Utilities.ExecuteVerifications( + cmdlet: cmdlet, + insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, + requiredFieldName: "resourceProvider", + requiredFieldValue: Utilities.ResourceProvider, + filter: ref this.filter, + selected: ref this.selected, + startDate: startDate, + response: response); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceGroupLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceGroupLogCommandTests.cs deleted file mode 100644 index 65e3885e4462..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceGroupLogCommandTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Management.Automation; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Events; -using Microsoft.Azure.Insights; -using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Moq; -using Xunit; - -namespace Microsoft.Azure.Commands.Insights.Test.Events -{ - public class GetAzureResourceGroupLogCommandTests - { - private GetAzureResourceGroupLogCommand cmdlet; - private readonly Mock insightsClientMock; - private readonly Mock insightsEventOperationsMock; - private Mock commandRuntimeMock; - private EventDataListResponse response; - private string filter; - private string selected; - - public GetAzureResourceGroupLogCommandTests() - { - insightsEventOperationsMock = new Mock(); - insightsClientMock = new Mock(); - commandRuntimeMock = new Mock(); - cmdlet = new GetAzureResourceGroupLogCommand() - { - CommandRuntime = commandRuntimeMock.Object, - InsightsClient = insightsClientMock.Object - }; - - response = Utilities.InitializeResponse(); - - insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(response)) - .Callback((string f, string s, CancellationToken t) => - { - filter = f; - selected = s; - }); - - insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void GetAzureResourceGroupLogCommandParametersProcessing() - { - var startDate = DateTime.Now.AddSeconds(-1); - - // Setting required parameter - cmdlet.ResourceGroup = Utilities.ResourceGroup; - - Utilities.ExecuteVerifications( - cmdlet: cmdlet, - insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: "resourceGroupName", - requiredFieldValue: Utilities.ResourceGroup, - filter: ref this.filter, - selected: ref this.selected, - startDate: startDate, - response: response); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceLogCommandTests.cs deleted file mode 100644 index 2535f8ce0615..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceLogCommandTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Management.Automation; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Events; -using Microsoft.Azure.Insights; -using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Moq; -using Xunit; - -namespace Microsoft.Azure.Commands.Insights.Test.Events -{ - public class GetAzureResourceLogCommandTests - { - private readonly GetAzureResourceLogCommand cmdlet; - private readonly Mock insightsClientMock; - private readonly Mock insightsEventOperationsMock; - private Mock commandRuntimeMock; - private EventDataListResponse response; - private string filter; - private string selected; - - public GetAzureResourceLogCommandTests() - { - insightsEventOperationsMock = new Mock(); - insightsClientMock = new Mock(); - commandRuntimeMock = new Mock(); - cmdlet = new GetAzureResourceLogCommand() - { - CommandRuntime = commandRuntimeMock.Object, - InsightsClient = insightsClientMock.Object - }; - - response = Utilities.InitializeResponse(); - - insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(response)) - .Callback((string f, string s, CancellationToken t) => - { - filter = f; - selected = s; - }); - - insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void GetAzureResourceLogCommandParametersProcessing() - { - var startDate = DateTime.Now.AddSeconds(-1); - - // Setting required parameter - cmdlet.ResourceId = Utilities.ResourceUri; - - Utilities.ExecuteVerifications( - cmdlet: cmdlet, - insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: "resourceUri", - requiredFieldValue: Utilities.ResourceUri, - filter: ref this.filter, - selected: ref this.selected, - startDate: startDate, - response: response); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceProviderLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceProviderLogCommandTests.cs deleted file mode 100644 index f8876a7baaa7..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureResourceProviderLogCommandTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Management.Automation; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Events; -using Microsoft.Azure.Insights; -using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Moq; -using Xunit; - -namespace Microsoft.Azure.Commands.Insights.Test.Events -{ - public class GetAzureResourceProviderLogCommandTests - { - private readonly GetAzureResourceProviderLogCommand cmdlet; - private readonly Mock insightsClientMock; - private readonly Mock insightsEventOperationsMock; - private Mock commandRuntimeMock; - private EventDataListResponse response; - private string filter; - private string selected; - - public GetAzureResourceProviderLogCommandTests() - { - insightsEventOperationsMock = new Mock(); - insightsClientMock = new Mock(); - commandRuntimeMock = new Mock(); - cmdlet = new GetAzureResourceProviderLogCommand() - { - CommandRuntime = commandRuntimeMock.Object, - InsightsClient = insightsClientMock.Object - }; - - response = Utilities.InitializeResponse(); - - insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(response)) - .Callback((string f, string s, CancellationToken t) => - { - filter = f; - selected = s; - }); - - insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void GetAzureResourceProviderLogCommandParametersProcessing() - { - var startDate = DateTime.Now.AddSeconds(-1); - - // Setting required parameter - cmdlet.ResourceProvider = Utilities.ResourceProvider; - - Utilities.ExecuteVerifications( - cmdlet: cmdlet, - insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: "resourceProvider", - requiredFieldValue: Utilities.ResourceProvider, - filter: ref this.filter, - selected: ref this.selected, - startDate: startDate, - response: response); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureSubscriptionIdLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureSubscriptionIdLogCommandTests.cs deleted file mode 100644 index 3f17cf812a98..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureSubscriptionIdLogCommandTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Management.Automation; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Events; -using Microsoft.Azure.Insights; -using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Moq; -using Xunit; - -namespace Microsoft.Azure.Commands.Insights.Test.Events -{ - public class GetAzureSubscriptionIdLogCommandTests - { - private readonly GetAzureSubscriptionIdLogCommand cmdlet; - private readonly Mock insightsClientMock; - private readonly Mock insightsEventOperationsMock; - private Mock commandRuntimeMock; - private EventDataListResponse response; - private string filter; - private string selected; - - public GetAzureSubscriptionIdLogCommandTests() - { - insightsEventOperationsMock = new Mock(); - insightsClientMock = new Mock(); - commandRuntimeMock = new Mock(); - cmdlet = new GetAzureSubscriptionIdLogCommand() - { - CommandRuntime = commandRuntimeMock.Object, - InsightsClient = insightsClientMock.Object - }; - - response = Utilities.InitializeResponse(); - - insightsEventOperationsMock.Setup(f => f.ListEventsAsync(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(response)) - .Callback((string f, string s, CancellationToken t) => - { - filter = f; - selected = s; - }); - - insightsClientMock.SetupGet(f => f.EventOperations).Returns(this.insightsEventOperationsMock.Object); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void GetAzureSubscriptionIdLogCommandParametersProcessing() - { - var startDate = DateTime.Now.AddSeconds(-1); - - Utilities.ExecuteVerifications( - cmdlet: cmdlet, - insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: null, - requiredFieldValue: null, - filter: ref this.filter, - selected: ref this.selected, - startDate: startDate, - response: response); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 index bccad214eaa3..02643369e49c 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 @@ -24,7 +24,7 @@ function Test-GetAzureCorrelationIdLog try { # Test - $actual = Get-AzureCorrelationIdLog -CorrelationId $correlation -starttime 2015-03-02T10:00:00 -endtime 2015-03-02T12:00:00 -detailedOutput + $actual = Get-AzureLog -CorrelationId $correlation -starttime 2015-03-02T10:00:00 -endtime 2015-03-02T12:00:00 -detailedOutput # Assert TODO add more asserts Assert-AreEqual $actual.Count 2 @@ -47,7 +47,7 @@ function Test-GetAzureResourceGroupLog try { - $actual = Get-AzureResourceGroupLog -ResourceGroup $rgname -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 + $actual = Get-AzureLog -ResourceGroup $rgname -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 # Assert TODO add more asserts Assert-AreEqual $actual.Count 2 @@ -70,7 +70,7 @@ function Test-GetAzureResourceLog try { - $actual = Get-AzureResourceLog -ResourceId $rname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z + $actual = Get-AzureLog -ResourceId $rname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z # Assert TODO add more asserts # Assert-Throws { Set-AzureResourceGroup -Name $rgname -Tags @{"testtag" = "testval"} } "Invalid tag format. Expect @{Name = `"tagName`"} or @{Name = `"tagName`"; Value = `"tagValue`"}" @@ -94,7 +94,7 @@ function Test-GetAzureResourceProviderLog try { - $actual = Get-AzureResourceProviderLog -ResourceProvider $rpname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z + $actual = Get-AzureLog -ResourceProvider $rpname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z # Assert Assert-AreEqual $actual.Count 2 @@ -117,7 +117,7 @@ function Test-GetAzureSubscriptionIdLog try { # Test - $actual = Get-AzureSubscriptionIdLog -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 + $actual = Get-AzureLog -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 # Assert Assert-AreEqual $actual.Count 1 diff --git a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj index 6af41d92a805..e0f291c95b03 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj +++ b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj @@ -98,11 +98,11 @@ False ..\..\..\packages\WindowsAzure.Storage.4.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll - + False ..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll - + @@ -128,11 +128,7 @@ - - - - - + @@ -241,4 +237,4 @@ --> - + \ No newline at end of file diff --git a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs index 5d382f215414..1b84b708f558 100644 --- a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs @@ -45,33 +45,33 @@ public abstract class EventCmdletBase : InsightsClientCmdletBase /// Gets or sets the starttime parameter of the cmdlet /// [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The startTime of the query")] - public DateTime? StartTime { get; set; } + public virtual DateTime? StartTime { get; set; } /// /// Gets or sets the endtime parameter of the cmdlet /// [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The endTime of the query")] - public DateTime? EndTime { get; set; } + public virtual DateTime? EndTime { get; set; } /// /// Gets or sets the status parameter of the cmdlet /// [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The status of the records to fetch")] [ValidateNotNullOrEmpty] - public string Status { get; set; } + public virtual string Status { get; set; } /// /// Gets or sets the caller parameter of the cmdlet /// [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The caller of the records to fetch")] [ValidateNotNullOrEmpty] - public string Caller { get; set; } + public virtual string Caller { get; set; } /// /// Gets or sets the detailedoutput parameter of the cmdlet /// [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the records (the default is to return only some attributes, i.e. no detail)")] - public SwitchParameter DetailedOutput { get; set; } + public virtual SwitchParameter DetailedOutput { get; set; } #endregion diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureCorrelationIdLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureCorrelationIdLogCommand.cs deleted file mode 100644 index c5d4618a51ea..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureCorrelationIdLogCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Management.Automation; -using Microsoft.Azure.Commands.Insights.OutputClasses; - -namespace Microsoft.Azure.Commands.Insights.Events -{ - /// - /// Get the list of events for at a CorrelationId level. - /// - [Cmdlet(VerbsCommon.Get, "AzureCorrelationIdLog"), OutputType(typeof(List))] - public class GetAzureCorrelationIdLogCommand : EventCmdletBase - { - /// - /// Gets or sets the correlationId of the cmdlet - /// - [Parameter(Position = 0, ParameterSetName = CorrelationIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "CorrelationId")] - [ValidateNotNullOrEmpty] - public string CorrelationId { get; set; } - - /// - /// Process the parameters defined by this class (a.k.a. particular parameters) - /// - /// The current query filter - /// The query filter with the conditions for particular parameters added - protected override string ProcessParticularParameters(string currentQueryFilter) - { - return this.AddConditionIfPResent(currentQueryFilter, "correlationId", this.CorrelationId); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs new file mode 100644 index 000000000000..639e8858893a --- /dev/null +++ b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs @@ -0,0 +1,108 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Management.Automation; +using Microsoft.Azure.Commands.Insights.OutputClasses; + +namespace Microsoft.Azure.Commands.Insights.Events +{ + /// + /// Get the list of events for at a subscription level. + /// + [Cmdlet(VerbsCommon.Get, "AzureLog"), OutputType(typeof(List))] + public class GetAzureLogCommand : EventCmdletBase + { + /// + /// Gets or sets the starttime parameter of the cmdlet + /// + [Parameter(ParameterSetName = CorrelationIdName, ValueFromPipelineByPropertyName = true, HelpMessage = "The correlationId of the query")] + [Parameter(ParameterSetName = ResourceIdName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resourceId of the query")] + [Parameter(ParameterSetName = ResourceGroupName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name of the query")] + [Parameter(ParameterSetName = ResourceProviderName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource provider name of the query")] + [Parameter(ParameterSetName = SubscriptionLevelName, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscriptionId of the query")] + public override DateTime? StartTime { get; set; } + + /// + /// Gets or sets the endtime parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The endTime of the query")] + public override DateTime? EndTime { get; set; } + + /// + /// Gets or sets the status parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The status of the records to fetch")] + [ValidateNotNullOrEmpty] + public override string Status { get; set; } + + /// + /// Gets or sets the caller parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The caller of the records to fetch")] + [ValidateNotNullOrEmpty] + public override string Caller { get; set; } + + /// + /// Gets or sets the detailedoutput parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the records (the default is to return only some attributes, i.e. no detail)")] + public override SwitchParameter DetailedOutput { get; set; } + + /// + /// Gets or sets the correlationId of the cmdlet + /// + [Parameter(Position = 0, ParameterSetName = CorrelationIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "CorrelationId")] + [ValidateNotNullOrEmpty] + public string CorrelationId { get; set; } + + /// + /// Gets or sets the resourcegroup parameters of this cmdlet + /// + [Parameter(Position = 0, ParameterSetName = ResourceGroupName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")] + [ValidateNotNullOrEmpty] + public string ResourceGroup { get; set; } + + /// + /// Gets or sets the resourceId parameter of the cmdlet + /// + [Parameter(Position = 0, ParameterSetName = ResourceIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId")] + [ValidateNotNullOrEmpty] + public string ResourceId { get; set; } + + /// + /// Gets or sets the resourceprovider parameter of the cmdlet + /// + [Parameter(Position = 0, ParameterSetName = ResourceProviderName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceProvider name")] + [ValidateNotNullOrEmpty] + public string ResourceProvider { get; set; } + + /// + /// Process the parameters defined by this class (a.k.a. particular parameters) + /// + /// The current query filter + /// The query filter with the conditions for particular parameters added + protected override string ProcessParticularParameters(string currentQueryFilter) + { + string extendedQuery = this.AddConditionIfPResent(currentQueryFilter, "correlationId", this.CorrelationId); + extendedQuery = this.AddConditionIfPResent(extendedQuery, "resourceGroupName", this.ResourceGroup); + + // Notice the different name in the condition (resourceUri) and the parameter (resourceId) + // The difference is intentional as the new directive is to use ResourceId everywhere, but the SDK still uses resourceUri + extendedQuery = this.AddConditionIfPResent(extendedQuery, "resourceUri", this.ResourceId); + return this.AddConditionIfPResent(extendedQuery, "resourceProvider", this.ResourceProvider); + } + } +} diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceGroupLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceGroupLogCommand.cs deleted file mode 100644 index af51019d7a42..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceGroupLogCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Management.Automation; -using Microsoft.Azure.Commands.Insights.OutputClasses; - -namespace Microsoft.Azure.Commands.Insights.Events -{ - /// - /// Get the list of events for at a ResourceGroup level. - /// - [Cmdlet(VerbsCommon.Get, "AzureResourceGroupLog"), OutputType(typeof(List))] - public class GetAzureResourceGroupLogCommand : EventCmdletBase - { - /// - /// Gets or sets the resourcegroup parameters of this cmdlet - /// - [Parameter(Position = 0, ParameterSetName = ResourceGroupName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")] - [ValidateNotNullOrEmpty] - public string ResourceGroup { get; set; } - - /// - /// Process the parameters defined by this class (a.k.a. particular parameters) - /// - /// The current query filter - /// The query filter with the conditions for particular parameters added - protected override string ProcessParticularParameters(string currentQueryFilter) - { - return this.AddConditionIfPResent(currentQueryFilter, "resourceGroupName", this.ResourceGroup); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceLogCommand.cs deleted file mode 100644 index 0e7419cc0504..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceLogCommand.cs +++ /dev/null @@ -1,46 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Management.Automation; -using Microsoft.Azure.Commands.Insights.OutputClasses; - -namespace Microsoft.Azure.Commands.Insights.Events -{ - /// - /// Get the list of events for at a Resource level. - /// - [Cmdlet(VerbsCommon.Get, "AzureResourceLog"), OutputType(typeof(List))] - public class GetAzureResourceLogCommand : EventCmdletBase - { - /// - /// Gets or sets the resourceId parameter of the cmdlet - /// - [Parameter(Position = 0, ParameterSetName = ResourceIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId")] - [ValidateNotNullOrEmpty] - public string ResourceId { get; set; } - - /// - /// Process the parameters defined by this class (a.k.a. particular parameters) - /// - /// The current query filter - /// The query filter with the conditions for particular parameters added - protected override string ProcessParticularParameters(string currentQueryFilter) - { - // Notice the different name in the condition (resourceUri) and the parameter (resourceId) - // The difference is intentional as the new directive is to use ResourceId everywhere, but the SDK still uses resourceUri - return this.AddConditionIfPResent(currentQueryFilter, "resourceUri", this.ResourceId); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceProviderLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceProviderLogCommand.cs deleted file mode 100644 index db84a6b99014..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureResourceProviderLogCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Management.Automation; -using Microsoft.Azure.Commands.Insights.OutputClasses; - -namespace Microsoft.Azure.Commands.Insights.Events -{ - /// - /// Get the list of events for at a ResourceProvider level. - /// - [Cmdlet(VerbsCommon.Get, "AzureResourceProviderLog"), OutputType(typeof(List))] - public class GetAzureResourceProviderLogCommand : EventCmdletBase - { - /// - /// Gets or sets the resourceprovider parameter of the cmdlet - /// - [Parameter(Position = 0, ParameterSetName = ResourceProviderName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceProvider name")] - [ValidateNotNullOrEmpty] - public string ResourceProvider { get; set; } - - /// - /// Process the parameters defined by this class (a.k.a. particular parameters) - /// - /// The current query filter - /// The query filter with the conditions for particular parameters added - protected override string ProcessParticularParameters(string currentQueryFilter) - { - return this.AddConditionIfPResent(currentQueryFilter, "resourceProvider", this.ResourceProvider); - } - } -} diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureSubscriptionIdLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureSubscriptionIdLogCommand.cs deleted file mode 100644 index 308c63ba2323..000000000000 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureSubscriptionIdLogCommand.cs +++ /dev/null @@ -1,37 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Management.Automation; -using Microsoft.Azure.Commands.Insights.OutputClasses; - -namespace Microsoft.Azure.Commands.Insights.Events -{ - /// - /// Get the list of events for at a subscription level. - /// - [Cmdlet(VerbsCommon.Get, "AzureSubscriptionIdLog"), OutputType(typeof(List))] - public class GetAzureSubscriptionIdLogCommand : EventCmdletBase - { - /// - /// Process the parameters defined by this class (a.k.a. particular parameters) - /// - /// The current query filter - /// The query filter with the conditions for particular parameters added - protected override string ProcessParticularParameters(string currentQueryFilter) - { - return currentQueryFilter; - } - } -} From cbe0d3f65d667399abe2f754b5e02f059966b4fc Mon Sep 17 00:00:00 2001 From: Shibani Medhekar Date: Fri, 18 Sep 2015 16:25:35 -0700 Subject: [PATCH 4/5] WORK: 4668268 [PowerShell][Events] Support number of events parameter --- .../Commands.Insights/EventCmdletBase.cs | 31 +- .../Events/GetAzureLogCommand.cs | 21 +- ...osoft.Azure.Commands.Insights.dll-Help.xml | 5116 +++++++++++------ 3 files changed, 3291 insertions(+), 1877 deletions(-) diff --git a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs index 1b84b708f558..2b4c342cd680 100644 --- a/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/EventCmdletBase.cs @@ -31,7 +31,8 @@ public abstract class EventCmdletBase : InsightsClientCmdletBase { private static readonly TimeSpan MaximumDateDifferenceAllowedInDays = TimeSpan.FromDays(15); private static readonly TimeSpan DefaultQueryTimeRange = TimeSpan.FromHours(1); - private const int MaxNumberOfReturnedRecords = 100000; + private const int MaxNumberOfReturnedRecords = 1000; + private int MaxEvents = 0; internal const string SubscriptionLevelName = "Query at subscription level"; internal const string ResourceProviderName = "Query on ResourceProvider"; @@ -98,6 +99,17 @@ protected virtual TimeSpan GetDefaultQueryTimeRange() return DefaultQueryTimeRange; } + /// + /// Sets the max number of records to fetch + /// + protected virtual void SetMaxEventsIfPresent(string currentQueryFilter, string name, int value) + { + if (value > 0 && value <= 100000) + { + this.MaxEvents = value; + } + } + /// /// Validates that the range of dates (start / end) makes sense, it is not to great (less 15 days), and adds the defaul values if needed /// @@ -192,6 +204,9 @@ protected override void ExecuteCmdletInternal() // Retrieve the records var fullDetails = this.DetailedOutput.IsPresent; + //Number of records to retrieve + int maxNumberOfRecords = this.MaxEvents > 0 ? this.MaxEvents : MaxNumberOfReturnedRecords; + // Call the proper API methods to return a list of raw records. In the future this pattern can be extended to include DigestRecords // If fullDetails is present do not select fields, if not present fetch only the SelectedFieldsForQuery EventDataListResponse response = this.InsightsClient.EventOperations.ListEventsAsync(filterString: queryFilter, selectedProperties: fullDetails ? null : PSEventDataNoDetails.SelectedFieldsForQuery, cancellationToken: CancellationToken.None).Result; @@ -199,15 +214,25 @@ protected override void ExecuteCmdletInternal() string nextLink = response.EventDataCollection.NextLink; // Adding a safety check to stop returning records if too many have been read already. - while (!string.IsNullOrWhiteSpace(nextLink) && records.Count < MaxNumberOfReturnedRecords) + while (!string.IsNullOrWhiteSpace(nextLink) && records.Count < maxNumberOfRecords) { response = this.InsightsClient.EventOperations.ListEventsNextAsync(nextLink: nextLink, cancellationToken: CancellationToken.None).Result; records.AddRange(response.EventDataCollection.Value.Select(e => fullDetails ? (IPSEventData)new PSEventData(e) : (IPSEventData)new PSEventDataNoDetails(e))); nextLink = response.EventDataCollection.NextLink; } + var recordsReturned = new List(); + if (records.Count > maxNumberOfRecords) + { + recordsReturned.AddRange(records.Take(maxNumberOfRecords)); + } + else + { + recordsReturned = records; + } + // Returns an object that contains a link to the set of subsequent records or null if not more records are available, called Next, and an array of records, called Value - WriteObject(sendToPipeline: records, enumerateCollection: true); + WriteObject(sendToPipeline: recordsReturned, enumerateCollection: true); } } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs index 639e8858893a..9dae1aa23f2f 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs @@ -44,27 +44,27 @@ public class GetAzureLogCommand : EventCmdletBase /// /// Gets or sets the status parameter of the cmdlet /// - [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The status of the records to fetch")] + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The status of the events to fetch")] [ValidateNotNullOrEmpty] public override string Status { get; set; } /// /// Gets or sets the caller parameter of the cmdlet /// - [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The caller of the records to fetch")] + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The caller of the events to fetch")] [ValidateNotNullOrEmpty] public override string Caller { get; set; } /// /// Gets or sets the detailedoutput parameter of the cmdlet /// - [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the records (the default is to return only some attributes, i.e. no detail)")] + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Return object with all the details of the events (the default is to return only some attributes, i.e. no detail)")] public override SwitchParameter DetailedOutput { get; set; } /// /// Gets or sets the correlationId of the cmdlet /// - [Parameter(Position = 0, ParameterSetName = CorrelationIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "CorrelationId")] + [Parameter(Position = 0, ParameterSetName = CorrelationIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The CorrelationId")] [ValidateNotNullOrEmpty] public string CorrelationId { get; set; } @@ -78,17 +78,24 @@ public class GetAzureLogCommand : EventCmdletBase /// /// Gets or sets the resourceId parameter of the cmdlet /// - [Parameter(Position = 0, ParameterSetName = ResourceIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId")] + [Parameter(Position = 0, ParameterSetName = ResourceIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceId")] [ValidateNotNullOrEmpty] public string ResourceId { get; set; } /// /// Gets or sets the resourceprovider parameter of the cmdlet /// - [Parameter(Position = 0, ParameterSetName = ResourceProviderName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceProvider name")] + [Parameter(Position = 0, ParameterSetName = ResourceProviderName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceProvider name")] [ValidateNotNullOrEmpty] public string ResourceProvider { get; set; } + /// + /// Gets or sets the max number of events to fetch parameter of the cmdlet + /// + [Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "The maximum number of events to fetch")] + [ValidateNotNullOrEmpty] + public virtual int MaxEvents { get; set; } + /// /// Process the parameters defined by this class (a.k.a. particular parameters) /// @@ -96,6 +103,8 @@ public class GetAzureLogCommand : EventCmdletBase /// The query filter with the conditions for particular parameters added protected override string ProcessParticularParameters(string currentQueryFilter) { + this.SetMaxEventsIfPresent(currentQueryFilter, "MaxEvents", this.MaxEvents); + string extendedQuery = this.AddConditionIfPResent(currentQueryFilter, "correlationId", this.CorrelationId); extendedQuery = this.AddConditionIfPResent(extendedQuery, "resourceGroupName", this.ResourceGroup); diff --git a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml index d2d56ac6b9d1..ed0bdfd07142 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml +++ b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml @@ -124,6 +124,20 @@ AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + Add-AlertRule @@ -274,6 +288,20 @@ AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + Add-AlertRule @@ -354,6 +382,20 @@ AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -537,6 +579,30 @@ + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + EventName @@ -824,6 +890,20 @@ If the rule exists, then it just disables it. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + Add-AutoscaleSetting @@ -876,6 +956,20 @@ If the rule exists, then it just disables it. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -939,6 +1033,30 @@ If the rule exists, then it just disables it. + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + Location @@ -1094,6 +1212,20 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -1121,6 +1253,30 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -1130,7 +1286,8 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< - + + @@ -1142,7 +1299,8 @@ The output of this Cmdlet is suitable to be processed by the Export-csv Cmdlet.< - + + @@ -1191,7 +1349,7 @@ foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInf - + Unknown @@ -1265,6 +1423,20 @@ foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInf AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -1352,6 +1524,30 @@ foreach($e in $s2) { Export-csv -Path ./metrics.csv -input $e -Append -NoTypeInf + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -1727,6 +1923,20 @@ SubStatus : AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + Get-AlertRule @@ -1758,6 +1968,20 @@ SubStatus : AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + Get-AlertRule @@ -1782,6 +2006,20 @@ SubStatus : AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -1833,6 +2071,30 @@ SubStatus : + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + TargetResourceId @@ -2031,6 +2293,20 @@ The output contains only basic information about the alert rule. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -2118,6 +2394,30 @@ The output contains only basic information about the alert rule. + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -2395,6 +2695,20 @@ SubStatus : AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -2446,6 +2760,30 @@ SubStatus : + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -2729,23 +3067,210 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - Get-AzureCorrelationIdLog + Get-AzureLog - Gets the operations associated with a CorrelationId + Gets the events associated with the current SubscriptionId or CorrelationId or Resource Group or ResourceId or Resource Provider Get - AzureCorrelationIdLog + AzureLog - Gets the operations associated with a CorrelationId. + Gets the events associated with the current SubscriptionId or CorrelationId or Resource Group or ResourceId or Resource Provider. - Get-AzureCorrelationIdLog + Get-AzureLog + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + + ResourceGroup + + Specifies a filter by ResourceGroup. This parameter is mandatory. + + String + + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + Get-AzureLog + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + + ResourceProvider + + Specifies a filter by ResourceProvider. This parameter is mandatory. + + String + + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + Get-AzureLog + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + CorrelationId @@ -2753,6 +3278,37 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese String + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + Get-AzureLog StartTime @@ -2790,6 +3346,20 @@ The value must be earlier than StartTime, but not more than 15 days. SwitchParameter + + ResourceId + + Specifies a filter by ResoruceId. This parameter is mandatory. + + String + + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + Profile @@ -2797,43 +3367,113 @@ The value must be earlier than StartTime, but not more than 15 days. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + - - - - CorrelationId - - Specifies a filter by correlationId. This parameter is mandatory. - - String - - String - - - - - - StartTime - - Specifies the start time of the query in local time. This parameter is optional. + + Get-AzureLog + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. The default is EndTime minus one hour. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - EndTime minus one hour - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - Nullable`1[DateTime] + + Nullable`1[DateTime] + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + String + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + SwitchParameter + + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + Nullable`1[DateTime] + + Nullable`1[DateTime] + + + EndTime minus one hour + + + EndTime + + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. + + Nullable`1[DateTime] + + Nullable`1[DateTime] Current time @@ -2874,6 +3514,30 @@ The value must be earlier than StartTime, but not more than 15 days. + + ResourceGroup + + Specifies a filter by ResourceGroup. This parameter is mandatory. + + String + + String + + + + + + MaxEvents + + If present it indicates total number of events to be fetched for the filter specified. This parameter is optional. The default is 1000. + + Int32 + + Int32 + + + + Profile @@ -2886,6 +3550,66 @@ The value must be earlier than StartTime, but not more than 15 days. + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + + + ResourceProvider + + Specifies a filter by ResourceProvider. This parameter is mandatory. + + String + + String + + + + + + CorrelationId + + Specifies a filter by correlationId. This parameter is mandatory. + + String + + String + + + + + + ResourceId + + Specifies a filter by ResoruceId. This parameter is mandatory. + + String + + String + + + + @@ -2895,8 +3619,7 @@ The value must be earlier than StartTime, but not more than 15 days. - - + @@ -2908,8 +3631,7 @@ The value must be earlier than StartTime, but not more than 15 days. - - + @@ -2923,13 +3645,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureCorrelationIdLog -------------------------- + -------------------------- Example 1: GetAzureLog by SubscriptionId -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + PS C:\>Get-AzureLog - This command lists all the operations associated to the given CorrelationId that took place in the last hour. + This command lists all the events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. @@ -2943,13 +3665,14 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureCorrelationIdLog with starttime only -------------------------- + -------------------------- Example 2: GetAzureLog by SubscriptionId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + PS C:\>Get-AzureLog -MaxEvents 100 + - This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. + This command lists maximum of 100 events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. @@ -2963,13 +3686,15 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureCorrelationIdLog with start and end times -------------------------- + -------------------------- Example 2: GetAzureLog by SubscriptionId with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + PS C:\>Get-AzureLog -StartTime 2015-01-01T10:30 + + - This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists all the events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time. @@ -2982,234 +3707,15 @@ The value must be earlier than StartTime, but not more than 15 days. - - - - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 - - - Get-AzureSubscriptionIdLog - - - - Get-AzureResourceGroupLog - - - - Get-AzureResourceLog - - - - Get-AzureResourceProviderLog - - - - - - - - Get-AzureResourceGroupLog - - Gets the operations associated with a Resource Group - - - - - Get - AzureResourceGroupLog - - - - Gets the operations associated with a Resource Group. - - - - Get-AzureResourceGroupLog - - ResourceGroup - - Specifies a filter by ResourceGroup. This parameter is mandatory. - - String - - - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - - Caller - - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - - DetailedOutput - - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - - SwitchParameter - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - - - - - ResourceGroup - - Specifies a filter by ResourceGroup. This parameter is mandatory. - - String - - String - - - - - - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - EndTime minus one hour - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - Current time - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - String - - - - - - Caller - - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - String - - - - - - DetailedOutput - - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - - SwitchParameter - - SwitchParameter - - - - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - AzureProfile - - - - - - - - - None - - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------------------- Example 1: GetAzureResourceGroupLog -------------------------- + -------------------------- Example 4: GetAzureLog by SubscriptionId with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS + PS C:\>Get-AzureLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + - This command lists all the operations associated to the given Resource Group that took place in the last hour. + This command lists all the events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -3223,13 +3729,14 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureResourceGroupLog with starttime only -------------------------- + -------------------------- Example 5: GetAzureLog by CorrelationId -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + - This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. + This command lists all the events associated to the given CorrelationId that took place in the last hour. @@ -3243,13 +3750,13 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceGroupLog with start and end times -------------------------- + -------------------------- Example 6: GetAzureLog by CorrelationId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -MaxEvents 100 - This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists maximum of 100 events associated to the given CorrelationId that took place in the last hour. @@ -3262,238 +3769,162 @@ The value must be earlier than StartTime, but not more than 15 days. - - - - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 - - - Get-AzureSubscriptionIdLog - - - - Get-AzureCorrelationIdLog - - - - Get-AzureResourceLog - - - - Get-AzureResourceProviderLog - - - - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 - - - - - - - Get-AzureResourceLog - - Gets the operations associated with a ResourceId - - - - - Get - AzureResourceLog - - - - Gets the operations associated with a ResourceId. - - - - Get-AzureResourceLog - - ResourceId - - Specifies a filter by ResoruceId. This parameter is mandatory. - - String - - - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - - Caller - - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - - DetailedOutput - - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - - SwitchParameter - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - - - - - ResourceId - - Specifies a filter by ResoruceId. This parameter is mandatory. - - String - - String - - - - - - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - EndTime minus one hour - - - EndTime - - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - Current time - - - Status - - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - String - - - - - - Caller - - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - - String - - String - - - - - - DetailedOutput - - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - - SwitchParameter - - SwitchParameter - - - - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - AzureProfile - - - - - - - - - None - - - - - - - - - - - - - None - - - - - + + -------------------------- Example 7: GetAzureLog by CorrelationId with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + + + This command lists all the events associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 8: GetAzureLog by CorrelationId with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + + + This command lists all the events associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + + + -------------------------- Example 9: GetAzureLog by ResourceGroup -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS + + This command lists all the events associated to the given Resource Group that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 10: GetAzureLog by ResourceGroup with MaxEvents -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -MaxEvents 100 + + + This command lists maximum of 100 events associated to the given Resource Group that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 11: GetAzureLog by ResourceGroup with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 + + + This command lists all the events associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 12: GetAzureLog by ResourceGroup with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + + + This command lists all the events associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + + + -------------------------- Example 13: GetAzureLog by ResourceId -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 + + + This command lists all the events associated to the given ResourceId that took place in the last hour. - - - - - - - - - - - - + + + + + + + + + + + + - -------------------------- Example 1: GetAzureResourceLog -------------------------- + -------------------------- Example 14: GetAzureLog by ResourceId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 + PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -MaxEvents 100 - This command lists all the operations associated to the given ResourceId that took place in the last hour. + This command lists maximum of 100 events associated to the given ResourceId that took place in the last hour. + @@ -3507,13 +3938,14 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureResourceLog with starttime only -------------------------- + -------------------------- Example 15: GetAzureLog by ResourceId with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 + - This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. + This command lists all the events associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. @@ -3527,13 +3959,14 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceLog with start and end times -------------------------- + -------------------------- Example 16: GetAzureLog by ResourceId with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + - This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + This command lists all the events associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -3546,108 +3979,168 @@ The value must be earlier than StartTime, but not more than 15 days. - - - - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 - - - Get-AzureSubscriptionIdLog - - - - Get-AzureCorrelationIdLog - - - - Get-AzureResourceGroupLog - - + + -------------------------- Example 17: GetAzureLog by ResourceProvider -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web + + + This command lists all the events associated to the given Resource Provider that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 18: GetAzureLog by ResourceProvider with MaxEvents -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -MaxEvents 100 + + + This command lists maximum of 100 events associated to the given Resource Provider that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 19: GetAzureLog by ResourceProvider with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 + + + This command lists all the events associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 20: GetAzureLog by ResourceProvider with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + + + This command lists all the events associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + + + + - Get-AzureResourceProviderLog - + Online Version + http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureResourceProviderLog + Get-MetricDefinitions - Gets the operations associated with a Resource Provider + Retrieves the metric definitions. Get - AzureResourceProviderLog + MetricDefinitions - Gets the operations associated with a Resource Provider. + Retrieves the metric definitions. - Get-AzureResourceProviderLog + Get-MetricDefinitions - ResourceProvider + ResourceId - Specifies a filter by ResourceProvider. This parameter is mandatory. + The id of the resource the metric is associated to. String - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - - EndTime + MetricNames - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + An array of names of metrics to retrieve their definitions. - Nullable`1[DateTime] + String[] - Status + DetailedOutput - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) - String + SwitchParameter - - Caller + + Profile - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + In-memory profile (AzureProfile). - String + AzureProfile - - DetailedOutput + + InformationAction - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + - SwitchParameter + ActionPreference - Profile + InformationVariable - In-memory profile (AzureProfile). + - AzureProfile + String - ResourceProvider + ResourceId - Specifies a filter by ResourceProvider. This parameter is mandatory. + The id of the resource the metric is associated to. String @@ -3657,75 +4150,61 @@ The value must be earlier than StartTime, but not more than 15 days. - StartTime - - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. - - Nullable`1[DateTime] - - Nullable`1[DateTime] - - - EndTime minus one hour - - - EndTime + MetricNames - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + An array of names of metrics to retrieve their definitions. - Nullable`1[DateTime] + String[] - Nullable`1[DateTime] + String[] - Current time + - Status + DetailedOutput - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) - String + SwitchParameter - String + SwitchParameter - + false - - Caller + + Profile - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + In-memory profile (AzureProfile). - String + AzureProfile - String + AzureProfile - - DetailedOutput + + InformationAction - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + - SwitchParameter + ActionPreference - SwitchParameter + ActionPreference - Profile + InformationVariable - In-memory profile (AzureProfile). + - AzureProfile + String - AzureProfile + String @@ -3734,7 +4213,7 @@ The value must be earlier than StartTime, but not more than 15 days. - None + @@ -3747,7 +4226,7 @@ The value must be earlier than StartTime, but not more than 15 days. - None + @@ -3767,36 +4246,34 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureResourceProviderLog -------------------------- - - PS C:\> - - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web - - This command lists all the operations associated to the given Resource Provider that took place in the last hour. - - - - - - - - - - - - - - -------------------------- Example 2: GetAzureResourceProviderLog with starttime only -------------------------- + -------------------------- Example 1: Summarized output -------------------------- PS C:\> - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 - This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. + Gets all the metrics definitions for the given resource (identified by the ResourceId) - + Name : CpuTime +Dimensions : {} +MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability} +PrimaryAggregationType : Total +Properties : {} +ResourceUri : +Unit : Seconds + +Name : Requests +Dimensions : {} +MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability, + Microsoft.Azure.Insights.Models.MetricAvailability} +PrimaryAggregationType : Total +Properties : {} +ResourceUri : +Unit : Count @@ -3807,18 +4284,102 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureResourceProviderLog with start and end times -------------------------- + -------------------------- Example 2: Detailed output -------------------------- PS C:\> - PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det - This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + Gets all the metrics definitions for the given resource (identified by the ResourceId). The results are detailed. - - - + Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : CpuTime +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Seconds + +Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : Requests +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Count + + + + + + + + + + + -------------------------- Example 3: Filtered detailed output -------------------------- + + PS C:\> + + get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det -met BytesSent,CpuTime + + Gets one two metric definitions for the given resource (identified by the ResourceId). The results are detailed. + + + Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : CpuTime +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Seconds + +Dimensions : +MetricAvailabilities : + Location : + Retention : 2.00:00:00 + Values : 00:01:00 + Location : + Retention : 30.00:00:00 + Values : 01:00:00 + Location : + Retention : 90.00:00:00 + Values : 1.00:00:00 +Name : BytesSent +Properties : +PrimaryAggregationType : Total +ResourceUri : +Unit : Bytes + + @@ -3833,19 +4394,7 @@ The value must be earlier than StartTime, but not more than 15 days. http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureSubscriptionIdLog - - - - Get-AzureCorrelationIdLog - - - - Get-AzureResourceGroupLog - - - - Get-AzureResourceLog + Get-Metrics @@ -3853,57 +4402,62 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureSubscriptionIdLog + Get-Metrics - Gets the operations associated with the current subscriptionId + Retrieves the metric values of a resource. Get - AzureSubscriptionIdLog + Metrics - Gets the operations associated with the current subscriptionId. + Retrieves the metric values of a resource that comply with certain criteria. - Get-AzureSubscriptionIdLog - - StartTime + Get-Metrics + + ResourceId - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. + The id of the resource the metric is associated to. - Nullable`1[DateTime] + String - - EndTime + + TimeGrain - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - Nullable`1[DateTime] + TimeSpan - Status + StartTime - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + Earliest Date/Time to search for metric values. - String + DateTime - Caller + EndTime - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + Latest Time/Date to search for metric values. - String + DateTime + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter @@ -3914,55 +4468,79 @@ The value must be earlier than StartTime, but not more than 15 days. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + - - StartTime + + ResourceId - Specifies the start time of the query in local time. This parameter is optional. -The default is EndTime minus one hour. + The id of the resource the metric is associated to. - Nullable`1[DateTime] + String - Nullable`1[DateTime] + String - - EndTime + + TimeGrain - Specifies the end time of the query in local time. This parameter is optional. The default is the current time. -The value must be earlier than StartTime, but not more than 15 days. + The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - Nullable`1[DateTime] + TimeSpan - Nullable`1[DateTime] + TimeSpan - Current time + - Status + StartTime - Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + Earliest Date/Time to search for metric values. - String + DateTime - String + DateTime - + EndTime - 1 hour - Caller + EndTime - Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + Latest Time/Date to search for metric values. - String + DateTime - String + DateTime + + + Now + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] + + String[] @@ -3970,14 +4548,14 @@ The value must be earlier than StartTime, but not more than 15 days. DetailedOutput - If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) SwitchParameter SwitchParameter - + false Profile @@ -3991,11 +4569,35 @@ The value must be earlier than StartTime, but not more than 15 days. + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + - None + @@ -4008,7 +4610,7 @@ The value must be earlier than StartTime, but not more than 15 days. - None + @@ -4028,36 +4630,91 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureSubscriptionIdLog -------------------------- + -------------------------- Example 1: Summarized output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. + Retrieves the metric values for website3 with a time grain of 1 minute - - - - - - - - - - - - -------------------------- Example 2: GetAzureSubscriptionIdLog with starttime only -------------------------- + DimensionName : +DimensionValue : +Name : AverageResponseTime +EndTime : 3/20/2015 6:40:46 PM +MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, + Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} +Properties : {} +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:40:00 PM +TimeGrain : 00:01:00 +Unit : Seconds + +DimensionName : +DimensionValue : +Name : AverageMemoryWorkingSet +EndTime : 3/20/2015 6:40:46 PM +MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, + Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} +Properties : {} +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:40:00 PM +TimeGrain : 00:01:00 +Unit : Bytes + + + + + + + + + + + -------------------------- Example 2: Detailed output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time. + Retrieves the metric values for website3 with a time grain of 1 minute. The output is detailed. - + MetricValues : + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:37:00 PM + Total : 0 + Average : 0.106 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:39:00 PM + Total : 0.106 + Average : 0.064 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:41:00 PM + Total : 0.064 +Properties : +DimensionName : +DimensionValue : +Name : AverageResponseTime +EndTime : 3/20/2015 6:43:33 PM +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:43:00 PM +TimeGrain : 00:01:00 +Unit : Seconds @@ -4068,16 +4725,65 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 3: GetAzureSubscriptionIdLog with start and end times -------------------------- + -------------------------- Example 3: Filtered detailed output -------------------------- PS C:\> - PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det -met Requests - This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. - + + MetricValues : + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:39:00 PM + Total : 1 + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:41:00 PM + Total : 1 + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:43:00 PM + Total : 0 + Average : 1 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:44:00 PM + Total : 1 + Average : 0 + Count : 1 + Last : + Maximum : + Minimum : + Properties : + Timestamp : 3/20/2015 6:45:00 PM + Total : 0 +Properties : +DimensionName : +DimensionValue : +Name : Requests +EndTime : 3/20/2015 6:47:56 PM +ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 +StartTime : 3/20/2015 5:47:00 PM +TimeGrain : 00:01:00 +Unit : Count @@ -4094,19 +4800,11 @@ The value must be earlier than StartTime, but not more than 15 days. http://go.microsoft.com/fwlink/?LinkID=397618 - Get-AzureCorrelationIdLog - - - - Get-AzureResourceGroupLog - - - - Get-AzureResourceLog + Get-MetricDefinitions - Get-AzureResourceProviderLog + Format-MetricsAsTable @@ -4114,23 +4812,23 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-MetricDefinitions + Get-UsageMetrics - Retrieves the metric definitions. + Retrieves the usage metric values of a resource. Get - MetricDefinitions + UsageMetrics - Retrieves the metric definitions. + Retrieves the usage metric values of a resource that comply with certain criteria. - Get-MetricDefinitions + Get-UsageMetrics ResourceId @@ -4138,19 +4836,33 @@ The value must be earlier than StartTime, but not more than 15 days. String - - MetricNames + + ApiVersion - An array of names of metrics to retrieve their definitions. + Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. - String[] + String - DetailedOutput + StartTime - If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) + Earliest Date/Time to search for metric values. - SwitchParameter + DateTime + + + EndTime + + Latest Time/Date to search for metric values. + + DateTime + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] Profile @@ -4159,6 +4871,20 @@ The value must be earlier than StartTime, but not more than 15 days. AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + @@ -4174,29 +4900,53 @@ The value must be earlier than StartTime, but not more than 15 days. - - MetricNames + + ApiVersion - An array of names of metrics to retrieve their definitions. + Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. - String[] + String - String[] + String - DetailedOutput + StartTime - If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) + Earliest Date/Time to search for metric values. - SwitchParameter + DateTime - SwitchParameter + DateTime - false + EndTime - 1 hour + + + EndTime + + Latest Time/Date to search for metric values. + + DateTime + + DateTime + + + Local current date/time. + + + MetricNames + + An array of names of metrics to retrieve their values. + + String[] + + String[] + + + Profile @@ -4210,6 +4960,30 @@ The value must be earlier than StartTime, but not more than 15 days. + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -4219,7 +4993,8 @@ The value must be earlier than StartTime, but not more than 15 days. - + + @@ -4231,7 +5006,8 @@ The value must be earlier than StartTime, but not more than 15 days. - + + @@ -4245,139 +5021,16 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: Summarized output -------------------------- - - PS C:\> - - get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 - - - Gets all the metrics definitions for the given resource (identified by the ResourceId) - - - Name : CpuTime -Dimensions : {} -MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, - Microsoft.Azure.Insights.Models.MetricAvailability, - Microsoft.Azure.Insights.Models.MetricAvailability} -PrimaryAggregationType : Total -Properties : {} -ResourceUri : -Unit : Seconds - -Name : Requests -Dimensions : {} -MetricAvailabilities : {Microsoft.Azure.Insights.Models.MetricAvailability, - Microsoft.Azure.Insights.Models.MetricAvailability, - Microsoft.Azure.Insights.Models.MetricAvailability} -PrimaryAggregationType : Total -Properties : {} -ResourceUri : -Unit : Count - - - - - - - - - - - -------------------------- Example 2: Detailed output -------------------------- - - PS C:\> - - get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det - - Gets all the metrics definitions for the given resource (identified by the ResourceId). The results are detailed. - - - Dimensions : -MetricAvailabilities : - Location : - Retention : 2.00:00:00 - Values : 00:01:00 - Location : - Retention : 30.00:00:00 - Values : 01:00:00 - Location : - Retention : 90.00:00:00 - Values : 1.00:00:00 -Name : CpuTime -Properties : -PrimaryAggregationType : Total -ResourceUri : -Unit : Seconds - -Dimensions : -MetricAvailabilities : - Location : - Retention : 2.00:00:00 - Values : 00:01:00 - Location : - Retention : 30.00:00:00 - Values : 01:00:00 - Location : - Retention : 90.00:00:00 - Values : 1.00:00:00 -Name : Requests -Properties : -PrimaryAggregationType : Total -ResourceUri : -Unit : Count - - - - - - - - - - - -------------------------- Example 3: Filtered detailed output -------------------------- + -------------------------- Example 1: Querying with resourceId only -------------------------- PS C:\> - get-metricdefinitions -res /subscriptions/d33fb0c7-69d3-40be-e35b-4f0deba70fff/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website2 -det -met BytesSent,CpuTime + get-usagemetrics -res /subscriptions/bcdeb07f-1c43-20be-1f3b-4f0febc10f5b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/johnsmith - Gets one two metric definitions for the given resource (identified by the ResourceId). The results are detailed. + Query the usage metrics for a website - Dimensions : -MetricAvailabilities : - Location : - Retention : 2.00:00:00 - Values : 00:01:00 - Location : - Retention : 30.00:00:00 - Values : 01:00:00 - Location : - Retention : 90.00:00:00 - Values : 1.00:00:00 -Name : CpuTime -Properties : -PrimaryAggregationType : Total -ResourceUri : -Unit : Seconds - -Dimensions : -MetricAvailabilities : - Location : - Retention : 2.00:00:00 - Values : 00:01:00 - Location : - Retention : 30.00:00:00 - Values : 01:00:00 - Location : - Retention : 90.00:00:00 - Values : 1.00:00:00 -Name : BytesSent -Properties : -PrimaryAggregationType : Total -ResourceUri : -Unit : Bytes + @@ -4393,74 +5046,62 @@ Unit : Bytes Online Version: http://go.microsoft.com/fwlink/?LinkID=397618 - - Get-Metrics - - - Get-Metrics + New-AutoscaleProfile - Retrieves the metric values of a resource. + Creates an autoscale profile. - Get - Metrics + New + AutoscaleProfile - Retrieves the metric values of a resource that comply with certain criteria. + Creates an autoscale profile. - Get-Metrics - - ResourceId + New-AutoscaleProfile + + Name - The id of the resource the metric is associated to. + The name of the profile. String - - TimeGrain - - The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - - TimeSpan - - - StartTime + + DefaultCapacity - Earliest Date/Time to search for metric values. + The default capacity. - DateTime + String - - EndTime + + MaximumCapacity - Latest Time/Date to search for metric values. - + The maximum capacity. - DateTime + String - - MetricNames + + MinimumCapacity - An array of names of metrics to retrieve their values. + The minimum capacity. - String[] + String - - DetailedOutput + + Rules - If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) + The list of rules to add to the newly created profile. - SwitchParameter + List`1[ScaleRule] Profile @@ -4469,81 +5110,850 @@ Unit : Bytes AzureProfile + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + - - - - ResourceId - - The id of the resource the metric is associated to. - - String - - String - - - - - - TimeGrain - - The time grain of the metric given as a TimeSpan (i.e. hh:mm:ss). - - TimeSpan - - TimeSpan - - - - - - StartTime - - Earliest Date/Time to search for metric values. - - DateTime - - DateTime - - - EndTime - 1 hour - - - EndTime - - Latest Time/Date to search for metric values. - - - DateTime - - DateTime - - - Now - - - MetricNames - - An array of names of metrics to retrieve their values. + + New-AutoscaleProfile + + Name + + The name of the profile. + + String + + + DefaultCapacity + + The default capacity. + + String + + + MaximumCapacity + + The maximum capacity. + + String + + + MinimumCapacity + + The minimum capacity. + + String + + + StartTimeWindow + + The start of the time window. + + DateTime + + + EndTimeWindow + + The end of the time window. + + DateTime + + + TimeWindowTimeZone + + The time zone of the time window. + + String + + + Rules + + The list of rules to add to the newly created profile. + + List`1[ScaleRule] + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + New-AutoscaleProfile + + Name + + The name of the profile. + + String + + + DefaultCapacity + + The default capacity. + + String + + + MaximumCapacity + + The maximum capacity. + + String + + + MinimumCapacity + + The minimum capacity. + + String + + + RecurrenceFrequency + + The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. + + RecurrenceFrequency + + + ScheduleDays + + A list of days scheduled. + + List`1[String] + + + ScheduleHours + + A list of scheduled hours. + + List`1[Int32] + + + ScheduleMinutes + + List of scheduled minutes. + + List`1[Int32] + + + ScheduleTimeZone + + The time zone of the schedule. + + String + + + Rules + + The list of rules to add to the newly created profile. + + List`1[ScaleRule] + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + + + Name + + The name of the profile. + + String + + String + + + + + + DefaultCapacity + + The default capacity. + + String + + String + + + + + + MaximumCapacity + + The maximum capacity. + + String + + String + + + + + + MinimumCapacity + + The minimum capacity. + + String + + String + + + + + + Rules + + The list of rules to add to the newly created profile. + + List`1[ScaleRule] + + List`1[ScaleRule] + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + + + StartTimeWindow + + The start of the time window. + + DateTime + + DateTime + + + + + + EndTimeWindow + + The end of the time window. + + DateTime + + DateTime + + + + + + TimeWindowTimeZone + + The time zone of the time window. + + String + + String + + + + + + RecurrenceFrequency + + The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. + + RecurrenceFrequency + + RecurrenceFrequency + + + + + + ScheduleDays + + A list of days scheduled. + + List`1[String] + + List`1[String] + + + + + + ScheduleHours + + A list of scheduled hours. + + List`1[Int32] + + List`1[Int32] + + + + + + ScheduleMinutes + + List of scheduled minutes. + + List`1[Int32] + + List`1[Int32] + + + + + + ScheduleTimeZone + + The time zone of the schedule. + + String + + String + + + + + + Profiles + + List of profiles to add to the result. + + list`1[autoscaleprofile] + + list`1[autoscaleprofile] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Create single profile, fixed date -------------------------- + + PS C:\> + + $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + +$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -StartTimeWindow 2015-03-05T14:00:00 -EndTimeWindow 2015-03-05T14:30:00 -TimeWindowTimeZone GMT -Rules $rule -Name "adios" + + Creates a single profile without a schedule (fix date) + + + Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity +FixedDate : Microsoft.Azure.Management.Insights.Models.TimeWindow +Name : adios +Recurrence : +Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, + Microsoft.Azure.Management.Insights.Models.ScaleRule} + + + + + + + + + + + -------------------------- Example 2: Create single profile with schedule -------------------------- + + PS C:\> + + $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + +$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule -Name "secondProfileName" -RecurrenceFrequency Minute -ScheduleDays "1", "2", "3" -ScheduleHours 5, 10, 15 -ScheduleMinutes 15, 30, 45 -ScheduleTimeZone GMT + + Creates a single profile with a recurrent schedule. + + + Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity +FixedDate : +Name : secondProfileName +Recurrence : Microsoft.Azure.Management.Insights.Models.Recurrence +Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, + Microsoft.Azure.Management.Insights.Models.ScaleRule} + + + + + + + + + + + -------------------------- Example 3: Create two profiles -------------------------- + + PS C:\> + + $rule1 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + +$rule2 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:10:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "2" + +$profile1 = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -StartTimeWindow 2015-03-05T14:00:00 -EndTimeWindow 2015-03-05T14:30:00 -TimeWindowTimeZone GMT -Rules $rule1, $rule2 -Name "profileName" + +$profile2 = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule1, $rule2 -Name "secondProfileName" -RecurrenceFrequency Week -ScheduleDays "1" -ScheduleHours 5 -ScheduleMinutes 15 -ScheduleTimeZone UTC + + Creates two profiles adds them to a list. + + + Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity +FixedDate : Microsoft.Azure.Management.Insights.Models.TimeWindow +Name : profileName +Recurrence : +Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, + Microsoft.Azure.Management.Insights.Models.ScaleRule} + +Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity +FixedDate : +Name : secondProfileName +Recurrence : Microsoft.Azure.Management.Insights.Models.Recurrence +Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, + Microsoft.Azure.Management.Insights.Models.ScaleRule} + + + + + + + + + + + -------------------------- Example 4: Create single profile, no scheduled time -------------------------- + + PS C:\> + + $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + +$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule -Name "profileName" + + Creates a single profile without a schedule or a fixed date + + + + + + + + + + + + + + + + New-AutoscaleRule + + + + Add-AutoscaleSetting + + + + Get-AutoscaleSetting + + + + Remove-AutoscaleSetting + + + + Get-AutoscaleHistory + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + + + + + New-AutoscaleRule + + Create an autoscale rule. + + + + + New + AutoscaleRule + + + + Create an autoscale rule. + + + + New-AutoscaleRule + + MetricName + + The metric name. + + String + + + MetricResourceId + + The metric resource Id. + + String + + + Operator + + The operator. Allowed values are: Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual + + ComparisonOperationType + + + MetricStatistic + + The metric statistic. The allowed values are: Average, Min, Max, Sum. + + MetricStatisticType + + + Threshold + + The threshold of the metric value. + + Double + + + TimeAggregationOperator + + The time aggregation operator. The allowed values are: Average, Minimum, Maximum, Last, Total, Count. + + TimeAggregationType + + + TimeGrain + + The time grain. + + TimeSpan + + + TimeWindow + + The time window. + + TimeSpan + + + ScaleActionCooldown + + Autoscale action cooldown time. + + TimeSpan + + + ScaleActionDirection + + The scale action direction. The allowed values are: None, Increase, Decrease. + + ScaleDirection + + + ScaleActionScaleType + + The scale type. The allowed values are: ChangeSize, ChangeCount, PercentChangeCount, ExactCount. + + ScaleType + + + ScaleActionValue + + The action value. + + String + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + + InformationAction + + + + ActionPreference + + + InformationVariable + + + + String + + + + + + MetricName + + The metric name. - String[] + String - String[] + String + + + + + + MetricResourceId + + The metric resource Id. + + String + + String + + + + + + Operator + + The operator. Allowed values are: Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual + + ComparisonOperationType + + ComparisonOperationType + + + + + + MetricStatistic + + The metric statistic. The allowed values are: Average, Min, Max, Sum. + + MetricStatisticType + + MetricStatisticType + + + + + + Threshold + + The threshold of the metric value. + + Double + + Double - DetailedOutput + TimeAggregationOperator - If present it indicates that the output will be detailed. This parameter is optional. The default is false (i.e. summarized output.) + The time aggregation operator. The allowed values are: Average, Minimum, Maximum, Last, Total, Count. - SwitchParameter + TimeAggregationType - SwitchParameter + TimeAggregationType - false + + + + TimeGrain + + The time grain. + + TimeSpan + + TimeSpan + + + + + + TimeWindow + + The time window. + + TimeSpan + + TimeSpan + + + + + + ScaleActionCooldown + + Autoscale action cooldown time. + + TimeSpan + + TimeSpan + + + + + + ScaleActionDirection + + The scale action direction. The allowed values are: None, Increase, Decrease. + + ScaleDirection + + ScaleDirection + + + + + + ScaleActionScaleType + + The scale type. The allowed values are: ChangeSize, ChangeCount, PercentChangeCount, ExactCount. + + ScaleType + + ScaleType + + + + + + ScaleActionValue + + The action value. + + String + + String + + + Profile @@ -4557,6 +5967,30 @@ Unit : Bytes + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + @@ -4566,7 +6000,8 @@ Unit : Bytes - + + @@ -4579,7 +6014,7 @@ Unit : Bytes - + @@ -4588,96 +6023,23 @@ Unit : Bytes - - - - - - -------------------------- Example 1: Summarized output -------------------------- - - PS C:\> - - get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 - - Retrieves the metric values for website3 with a time grain of 1 minute - - - DimensionName : -DimensionValue : -Name : AverageResponseTime -EndTime : 3/20/2015 6:40:46 PM -MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, - Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} -Properties : {} -ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -StartTime : 3/20/2015 5:40:00 PM -TimeGrain : 00:01:00 -Unit : Seconds - -DimensionName : -DimensionValue : -Name : AverageMemoryWorkingSet -EndTime : 3/20/2015 6:40:46 PM -MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue, - Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...} -Properties : {} -ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -StartTime : 3/20/2015 5:40:00 PM -TimeGrain : 00:01:00 -Unit : Bytes - - - - - - - - - + + + + - -------------------------- Example 2: Detailed output -------------------------- + -------------------------- Example 1: Create single rule -------------------------- PS C:\> - get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det + $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - Retrieves the metric values for website3 with a time grain of 1 minute. The output is detailed. + Creates a single rule. - MetricValues : - Average : 0 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:37:00 PM - Total : 0 - Average : 0.106 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:39:00 PM - Total : 0.106 - Average : 0.064 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:41:00 PM - Total : 0.064 -Properties : -DimensionName : -DimensionValue : -Name : AverageResponseTime -EndTime : 3/20/2015 6:43:33 PM -ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -StartTime : 3/20/2015 5:43:00 PM -TimeGrain : 00:01:00 -Unit : Seconds + MetricTrigger ScaleAction +------------- ----------- +Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction @@ -4688,65 +6050,21 @@ Unit : Seconds - -------------------------- Example 3: Filtered detailed output -------------------------- + -------------------------- Example 2: Create two rules -------------------------- PS C:\> - get-metrics -res /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -time 00:01:00 -det -met Requests + $rule1 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + +$rule2 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:10:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "2" + Creates two rules. - - MetricValues : - Average : 1 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:39:00 PM - Total : 1 - Average : 1 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:41:00 PM - Total : 1 - Average : 0 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:43:00 PM - Total : 0 - Average : 1 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:44:00 PM - Total : 1 - Average : 0 - Count : 1 - Last : - Maximum : - Minimum : - Properties : - Timestamp : 3/20/2015 6:45:00 PM - Total : 0 -Properties : -DimensionName : -DimensionValue : -Name : Requests -EndTime : 3/20/2015 6:47:56 PM -ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3 -StartTime : 3/20/2015 5:47:00 PM -TimeGrain : 00:01:00 -Unit : Count + MetricTrigger ScaleAction +------------- ----------- +Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction +Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction @@ -4759,88 +6077,93 @@ Unit : Count - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 + New-AutoscaleProfile + - Get-MetricDefinitions + Add-AutoscaleSetting - Format-MetricsAsTable + Get-AutoscaleSetting + + + + Remove-AutoscaleSetting + + + + Get-AutoscaleHistory + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + - Get-UsageMetrics + Remove-AlertRule - Retrieves the usage metric values of a resource. + Removes an alert rule. - Get - UsageMetrics + Remove + AlertRule - Retrieves the usage metric values of a resource that comply with certain criteria. + Removes and alert rule identified by name and resource group name. - Get-UsageMetrics - - ResourceId + Remove-AlertRule + + ResourceGroup - The id of the resource the metric is associated to. + The name of the resource group where the alert is included. String - - ApiVersion + + Name - Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. + Name of the alert rule to remove. String - - StartTime - - Earliest Date/Time to search for metric values. - - DateTime - - - EndTime + + Profile - Latest Time/Date to search for metric values. + In-memory profile (AzureProfile). - DateTime + AzureProfile - - MetricNames + + InformationAction - An array of names of metrics to retrieve their values. + - String[] + ActionPreference - Profile + InformationVariable - In-memory profile (AzureProfile). + - AzureProfile + String - - ResourceId + + ResourceGroup - The id of the resource the metric is associated to. + The name of the resource group where the alert is included. String @@ -4849,10 +6172,10 @@ Unit : Count - - ApiVersion + + Name - Api version string, e.g.: 2014-04-01 (default values), accepted by the resource provider. + Name of the alert rule to remove. String @@ -4861,50 +6184,38 @@ Unit : Count - - StartTime - - Earliest Date/Time to search for metric values. - - DateTime - - DateTime - - - EndTime - 1 hour - - - EndTime + + Profile - Latest Time/Date to search for metric values. + In-memory profile (AzureProfile). - DateTime + AzureProfile - DateTime + AzureProfile - Local current date/time. + - - MetricNames + + InformationAction - An array of names of metrics to retrieve their values. + - String[] + ActionPreference - String[] + ActionPreference - Profile + InformationVariable - In-memory profile (AzureProfile). + - AzureProfile + String - AzureProfile + String @@ -4918,7 +6229,8 @@ Unit : Count - + + @@ -4930,7 +6242,8 @@ Unit : Count - + + @@ -4944,15 +6257,18 @@ Unit : Count - -------------------------- Example 1: Querying with resourceId only -------------------------- + -------------------------- Example 1: removing an alert rule -------------------------- PS C:\> - get-usagemetrics -res /subscriptions/bcdeb07f-1c43-20be-1f3b-4f0febc10f5b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/johnsmith + remove-alertrule -res Default-Web-CentralUS -n myalert-7da64548-214d-42ca-b12b-b245bb8f0ac8 - Query the usage metrics for a website + Removes the alert rule identified by name and resource group name. + RequestId StatusCode +--------- ---------- +2c6c159b-0e73-4a01-a67b-c32c1a0008a3 OK @@ -4964,6 +6280,18 @@ Unit : Count + + Add-AlertRule + + + + Get-AlertRule + + + + Get-AlertHistory + + Online Version: http://go.microsoft.com/fwlink/?LinkID=397618 @@ -4973,159 +6301,37 @@ Unit : Count - New-AutoscaleProfile + Remove-AutoscaleSetting - Creates an autoscale profile. + Removes an autoscale setting - New - AutoscaleProfile + Remove + AutoscaleSetting - Creates an autoscale profile. + Removes an autoscale setting identified by a resource group name and the setting name - New-AutoscaleProfile - - Name - - The name of the profile. - - String - - - DefaultCapacity - - The default capacity. - - String - - - MaximumCapacity - - The maximum capacity. - - String - - - MinimumCapacity - - The minimum capacity. - - String - - - RecurrenceFrequency - - The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. - - RecurrenceFrequency - - - ScheduleDays - - A list of days scheduled. - - List`1[String] - - - ScheduleHours - - A list of scheduled hours. - - List`1[Int32] - - - ScheduleMinutes - - List of scheduled minutes. - - List`1[Int32] - + Remove-AutoscaleSetting - ScheduleTimeZone + ResourceGroup - The time zone of the schedule. + The resource group name String - - Rules - - The list of rules to add to the newly created profile. - - List`1[ScaleRule] - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - - - New-AutoscaleProfile Name - The name of the profile. - - String - - - DefaultCapacity - - The default capacity. - - String - - - MaximumCapacity - - The maximum capacity. - - String - - - MinimumCapacity - - The minimum capacity. - - String - - - StartTimeWindow - - The start of the time window. - - DateTime - - - EndTimeWindow - - The end of the time window. - - DateTime - - - TimeWindowTimeZone - - The time zone of the time window. + The setting name String - - Rules - - The list of rules to add to the newly created profile. - - List`1[ScaleRule] - Profile @@ -5133,230 +6339,467 @@ Unit : Count AzureProfile - - - New-AutoscaleProfile - - Name - - The name of the profile. - - String - - - DefaultCapacity - - The default capacity. - - String - - - MaximumCapacity - - The maximum capacity. - - String - - - MinimumCapacity - - The minimum capacity. - - String - - - Rules + + InformationAction - The list of rules to add to the newly created profile. + - List`1[ScaleRule] + ActionPreference - Profile + InformationVariable - In-memory profile (AzureProfile). + - AzureProfile + String - - Name + + ResourceGroup + + The resource group name + + String + + String + + + + + + Name + + The setting name + + String + + String + + + + + + Profile + + In-memory profile (AzureProfile). + + AzureProfile + + AzureProfile + + + + + + InformationAction + + + + ActionPreference + + ActionPreference + + + + + + InformationVariable + + + + String + + String + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Add-AutoscaleSetting + + + + Get-AutoscaleSetting + + + + Get-AutoscaleHistory + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + + + + + Get-AzureCorrelationIdLog + + Gets the operations associated with a CorrelationId + + + + + + + + + + Gets the operations associated with a CorrelationId. + + + + + + CorrelationId - The name of the profile. + Specifies a filter by correlationId. This parameter is mandatory. - String + string - String + string - - DefaultCapacity + + StartTime - The default capacity. + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. - String + nullable`1[datetime] - String + nullable`1[datetime] - + EndTime minus one hour - - MaximumCapacity + + EndTime - The maximum capacity. + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. - String + nullable`1[datetime] - String + nullable`1[datetime] - + Current time - - MinimumCapacity + + Status - The minimum capacity. + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - String + string - String + string - - RecurrenceFrequency + + Caller - The frequency of recurrence. The allowed values are: None, Second, Minute, Hour, Day, Week, Month, Year. Not all those values are supported. + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - RecurrenceFrequency + string - RecurrenceFrequency + string - - ScheduleDays + + DetailedOutput - A list of days scheduled. + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - List`1[String] + switchparameter - List`1[String] + switchparameter - - ScheduleHours + + Profile - A list of scheduled hours. + In-memory profile (AzureProfile). - List`1[Int32] + azureprofile - List`1[Int32] + azureprofile - - ScheduleMinutes + + + + + None + + + - List of scheduled minutes. + + - List`1[Int32] + + + + - List`1[Int32] - + None + + - - - - ScheduleTimeZone - The time zone of the schedule. + + - String + + + + + + + + + + + + + -------------------------- Example 1: GetAzureCorrelationIdLog -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + + This command lists all the operations associated to the given CorrelationId that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 2: GetAzureCorrelationIdLog with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + + This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 3: GetAzureCorrelationIdLog with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureCorrelationIdLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + + This command lists all the operations associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-AzureSubscriptionIdLog + + + + Get-AzureResourceGroupLog + + + + Get-AzureResourceLog + + + + Get-AzureResourceProviderLog + + + + + + + + Get-AzureResourceGroupLog + + Gets the operations associated with a Resource Group + + + + + + + + + + Gets the operations associated with a Resource Group. + + + + + + ResourceGroup + + Specifies a filter by ResourceGroup. This parameter is mandatory. + + string - String + string - - Rules + + StartTime - The list of rules to add to the newly created profile. + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. - List`1[ScaleRule] + nullable`1[datetime] - List`1[ScaleRule] + nullable`1[datetime] - + EndTime minus one hour - - Profile + + EndTime - In-memory profile (AzureProfile). + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. - AzureProfile + nullable`1[datetime] - AzureProfile + nullable`1[datetime] - + Current time - - StartTimeWindow + + Status - The start of the time window. + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - DateTime + string - DateTime + string - - EndTimeWindow + + Caller - The end of the time window. + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - DateTime + string - DateTime + string - - TimeWindowTimeZone + + DetailedOutput - The time zone of the time window. + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - String + switchparameter - String + switchparameter - - Profiles + + Profile - List of profiles to add to the result. + In-memory profile (AzureProfile). - list`1[autoscaleprofile] + azureprofile - list`1[autoscaleprofile] + azureprofile @@ -5365,7 +6808,7 @@ Unit : Count - + None @@ -5378,7 +6821,7 @@ Unit : Count - + None @@ -5398,50 +6841,16 @@ Unit : Count - -------------------------- Example 1: Create single profile, fixed date -------------------------- - - PS C:\> - - $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - -$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -StartTimeWindow 2015-03-05T14:00:00 -EndTimeWindow 2015-03-05T14:30:00 -TimeWindowTimeZone GMT -Rules $rule -Name "adios" - - Creates a single profile without a schedule (fix date) - - - Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity -FixedDate : Microsoft.Azure.Management.Insights.Models.TimeWindow -Name : adios -Recurrence : -Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - Microsoft.Azure.Management.Insights.Models.ScaleRule} - - - - - - - - - - - -------------------------- Example 2: Create single profile with schedule -------------------------- + -------------------------- Example 1: GetAzureResourceGroupLog -------------------------- PS C:\> - $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - -$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule -Name "secondProfileName" -RecurrenceFrequency Minute -ScheduleDays "1", "2", "3" -ScheduleHours 5, 10, 15 -ScheduleMinutes 15, 30, 45 -ScheduleTimeZone GMT + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS - Creates a single profile with a recurrent schedule. + This command lists all the operations associated to the given Resource Group that took place in the last hour. - Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity -FixedDate : -Name : secondProfileName -Recurrence : Microsoft.Azure.Management.Insights.Models.Recurrence -Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - Microsoft.Azure.Management.Insights.Models.ScaleRule} + @@ -5452,34 +6861,16 @@ Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - -------------------------- Example 3: Create two profiles -------------------------- + -------------------------- Example 2: GetAzureResourceGroupLog with starttime only -------------------------- PS C:\> - $rule1 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - -$rule2 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:10:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "2" - -$profile1 = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -StartTimeWindow 2015-03-05T14:00:00 -EndTimeWindow 2015-03-05T14:30:00 -TimeWindowTimeZone GMT -Rules $rule1, $rule2 -Name "profileName" - -$profile2 = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule1, $rule2 -Name "secondProfileName" -RecurrenceFrequency Week -ScheduleDays "1" -ScheduleHours 5 -ScheduleMinutes 15 -ScheduleTimeZone UTC + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 - Creates two profiles adds them to a list. + This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. - Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity -FixedDate : Microsoft.Azure.Management.Insights.Models.TimeWindow -Name : profileName -Recurrence : -Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - Microsoft.Azure.Management.Insights.Models.ScaleRule} - -Capacity : Microsoft.Azure.Management.Insights.Models.ScaleCapacity -FixedDate : -Name : secondProfileName -Recurrence : Microsoft.Azure.Management.Insights.Models.Recurrence -Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - Microsoft.Azure.Management.Insights.Models.ScaleRule} + @@ -5490,15 +6881,13 @@ Rules : {Microsoft.Azure.Management.Insights.Models.ScaleRule, - -------------------------- Example 4: Create single profile, no scheduled time -------------------------- + -------------------------- Example 3: GetAzureResourceGroupLog with start and end times -------------------------- PS C:\> - $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - -$profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rules $rule -Name "profileName" + PS C:\>Get-AzureResourceGroupLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 - Creates a single profile without a schedule or a fixed date + This command lists all the operations associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -5514,285 +6903,121 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity - New-AutoscaleRule - + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 - Add-AutoscaleSetting + Get-AzureSubscriptionIdLog - Get-AutoscaleSetting + Get-AzureCorrelationIdLog - Remove-AutoscaleSetting + Get-AzureResourceLog - Get-AutoscaleHistory + Get-AzureResourceProviderLog Online Version: http://go.microsoft.com/fwlink/?LinkID=397618 - - - - - - New-AutoscaleRule - - Create an autoscale rule. - - - - - New - AutoscaleRule - - - - Create an autoscale rule. - - - - New-AutoscaleRule - - MetricName - - The metric name. - - String - - - MetricResourceId - - The metric resource Id. - - String - - - Operator - - The operator. Allowed values are: Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual - - ComparisonOperationType - - - MetricStatistic - - The metric statistic. The allowed values are: Average, Min, Max, Sum. - - MetricStatisticType - - - Threshold - - The threshold of the metric value. - - Double - - - TimeAggregationOperator - - The time aggregation operator. The allowed values are: Average, Minimum, Maximum, Last, Total, Count. - - TimeAggregationType - - - TimeGrain - - The time grain. - - TimeSpan - - - TimeWindow - - The time window. - - TimeSpan - - - ScaleActionCooldown - - Autoscale action cooldown time. - - TimeSpan - - - ScaleActionDirection - - The scale action direction. The allowed values are: None, Increase, Decrease. - - ScaleDirection - - - ScaleActionScaleType - - The scale type. The allowed values are: ChangeSize, ChangeCount, PercentChangeCount, ExactCount. - - ScaleType - - - ScaleActionValue - - The action value. - - String - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - + + + + + + Get-AzureResourceLog + + Gets the operations associated with a ResourceId + + + + + + + + + + Gets the operations associated with a ResourceId. + + - - MetricName - - The metric name. - - String - - String - - - - - - MetricResourceId - - The metric resource Id. - - String - - String - - - - - - Operator - - The operator. Allowed values are: Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual - - ComparisonOperationType - - ComparisonOperationType - - - - - - MetricStatistic - - The metric statistic. The allowed values are: Average, Min, Max, Sum. - - MetricStatisticType - - MetricStatisticType - - - - - - Threshold - - The threshold of the metric value. - - Double - - Double - - - - - - TimeAggregationOperator - - The time aggregation operator. The allowed values are: Average, Minimum, Maximum, Last, Total, Count. - - TimeAggregationType - - TimeAggregationType - - - - - - TimeGrain + + ResourceId - The time grain. + Specifies a filter by ResoruceId. This parameter is mandatory. - TimeSpan + string - TimeSpan + string - - TimeWindow + + StartTime - The time window. + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. - TimeSpan + nullable`1[datetime] - TimeSpan + nullable`1[datetime] - + EndTime minus one hour - - ScaleActionCooldown + + EndTime - Autoscale action cooldown time. + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. - TimeSpan + nullable`1[datetime] - TimeSpan + nullable`1[datetime] - + Current time - - ScaleActionDirection + + Status - The scale action direction. The allowed values are: None, Increase, Decrease. + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) - ScaleDirection + string - ScaleDirection + string - - ScaleActionScaleType + + Caller - The scale type. The allowed values are: ChangeSize, ChangeCount, PercentChangeCount, ExactCount. + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - ScaleType + string - ScaleType + string - - ScaleActionValue + + DetailedOutput - The action value. + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) - String + switchparameter - String + switchparameter @@ -5802,9 +7027,9 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity In-memory profile (AzureProfile). - AzureProfile + azureprofile - AzureProfile + azureprofile @@ -5813,7 +7038,7 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity - + None @@ -5826,7 +7051,7 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity - + None @@ -5846,18 +7071,16 @@ $profile = new-autoscaleprofile -DefaultCapacity "1" -MaximumCapacity - -------------------------- Example 1: Create single rule -------------------------- + -------------------------- Example 1: GetAzureResourceLog -------------------------- PS C:\> - $rule = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 - Creates a single rule. + This command lists all the operations associated to the given ResourceId that took place in the last hour. - MetricTrigger ScaleAction -------------- ----------- -Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction + @@ -5868,21 +7091,36 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - -------------------------- Example 2: Create two rules -------------------------- + -------------------------- Example 2: GetAzureResourceLog with starttime only -------------------------- PS C:\> - $rule1 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:05:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "1" - -$rule2 = new-autoscaleRule -MetricName Requests -MetricResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite" -Operator GreaterThan -MetricStatistic Average -Threshold 10 -TimeGrain 00:01:00 -ScaleActionCooldown 00:10:00 -ScaleActionDirection Increase -ScaleActionScaleType ChangeCount -ScaleActionValue "2" + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 - Creates two rules. + This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. - MetricTrigger ScaleAction -------------- ----------- -Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction -Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Management.Insights.Models.ScaleAction + + + + + + + + + + + + -------------------------- Example 3: GetAzureResourceLog with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureResourceLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + + This command lists all the operations associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + @@ -5895,95 +7133,117 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - New-AutoscaleProfile - + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 - Add-AutoscaleSetting + Get-AzureSubscriptionIdLog - Get-AutoscaleSetting + Get-AzureCorrelationIdLog - Remove-AutoscaleSetting + Get-AzureResourceGroupLog - Get-AutoscaleHistory + Get-AzureResourceProviderLog - - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 - - Remove-AlertRule + Get-AzureResourceProviderLog - Removes an alert rule. + Gets the operations associated with a Resource Provider - Remove - AlertRule + + - Removes and alert rule identified by name and resource group name. + Gets the operations associated with a Resource Provider. - - Remove-AlertRule - - ResourceGroup - - The name of the resource group where the alert is included. - - String - - - Name - - Name of the alert rule to remove. - - String - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - - - ResourceGroup + + ResourceProvider + + Specifies a filter by ResourceProvider. This parameter is mandatory. + + string + + string + + + + + + StartTime + + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. + + nullable`1[datetime] + + nullable`1[datetime] + + + EndTime minus one hour + + + EndTime - The name of the resource group where the alert is included. + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. - String + nullable`1[datetime] - String + nullable`1[datetime] + + + Current time + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + string + + string - - Name + + Caller - Name of the alert rule to remove. + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) - String + string - String + string + + + + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + switchparameter + + switchparameter @@ -5993,9 +7253,9 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana In-memory profile (AzureProfile). - AzureProfile + azureprofile - AzureProfile + azureprofile @@ -6004,7 +7264,7 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - + None @@ -6017,7 +7277,7 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - + None @@ -6037,18 +7297,56 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - -------------------------- Example 1: removing an alert rule -------------------------- + -------------------------- Example 1: GetAzureResourceProviderLog -------------------------- PS C:\> - remove-alertrule -res Default-Web-CentralUS -n myalert-7da64548-214d-42ca-b12b-b245bb8f0ac8 + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web - Removes the alert rule identified by name and resource group name. + This command lists all the operations associated to the given Resource Provider that took place in the last hour. - RequestId StatusCode ---------- ---------- -2c6c159b-0e73-4a01-a67b-c32c1a0008a3 OK + + + + + + + + + + + + -------------------------- Example 2: GetAzureResourceProviderLog with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 + + This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 3: GetAzureResourceProviderLog with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureResourceProviderLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + + This command lists all the operations associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + @@ -6061,87 +7359,105 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - Add-AlertRule + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-AzureSubscriptionIdLog - Get-AlertRule + Get-AzureCorrelationIdLog - Get-AlertHistory + Get-AzureResourceGroupLog - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 + Get-AzureResourceLog + - Remove-AutoscaleSetting + Get-AzureSubscriptionIdLog - Removes an autoscale setting + Gets the operations associated with the current subscriptionId - Remove - AutoscaleSetting + + - Removes an autoscale setting identified by a resource group name and the setting name + Gets the operations associated with the current subscriptionId. - - Remove-AutoscaleSetting - - ResourceGroup - - The resource group name - - String - - - Name - - The setting name - - String - - - Profile - - In-memory profile (AzureProfile). - - AzureProfile - - - - ResourceGroup + + StartTime - The resource group name + Specifies the start time of the query in local time. This parameter is optional. +The default is EndTime minus one hour. - String + nullable`1[datetime] - String + nullable`1[datetime] - - Name + + EndTime - The setting name + Specifies the end time of the query in local time. This parameter is optional. The default is the current time. +The value must be earlier than StartTime, but not more than 15 days. - String + nullable`1[datetime] - String + nullable`1[datetime] + + + Current time + + + Status + + Specifies a filter by status. This parameter is optional. The fault is an empty string (i.e. no filter) + + string + + string + + + + + + Caller + + Specifies a filter by caller. This parameter is optional. The fault is an empty string (i.e. no filter) + + string + + string + + + + + + DetailedOutput + + If present it indicates that the output will be detailed. This parameter is optional. The default is no (i.e. summarized output.) + + switchparameter + + switchparameter @@ -6151,9 +7467,9 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana In-memory profile (AzureProfile). - AzureProfile + azureprofile - AzureProfile + azureprofile @@ -6162,7 +7478,7 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - + None @@ -6175,7 +7491,7 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana - + None @@ -6194,23 +7510,87 @@ Microsoft.Azure.Management.Insights.Models.MetricTrigger Microsoft.Azure.Mana + + -------------------------- Example 1: GetAzureSubscriptionIdLog -------------------------- + + PS C:\> + + PS C:\>Get-AzureSubscriptionIdLog + + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. + + + + + + + + + + + + + + -------------------------- Example 2: GetAzureSubscriptionIdLog with starttime only -------------------------- + + PS C:\> + + PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 + + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time. + + + + + + + + + + + + + + -------------------------- Example 3: GetAzureSubscriptionIdLog with start and end times -------------------------- + + PS C:\> + + PS C:\>Get-AzureSubscriptionIdLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + + This command lists all the operations associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. + + + + + + + + + + + + - Add-AutoscaleSetting + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Get-AzureCorrelationIdLog - Get-AutoscaleSetting + Get-AzureResourceGroupLog - Get-AutoscaleHistory + Get-AzureResourceLog - Online Version: - http://go.microsoft.com/fwlink/?LinkID=397618 + Get-AzureResourceProviderLog + From 94971e8151c0a7de71760a8d8d7319727aac895a Mon Sep 17 00:00:00 2001 From: Shibani Medhekar Date: Tue, 29 Sep 2015 11:22:14 -0700 Subject: [PATCH 5/5] Changing name of Get-AzureLog cmdlet to Get-AzureRmLog according to new standards --- .../Commands.Insights.Test.csproj | 2 +- ...dTests.cs => GetAzureRmLogCommandTests.cs} | 8 +- .../ScenarioTests/EventsTests.ps1 | 10 +- .../Commands.Insights.csproj | 2 +- ...eLogCommand.cs => GetAzureRmLogCommand.cs} | 4 +- ...osoft.Azure.Commands.Insights.dll-Help.xml | 94 +++++++++---------- 6 files changed, 60 insertions(+), 60 deletions(-) rename src/ResourceManager/Insights/Commands.Insights.Test/Events/{GetAzureLogCommandTests.cs => GetAzureRmLogCommandTests.cs} (97%) rename src/ResourceManager/Insights/Commands.Insights/Events/{GetAzureLogCommand.cs => GetAzureRmLogCommand.cs} (97%) diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj index 831d2ae337c9..54c727240195 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj @@ -150,7 +150,7 @@ - + diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureRmLogCommandTests.cs similarity index 97% rename from src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs rename to src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureRmLogCommandTests.cs index 838a636e7fee..5d1145917183 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureLogCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Events/GetAzureRmLogCommandTests.cs @@ -25,9 +25,9 @@ namespace Microsoft.Azure.Commands.Insights.Test.Events { - public class GetAzureLogCommandTests + public class GetAzureRmLogCommandTests { - private readonly GetAzureLogCommand cmdlet; + private readonly GetAzureRmLogCommand cmdlet; private readonly Mock insightsClientMock; private readonly Mock insightsEventOperationsMock; private Mock commandRuntimeMock; @@ -35,12 +35,12 @@ public class GetAzureLogCommandTests private string filter; private string selected; - public GetAzureLogCommandTests() + public GetAzureRmLogCommandTests() { insightsEventOperationsMock = new Mock(); insightsClientMock = new Mock(); commandRuntimeMock = new Mock(); - cmdlet = new GetAzureLogCommand() + cmdlet = new GetAzureRmLogCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsClient = insightsClientMock.Object diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 index 02643369e49c..66f3f6cc2580 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 +++ b/src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/EventsTests.ps1 @@ -24,7 +24,7 @@ function Test-GetAzureCorrelationIdLog try { # Test - $actual = Get-AzureLog -CorrelationId $correlation -starttime 2015-03-02T10:00:00 -endtime 2015-03-02T12:00:00 -detailedOutput + $actual = Get-AzureRmLog -CorrelationId $correlation -starttime 2015-03-02T10:00:00 -endtime 2015-03-02T12:00:00 -detailedOutput # Assert TODO add more asserts Assert-AreEqual $actual.Count 2 @@ -47,7 +47,7 @@ function Test-GetAzureResourceGroupLog try { - $actual = Get-AzureLog -ResourceGroup $rgname -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 + $actual = Get-AzureRmLog -ResourceGroup $rgname -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 # Assert TODO add more asserts Assert-AreEqual $actual.Count 2 @@ -70,7 +70,7 @@ function Test-GetAzureResourceLog try { - $actual = Get-AzureLog -ResourceId $rname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z + $actual = Get-AzureRmLog -ResourceId $rname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z # Assert TODO add more asserts # Assert-Throws { Set-AzureResourceGroup -Name $rgname -Tags @{"testtag" = "testval"} } "Invalid tag format. Expect @{Name = `"tagName`"} or @{Name = `"tagName`"; Value = `"tagValue`"}" @@ -94,7 +94,7 @@ function Test-GetAzureResourceProviderLog try { - $actual = Get-AzureLog -ResourceProvider $rpname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z + $actual = Get-AzureRmLog -ResourceProvider $rpname -startTime 2015-03-03T15:42:50Z -endTime 2015-03-03T16:42:50Z # Assert Assert-AreEqual $actual.Count 2 @@ -117,7 +117,7 @@ function Test-GetAzureSubscriptionIdLog try { # Test - $actual = Get-AzureLog -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 + $actual = Get-AzureRmLog -starttime 2015-01-15T04:30:00 -endtime 2015-01-15T12:30:00 # Assert Assert-AreEqual $actual.Count 1 diff --git a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj index 9a5c352ac003..adb162157d15 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj +++ b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj @@ -128,7 +128,7 @@ - + diff --git a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureRmLogCommand.cs similarity index 97% rename from src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs rename to src/ResourceManager/Insights/Commands.Insights/Events/GetAzureRmLogCommand.cs index 9dae1aa23f2f..c943e41900b5 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureLogCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Events/GetAzureRmLogCommand.cs @@ -22,8 +22,8 @@ namespace Microsoft.Azure.Commands.Insights.Events /// /// Get the list of events for at a subscription level. /// - [Cmdlet(VerbsCommon.Get, "AzureLog"), OutputType(typeof(List))] - public class GetAzureLogCommand : EventCmdletBase + [Cmdlet(VerbsCommon.Get, "AzureRmLog"), OutputType(typeof(List))] + public class GetAzureRmLogCommand : EventCmdletBase { /// /// Gets or sets the starttime parameter of the cmdlet diff --git a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml index fbe93f0f1558..9ad31cd23e78 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml +++ b/src/ResourceManager/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml @@ -3946,7 +3946,7 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - Get-AzureLog + Get-AzureRmLog Gets the events associated with the current SubscriptionId or CorrelationId or Resource Group or ResourceId or Resource Provider @@ -3954,7 +3954,7 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese Get - AzureLog + AzureRmLog @@ -3962,7 +3962,7 @@ Tags : {[$type, Microsoft.WindowsAzure.Management.Common.Storage.CasePrese - Get-AzureLog + Get-AzureRmLog StartTime @@ -4037,7 +4037,7 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureLog + Get-AzureRmLog StartTime @@ -4112,7 +4112,7 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureLog + Get-AzureRmLog StartTime @@ -4187,7 +4187,7 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureLog + Get-AzureRmLog StartTime @@ -4262,7 +4262,7 @@ The value must be earlier than StartTime, but not more than 15 days. - Get-AzureLog + Get-AzureRmLog StartTime @@ -4524,11 +4524,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 1: GetAzureLog by SubscriptionId -------------------------- + -------------------------- Example 1: GetAzureRmLog by SubscriptionId -------------------------- PS C:\> - PS C:\>Get-AzureLog + PS C:\>Get-AzureRmLog This command lists all the events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. @@ -4544,11 +4544,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureLog by SubscriptionId with MaxEvents -------------------------- + -------------------------- Example 2: GetAzureRmLog by SubscriptionId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureLog -MaxEvents 100 + PS C:\>Get-AzureRmLog -MaxEvents 100 This command lists maximum of 100 events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place in the last hour. @@ -4565,11 +4565,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 2: GetAzureLog by SubscriptionId with starttime only -------------------------- + -------------------------- Example 2: GetAzureRmLog by SubscriptionId with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureLog -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureRmLog -StartTime 2015-01-01T10:30 @@ -4587,11 +4587,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 4: GetAzureLog by SubscriptionId with start and end times -------------------------- + -------------------------- Example 4: GetAzureRmLog by SubscriptionId with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureRmLog -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 This command lists all the events associated to the user's subscriptionId (see Add-AzureAccount for details) that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -4608,11 +4608,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 5: GetAzureLog by CorrelationId -------------------------- + -------------------------- Example 5: GetAzureRmLog by CorrelationId -------------------------- PS C:\> - PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 + PS C:\>Get-AzureRmLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 This command lists all the events associated to the given CorrelationId that took place in the last hour. @@ -4629,11 +4629,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 6: GetAzureLog by CorrelationId with MaxEvents -------------------------- + -------------------------- Example 6: GetAzureRmLog by CorrelationId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -MaxEvents 100 + PS C:\>Get-AzureRmLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -MaxEvents 100 This command lists maximum of 100 events associated to the given CorrelationId that took place in the last hour. @@ -4649,11 +4649,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 7: GetAzureLog by CorrelationId with starttime only -------------------------- + -------------------------- Example 7: GetAzureRmLog by CorrelationId with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 + PS C:\>Get-AzureRmLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 This command lists all the events associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time. @@ -4670,11 +4670,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 8: GetAzureLog by CorrelationId with start and end times -------------------------- + -------------------------- Example 8: GetAzureRmLog by CorrelationId with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 + PS C:\>Get-AzureRmLog -CorrelationId 60c694d0-e46f-4c12-bed1-9b7aef541c23 -StartTime 2015-01-15T04:30:00 -EndTime 2015-01-15T12:30:00 This command lists all the events associated to the given CorrelationId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -4691,11 +4691,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 9: GetAzureLog by ResourceGroup -------------------------- + -------------------------- Example 9: GetAzureRmLog by ResourceGroup -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS + PS C:\>Get-AzureRmLog -ResourceGroup Default-Web-CentralUS This command lists all the events associated to the given Resource Group that took place in the last hour. @@ -4711,11 +4711,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 10: GetAzureLog by ResourceGroup with MaxEvents -------------------------- + -------------------------- Example 10: GetAzureRmLog by ResourceGroup with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -MaxEvents 100 + PS C:\>Get-AzureRmLog -ResourceGroup Default-Web-CentralUS -MaxEvents 100 This command lists maximum of 100 events associated to the given Resource Group that took place in the last hour. @@ -4732,11 +4732,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 11: GetAzureLog by ResourceGroup with starttime only -------------------------- + -------------------------- Example 11: GetAzureRmLog by ResourceGroup with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureRmLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 This command lists all the events associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time. @@ -4753,11 +4753,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 12: GetAzureLog by ResourceGroup with start and end times -------------------------- + -------------------------- Example 12: GetAzureRmLog by ResourceGroup with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureRmLog -ResourceGroup Default-Web-CentralUS -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 This command lists all the events associated to the given Resource Group that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -4774,11 +4774,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 13: GetAzureLog by ResourceId -------------------------- + -------------------------- Example 13: GetAzureRmLog by ResourceId -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 + PS C:\>Get-AzureRmLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 This command lists all the events associated to the given ResourceId that took place in the last hour. @@ -4796,11 +4796,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 14: GetAzureLog by ResourceId with MaxEvents -------------------------- + -------------------------- Example 14: GetAzureRmLog by ResourceId with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -MaxEvents 100 + PS C:\>Get-AzureRmLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -MaxEvents 100 This command lists maximum of 100 events associated to the given ResourceId that took place in the last hour. @@ -4817,11 +4817,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 15: GetAzureLog by ResourceId with starttime only -------------------------- + -------------------------- Example 15: GetAzureRmLog by ResourceId with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureRmLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 This command lists all the events associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time. @@ -4838,11 +4838,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 16: GetAzureLog by ResourceId with start and end times -------------------------- + -------------------------- Example 16: GetAzureRmLog by ResourceId with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureRmLog -ResourceId /subscriptions/623d50f1-4fa8-4e46-a967-a9214aed43ab/resourcegroups/Default-Web-CentralUS/providers/Microsoft.Web/serverFarms/Default1 -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 This command lists all the events associated to the given ResourceId that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time. @@ -4859,11 +4859,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 17: GetAzureLog by ResourceProvider -------------------------- + -------------------------- Example 17: GetAzureRmLog by ResourceProvider -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web + PS C:\>Get-AzureRmLog -ResourceProvider Microsoft.Web This command lists all the events associated to the given Resource Provider that took place in the last hour. @@ -4880,11 +4880,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 18: GetAzureLog by ResourceProvider with MaxEvents -------------------------- + -------------------------- Example 18: GetAzureRmLog by ResourceProvider with MaxEvents -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -MaxEvents 100 + PS C:\>Get-AzureRmLog -ResourceProvider Microsoft.Web -MaxEvents 100 This command lists maximum of 100 events associated to the given Resource Provider that took place in the last hour. @@ -4901,11 +4901,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 19: GetAzureLog by ResourceProvider with starttime only -------------------------- + -------------------------- Example 19: GetAzureRmLog by ResourceProvider with starttime only -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 + PS C:\>Get-AzureRmLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 This command lists all the events associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time. @@ -4922,11 +4922,11 @@ The value must be earlier than StartTime, but not more than 15 days. - -------------------------- Example 20: GetAzureLog by ResourceProvider with start and end times -------------------------- + -------------------------- Example 20: GetAzureRmLog by ResourceProvider with start and end times -------------------------- PS C:\> - PS C:\>Get-AzureLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 + PS C:\>Get-AzureRmLog -ResourceProvider Microsoft.Web -StartTime 2015-01-01T10:30 -EndTime 2015-01-01T11:30 This command lists all the events associated to the given Resource Provider that took place on or after 2015-01-01T10:30 local time, but before 2015-01-01T11:30 local time.