Skip to content

Commit a885710

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents b3d2119 + 6d074f4 commit a885710

File tree

7 files changed

+317
-36
lines changed

7 files changed

+317
-36
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/Commands.Insights.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@
209209
<None Include="ScenarioTests\UsageMetricsTests.ps1">
210210
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211211
</None>
212+
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AzureRmDiagnosticSettingTests\TestSetAzureRmDiagnosticSettingTimegrainsOnly.json">
213+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
214+
</None>
215+
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AzureRmDiagnosticSettingTests\TestSetAzureRmDiagnosticSettingCategoriesOnly.json">
216+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
217+
</None>
212218
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AzureRmDiagnosticSettingTests\TestSetAzureRmDiagnosticSetting.json">
213219
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
214220
</None>

src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/AzureRmDiagnosticSettingTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,19 @@ public void TestSetAzureRmDiagnosticSetting()
3333
{
3434
TestsController.NewInstance.RunPsTest("Test-SetAzureRmDiagnosticSetting");
3535
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestSetAzureRmDiagnosticSettingCategoriesOnly()
40+
{
41+
TestsController.NewInstance.RunPsTest("Test-SetAzureRmDiagnosticSetting-CategoriesOnly");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestSetAzureRmDiagnosticSettingTimeGrainsOnly()
47+
{
48+
TestsController.NewInstance.RunPsTest("Test-SetAzureRmDiagnosticSetting-TimegrainsOnly");
49+
}
3650
}
3751
}

src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/AzureRmDiagnosticSettingTests.ps1

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,60 @@ function Test-SetAzureRmDiagnosticSetting
6969
}
7070
}
7171

