Skip to content

Commit 114552b

Browse files
authored
Merge pull request #8075 from maddieclayton/insights
Insights breaking changes
2 parents 0d1cbd7 + ff806b7 commit 114552b

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void SetWorkspace()
194194
[Trait(Category.AcceptanceType, Category.CheckIn)]
195195
public void SetSomeCategories()
196196
{
197-
cmdlet.Categories = new List<string> { "TestCategory1" };
197+
cmdlet.Category = new List<string> { "TestCategory1" };
198198
cmdlet.Enabled = false;
199199
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
200200
cmdlet.ExecuteCmdlet();
@@ -216,14 +216,14 @@ public void SetSomeCategories()
216216
Enabled = false
217217
}
218218
});
219-
cmdlet.Categories = new List<string> { "TestCategory3" };
219+
cmdlet.Category = new List<string> { "TestCategory3" };
220220
cmdlet.Enabled = false;
221221
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
222222
cmdlet.ExecuteCmdlet();
223223

224224
// Testing the new metric categories must be known before the cmdlet can add them
225225
expectedSettings.Metrics[0].Enabled = false;
226-
cmdlet.Categories = null;
226+
cmdlet.Category = null;
227227
cmdlet.MetricCategory = new List<string> { "MetricCat1" };
228228
cmdlet.Enabled = false;
229229
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
@@ -242,7 +242,7 @@ public void SetSomeCategories()
242242
[Trait(Category.AcceptanceType, Category.CheckIn)]
243243
public void SetSomeTimeGrains()
244244
{
245-
cmdlet.Timegrains = new List<string> { "PT1H" };
245+
cmdlet.Timegrain = new List<string> { "PT1H" };
246246
cmdlet.Enabled = false;
247247
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
248248
cmdlet.ExecuteCmdlet();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function Test-SetAzureRmDiagnosticSetting-CategoriesOnly
167167
{
168168
try
169169
{
170-
$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 -Enabled $true -Categories TestLog2
170+
$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 -Enabled $true -Category TestLog2
171171

172172
Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
173173
Assert-AreEqual "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.ServiceBus/namespaces/ns1/authorizationrules/ar1" $actual.EventHubName
@@ -198,7 +198,7 @@ function Test-SetAzureRmDiagnosticSetting-TimegrainsOnly
198198
{
199199
try
200200
{
201-
$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 -Enabled $true -Timegrains PT1M
201+
$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 -Enabled $true -Timegrain PT1M
202202

203203
Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
204204
Assert-AreEqual "workspace1" $actual.WorkspaceId

src/ResourceManager/Insights/Commands.Insights/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
* Overview of change #1
1818
- Additional information about change #1
1919
-->
20-
## Current Release
20+
## Current Release
21+
* Removed plural names "Categories" and "Timegrains" parameter in favor of singular parameter names

src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ public class SetAzureRmDiagnosticSettingCommand : ManagementCmdletBase
105105
/// </summary>
106106
[Parameter(ParameterSetName = SetAzureRmDiagnosticSettingOldParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The log categories")]
107107
[ValidateNotNullOrEmpty]
108-
[Alias("Category")]
109-
public List<string> Categories { get; set; }
108+
public List<string> Category { get; set; }
110109

111110
/// <summary>
112111
/// Gets or sets the metrics category parameter of the cmdlet
@@ -120,8 +119,7 @@ public class SetAzureRmDiagnosticSettingCommand : ManagementCmdletBase
120119
/// </summary>
121120
[Parameter(ParameterSetName = SetAzureRmDiagnosticSettingOldParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The timegrains")]
122121
[ValidateNotNullOrEmpty]
123-
[Alias("Timegrain")]
124-
public List<string> Timegrains { get; set; }
122+
public List<string> Timegrain { get; set; }
125123

126124
/// <summary>
127125
/// Gets or sets a value indicating whether retention should be enabled
@@ -162,7 +160,6 @@ protected override void ProcessRecordInternal()
162160
target: string.Format("Create/update a diagnostic setting for resource Id: {0}", this.ResourceId),
163161
action: "Create/update a diagnostic setting"))
164162
{
165-
WriteWarningWithTimestamp("The arguments Categories and Timegrains now have aliases Category and Timegrain respectively. The plural names will be removed in future releases.");
166163
DiagnosticSettingsResource properties;
167164

168165
// Name defaults to 'service'
@@ -275,15 +272,15 @@ protected override void ProcessRecordInternal()
275272

276273
SetWorkspace(properties);
277274

278-
if (this.Categories == null && this.MetricCategory == null && this.Timegrains == null)
275+
if (this.Category == null && this.MetricCategory == null && this.Timegrain == null)
279276
{
280277
WriteDebugWithTimestamp("Changing the enable properties");
281278
SetAllCategoriesAndTimegrains(properties);
282279
}
283280
else
284281
{
285282
WriteDebugWithTimestamp("Setting categories and time grains");
286-
if (this.Categories != null)
283+
if (this.Category != null)
287284
{
288285
SetSelectedCategories(properties);
289286
}
@@ -293,7 +290,7 @@ protected override void ProcessRecordInternal()
293290
SetSelectedMetricsCategories(properties);
294291
}
295292

296-
if (this.Timegrains != null)
293+
if (this.Timegrain != null)
297294
{
298295
SetSelectedTimegrains(properties);
299296
}
@@ -392,18 +389,18 @@ private void SetSelectedTimegrains(DiagnosticSettingsResource properties)
392389
{
393390
if (!this.isEnbledParameterPresent)
394391
{
395-
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrains' parameter.");
392+
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrain' parameter.");
396393
}
397394

398-
if (this.Timegrains != null && this.Timegrains.Count > 0)
395+
if (this.Timegrain != null && this.Timegrain.Count > 0)
399396
{
400397
if (properties.Metrics == null)
401398
{
402399
properties.Metrics = new List<MetricSettings>();
403400
}
404401

405402
WriteWarningWithTimestamp("Deprecation: The timegain argument for metrics will be deprecated since the back end supports only PT1M. Currently it is ignored for backwards compatibility.");
406-
WriteDebugWithTimestamp("Setting Enabled property for metrics since timegrains argument is non-empty");
403+
WriteDebugWithTimestamp("Setting Enabled property for metrics since timegrain argument is non-empty");
407404
foreach (MetricSettings metric in properties.Metrics)
408405
{
409406
metric.Enabled = this.Enabled;
@@ -415,7 +412,7 @@ private void SetSelectedCategories(DiagnosticSettingsResource properties)
415412
{
416413
if (!this.isEnbledParameterPresent)
417414
{
418-
throw new ArgumentException("Parameter 'Enabled' is required by 'Categories' parameter.");
415+
throw new ArgumentException("Parameter 'Enabled' is required by 'Category' parameter.");
419416
}
420417

421418
WriteDebugWithTimestamp("Setting log categories, including Enabled property");
@@ -424,7 +421,7 @@ private void SetSelectedCategories(DiagnosticSettingsResource properties)
424421
properties.Logs = new List<LogSettings>();
425422
}
426423

427-
foreach (string category in this.Categories)
424+
foreach (string category in this.Category)
428425
{
429426
LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));
430427
if (logSettings == null)

src/ResourceManager/Insights/Commands.Insights/help/Set-AzDiagnosticSetting.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Sets the logs and metrics settings for the resource.
1717
```
1818
Set-AzDiagnosticSetting -ResourceId <String> [-Name <String>] [-StorageAccountId <String>]
1919
[-ServiceBusRuleId <String>] [-EventHubName <String>] [-EventHubAuthorizationRuleId <String>]
20-
[-Enabled <Boolean>] [-Categories <System.Collections.Generic.List`1[System.String]>]
20+
[-Enabled <Boolean>] [-Category <System.Collections.Generic.List`1[System.String]>]
2121
[-MetricCategory <System.Collections.Generic.List`1[System.String]>]
22-
[-Timegrains <System.Collections.Generic.List`1[System.String]>] [-RetentionEnabled <Boolean>]
22+
[-Timegrain <System.Collections.Generic.List`1[System.String]>] [-RetentionEnabled <Boolean>]
2323
[-WorkspaceId <String>] [-RetentionInDays <Int32>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
2424
[-Confirm] [<CommonParameters>]
2525
```
@@ -82,7 +82,7 @@ All the other categories remain the same.
8282

8383
### Example 4: Enable/disable multiple log categories
8484
```
85-
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Categories Category1,Category2
85+
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Category Category1,Category2
8686
StorageAccountId : <storageAccountId>
8787
StorageAccountName : <storageAccountName>
8888
Metrics
@@ -111,7 +111,7 @@ All the other metrics and logs categories remain the same.
111111

112112
### Example 4: Enable a time grain and multiple categories
113113
```
114-
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Categories Category1,Category2 -Timegrains PT1M
114+
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Category Category1,Category2 -Timegrain PT1M
115115
```
116116

117117
This command enables only Category1, Category2, and time grain PT1M.
@@ -126,14 +126,14 @@ This command uses the PowerShell pipeline to set (not change made) a diagnostic
126126

127127
## PARAMETERS
128128

129-
### -Categories
129+
### -Category
130130
Specifies the list of log categories to enable or disable, according to the value of *Enabled*.
131131
If no category is specified, this command operates on all supported categories.
132132

133133
```yaml
134134
Type: System.Collections.Generic.List`1[System.String]
135135
Parameter Sets: OldSetDiagnosticSetting
136-
Aliases: Category
136+
Aliases:
137137

138138
Required: False
139139
Position: Named
@@ -324,14 +324,14 @@ Accept pipeline input: True (ByPropertyName)
324324
Accept wildcard characters: False
325325
```
326326
327-
### -Timegrains
327+
### -Timegrain
328328
Specifies the time grains to enable or disable for metrics, according to the value of *Enabled*.
329329
If you do not specify a time grain, this command operates on all available time grains.
330330
331331
```yaml
332332
Type: System.Collections.Generic.List`1[System.String]
333333
Parameter Sets: OldSetDiagnosticSetting
334-
Aliases: Timegrain
334+
Aliases:
335335

336336
Required: False
337337
Position: Named
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2+
"Microsoft.Azure.Commands.Insights.dll","Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand","Set-AzDiagnosticSetting","0","2000","The cmdlet 'Set-AzDiagnosticSetting' no longer supports the parameter 'Categories' and no alias was found for the original parameter name.","Add the parameter 'Categories' back to the cmdlet 'Set-AzDiagnosticSetting', or add an alias to the original parameter name."
3+
"Microsoft.Azure.Commands.Insights.dll","Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand","Set-AzDiagnosticSetting","0","2000","The cmdlet 'Set-AzDiagnosticSetting' no longer supports the parameter 'Timegrains' and no alias was found for the original parameter name.","Add the parameter 'Timegrains' back to the cmdlet 'Set-AzDiagnosticSetting', or add an alias to the original parameter name."
4+
"Microsoft.Azure.Commands.Insights.dll","Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand","Set-AzDiagnosticSetting","0","1050","The parameter set 'OldSetDiagnosticSetting' for cmdlet 'Set-AzDiagnosticSetting' has been removed.","Add parameter set 'OldSetDiagnosticSetting' back to cmdlet 'Set-AzDiagnosticSetting'."

0 commit comments

Comments
 (0)