72+
<#
73+
.SYNOPSIS
74+
Tests setting diagnostics for categories only
75+
#>
76+
function Test-SetAzureRmDiagnosticSetting-CategoriesOnly
77+
{
78+
try
79+
{
80+
$actual = Set-AzureRmDiagnosticSetting -ResourceId /subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusR2 -StorageAccountId /subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470 -Enable $true -Categories TestLog2
81+
82+
Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
83+
Assert-AreEqual montest3470 $actual.StorageAccountName
84+
Assert-AreEqual 1 $actual.Metrics.Count
85+
Assert-AreEqual $false $actual.Metrics[0].Enabled
86+
Assert-AreEqual "PT1M" $actual.Metrics[0].Timegrain
87+
Assert-AreEqual 2 $actual.Logs.Count
88+
Assert-AreEqual $false $actual.Logs[0].Enabled
89+
Assert-AreEqual "TestLog1" $actual.Logs[0].Category
90+
Assert-AreEqual $true $actual.Logs[1].Enabled
91+
Assert-AreEqual "TestLog2" $actual.Logs[1].Category
92+
}
93+
finally
94+
{
95+
# Cleanup
96+
# No cleanup needed for now
97+
}
98+
}
99+
100+
<#
101+
.SYNOPSIS
102+
Tests setting diagnostics for categories only
103+
#>
104+
function Test-SetAzureRmDiagnosticSetting-TimegrainsOnly
105+
{
106+
try
107+
{
108+
$actual = Set-AzureRmDiagnosticSetting -ResourceId /subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusR2 -StorageAccountId /subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470 -Enable $true -Timegrains PT1M
109+
110+
Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
111+
Assert-AreEqual montest3470 $actual.StorageAccountName
112+
Assert-AreEqual 1 $actual.Metrics.Count
113+
Assert-AreEqual $true $actual.Metrics[0].Enabled
114+
Assert-AreEqual "PT1M" $actual.Metrics[0].Timegrain
115+
Assert-AreEqual 2 $actual.Logs.Count
116+
Assert-AreEqual $false $actual.Logs[0].Enabled
117+
Assert-AreEqual "TestLog1" $actual.Logs[0].Category
118+
Assert-AreEqual $false $actual.Logs[1].Enabled
119+
Assert-AreEqual "TestLog2" $actual.Logs[1].Category
120+
}
121+
finally
122+
{
123+
# Cleanup
124+
# No cleanup needed for now
125+
}
126+
}
127+
72128
# TODO add more complicated scenarios after we have a definitive subscription
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/%2Fsubscriptions%2F1a66ce04-b633-4a0b-b2bc-a912ec8986a6%2Fresourcegroups%2Finsights-integration%2Fproviders%2Ftest.shoebox%2Ftestresources2%2Fpstest0000eastusR2/providers/microsoft.insights/diagnosticSettings/service?api-version=2015-07-01",
5+
"RequestMethod": "GET",
6+
"RequestBody": "",
7+
"RequestHeaders": {
8+
"Accept": [ "application/json" ],
9+
"User-Agent": [ "User-Agent: Microsoft.Azure.Management.Insights.InsightsManagementClient/0.9.0.0 AzurePowershell/v0.9.9.0" ],
10+
"Connection": [ "Keep-Alive" ]
11+
},
12+
"ResponseBody": "{\"id\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusr2/diagnosticSettings/service\",\"name\":\"service\",\"location\":null,\"tags\":null,\"properties\":{\"storageAccountName\":\"montest3470\",\"storageAccountId\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\":[{\"timeGrain\":\"PT1M\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}],\"logs\":[{\"category\":\"TestLog1\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}},{\"category\":\"TestLog2\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}]}}",
13+
"ResponseHeaders": {
14+
"Cache-Control": [
15+
"no-cache"
16+
],
17+
"Date": [
18+
"Mon, 03 Mar 2015 00:07:07 GMT"
19+
],
20+
"Expires": [
21+
"-1"
22+
],
23+
"Pragma": [
24+
"no-cache"
25+
],
26+
"Content-Length": [
27+
"441"
28+
],
29+
"Content-Type": [
30+
"application/json; charset=utf-8"
31+
],
32+
"x-ms-ratelimit-remaining-subscription-writes": [
33+
"1199"
34+
],
35+
"x-ms-request-id": [
36+
"47af504c-88a1-49c5-9766-e397d54e490b"
37+
],
38+
"x-ms-correlation-request-id": [
39+
"e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
40+
],
41+
"x-ms-routing-request-id": [
42+
"WESTUS:20150303T190828Z:e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
43+
],
44+
"Strict-Transport-Security": [
45+
"max-age=31536000; includeSubDomains"
46+
]
47+
},
48+
"StatusCode": 200
49+
},
50+
{
51+
"RequestUri": "/%2Fsubscriptions%2F1a66ce04-b633-4a0b-b2bc-a912ec8986a6%2Fresourcegroups%2Finsights-integration%2Fproviders%2Ftest.shoebox%2Ftestresources2%2Fpstest0000eastusR2/providers/microsoft.insights/diagnosticSettings/service?api-version=2015-07-01",
52+
"RequestMethod": "PUT",
53+
"RequestBody": "{\"properties\": {\"storageAccountId\": \"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\": [{\"timeGrain\": \"PT1M\",\"enabled\": false,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}}],\"logs\": [{\"category\": \"TestLog1\",\"enabled\": false,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}},{\"category\": \"TestLog2\",\"enabled\": true,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}}]}}",
54+
"RequestHeaders": {
55+
"Accept": [ "application/json" ],
56+
"User-Agent": [ "User-Agent: Microsoft.Azure.Management.Insights.InsightsManagementClient/0.9.0.0 AzurePowershell/v0.9.9.0" ],
57+
"Connection": [ "Keep-Alive" ]
58+
},
59+
"ResponseBody": "{\"id\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusr2/diagnosticSettings/service\",\"name\":\"service\",\"location\":null,\"tags\":null,\"properties\":{\"storageAccountName\":\"montest3470\",\"storageAccountId\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\":[{\"timeGrain\":\"PT1M\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}],\"logs\":[{\"category\":\"TestLog1\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}},{\"category\":\"TestLog2\",\"enabled\":true,\"retentionPolicy\":{\"days\":0}}]}}",
60+
"ResponseHeaders": {
61+
"Cache-Control": [
62+
"no-cache"
63+
],
64+
"Date": [
65+
"Mon, 03 Mar 2015 00:07:07 GMT"
66+
],
67+
"Expires": [
68+
"-1"
69+
],
70+
"Pragma": [
71+
"no-cache"
72+
],
73+
"Content-Length": [
74+
"614"
75+
],
76+
"Content-Type": [
77+
"application/json; charset=utf-8"
78+
],
79+
"x-ms-ratelimit-remaining-subscription-writes": [
80+
"1199"
81+
],
82+
"x-ms-request-id": [
83+
"47af504c-88a1-49c5-9766-e397d54e490b"
84+
],
85+
"x-ms-correlation-request-id": [
86+
"e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
87+
],
88+
"x-ms-routing-request-id": [
89+
"WESTUS:20150303T190828Z:e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
90+
],
91+
"Strict-Transport-Security": [
92+
"max-age=31536000; includeSubDomains"
93+
]
94+
},
95+
"StatusCode": 200
96+
}
97+
],
98+
"Names": {
99+
"Test-AddAlertRule": [
100+
""
101+
]
102+
},
103+
"Variables": {
104+
"SubscriptionId": "a93fb07c-6c93-40be-bf3b-4f0deba10f4b"
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/%2Fsubscriptions%2F1a66ce04-b633-4a0b-b2bc-a912ec8986a6%2Fresourcegroups%2Finsights-integration%2Fproviders%2Ftest.shoebox%2Ftestresources2%2Fpstest0000eastusR2/providers/microsoft.insights/diagnosticSettings/service?api-version=2015-07-01",
5+
"RequestMethod": "GET",
6+
"RequestBody": "",
7+
"RequestHeaders": {
8+
"Accept": [ "application/json" ],
9+
"User-Agent": [ "User-Agent: Microsoft.Azure.Management.Insights.InsightsManagementClient/0.9.0.0 AzurePowershell/v0.9.9.0" ],
10+
"Connection": [ "Keep-Alive" ]
11+
},
12+
"ResponseBody": "{\"id\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusr2/diagnosticSettings/service\",\"name\":\"service\",\"location\":null,\"tags\":null,\"properties\":{\"storageAccountName\":\"montest3470\",\"storageAccountId\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\":[{\"timeGrain\":\"PT1M\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}],\"logs\":[{\"category\":\"TestLog1\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}},{\"category\":\"TestLog2\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}]}}",
13+
"ResponseHeaders": {
14+
"Cache-Control": [
15+
"no-cache"
16+
],
17+
"Date": [
18+
"Mon, 03 Mar 2015 00:07:07 GMT"
19+
],
20+
"Expires": [
21+
"-1"
22+
],
23+
"Pragma": [
24+
"no-cache"
25+
],
26+
"Content-Length": [
27+
"441"
28+
],
29+
"Content-Type": [
30+
"application/json; charset=utf-8"
31+
],
32+
"x-ms-ratelimit-remaining-subscription-writes": [
33+
"1199"
34+
],
35+
"x-ms-request-id": [
36+
"47af504c-88a1-49c5-9766-e397d54e490b"
37+
],
38+
"x-ms-correlation-request-id": [
39+
"e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
40+
],
41+
"x-ms-routing-request-id": [
42+
"WESTUS:20150303T190828Z:e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
43+
],
44+
"Strict-Transport-Security": [
45+
"max-age=31536000; includeSubDomains"
46+
]
47+
},
48+
"StatusCode": 200
49+
},
50+
{
51+
"RequestUri": "/%2Fsubscriptions%2F1a66ce04-b633-4a0b-b2bc-a912ec8986a6%2Fresourcegroups%2Finsights-integration%2Fproviders%2Ftest.shoebox%2Ftestresources2%2Fpstest0000eastusR2/providers/microsoft.insights/diagnosticSettings/service?api-version=2015-07-01",
52+
"RequestMethod": "PUT",
53+
"RequestBody": "{\"properties\": {\"storageAccountId\": \"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\": [{\"timeGrain\": \"PT1M\",\"enabled\": true,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}}],\"logs\": [{\"category\": \"TestLog1\",\"enabled\": false,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}},{\"category\": \"TestLog2\",\"enabled\": false,\"retentionPolicy\": {\"enabled\": false,\"days\": 0}}]}}",
54+
"RequestHeaders": {
55+
"Accept": [ "application/json" ],
56+
"User-Agent": [ "User-Agent: Microsoft.Azure.Management.Insights.InsightsManagementClient/0.9.0.0 AzurePowershell/v0.9.9.0" ],
57+
"Connection": [ "Keep-Alive" ]
58+
},
59+
"ResponseBody": "{\"id\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/insights-integration/providers/test.shoebox/testresources2/pstest0000eastusr2/diagnosticSettings/service\",\"name\":\"service\",\"location\":null,\"tags\":null,\"properties\":{\"storageAccountName\":\"montest3470\",\"storageAccountId\":\"/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470\",\"metrics\":[{\"timeGrain\":\"PT1M\",\"enabled\":true,\"retentionPolicy\":{\"days\":0}}],\"logs\":[{\"category\":\"TestLog1\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}},{\"category\":\"TestLog2\",\"enabled\":false,\"retentionPolicy\":{\"days\":0}}]}}",
60+
"ResponseHeaders": {
61+
"Cache-Control": [
62+
"no-cache"
63+
],
64+
"Date": [
65+
"Mon, 03 Mar 2015 00:07:07 GMT"
66+
],
67+
"Expires": [
68+
"-1"
69+
],
70+
"Pragma": [
71+
"no-cache"
72+
],
73+
"Content-Length": [
74+
"614"
75+
],
76+
"Content-Type": [
77+
"application/json; charset=utf-8"
78+
],
79+
"x-ms-ratelimit-remaining-subscription-writes": [
80+
"1199"
81+
],
82+
"x-ms-request-id": [
83+
"47af504c-88a1-49c5-9766-e397d54e490b"
84+
],
85+
"x-ms-correlation-request-id": [
86+
"e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
87+
],
88+
"x-ms-routing-request-id": [
89+
"WESTUS:20150303T190828Z:e223e5fa-7d3c-4d2c-a2e9-aed3011aefb7"
90+
],
91+
"Strict-Transport-Security": [
92+
"max-age=31536000; includeSubDomains"
93+
]
94+
},
95+
"StatusCode": 200
96+
}
97+
],
98+
"Names": {
99+
"Test-AddAlertRule": [
100+
""
101+
]
102+
},
103+
"Variables": {
104+
"SubscriptionId": "a93fb07c-6c93-40be-bf3b-4f0deba10f4b"
105+
}
106+
}

src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleProfileCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.Management.Automation;
1818
using Microsoft.Azure.Commands.ResourceManager.Common;
1919
using Microsoft.Azure.Management.Insights.Models;
20-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2120

2221
namespace Microsoft.Azure.Commands.Insights.Autoscale
2322
{
@@ -157,9 +156,10 @@ public AutoscaleProfile CreateSettingProfile()
157156
Maximum = this.MaximumCapacity,
158157
},
159158

160-
// Premise: Fixed date schedule and recurrence are mutually exclusive
159+
// NOTE: "always" is specify by a null value in the FixedDate value with null ScheduledDays(Minutes, Seconds)
160+
// Premise: Fixed date schedule and recurrence are mutually exclusive, but they can both be missing so that the rule is always enabled.
161161
// Assuming dates are validated by the server
162-
FixedDate = this.ScheduleDays == null
162+
FixedDate = this.ScheduleDays == null && (this.StartTimeWindow != default(DateTime) || this.EndTimeWindow != default(DateTime))
163163
? new TimeWindow()
164164
{
165165
Start = this.StartTimeWindow,

0 commit comments

Comments
 (0)