Skip to content

Insights breaking changes #8075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void SetWorkspace()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SetSomeCategories()
{
cmdlet.Categories = new List<string> { "TestCategory1" };
cmdlet.Category = new List<string> { "TestCategory1" };
cmdlet.Enabled = false;
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
cmdlet.ExecuteCmdlet();
Expand All @@ -216,14 +216,14 @@ public void SetSomeCategories()
Enabled = false
}
});
cmdlet.Categories = new List<string> { "TestCategory3" };
cmdlet.Category = new List<string> { "TestCategory3" };
cmdlet.Enabled = false;
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
cmdlet.ExecuteCmdlet();

// Testing the new metric categories must be known before the cmdlet can add them
expectedSettings.Metrics[0].Enabled = false;
cmdlet.Categories = null;
cmdlet.Category = null;
cmdlet.MetricCategory = new List<string> { "MetricCat1" };
cmdlet.Enabled = false;
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
Expand All @@ -242,7 +242,7 @@ public void SetSomeCategories()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SetSomeTimeGrains()
{
cmdlet.Timegrains = new List<string> { "PT1H" };
cmdlet.Timegrain = new List<string> { "PT1H" };
cmdlet.Enabled = false;
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
cmdlet.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function Test-SetAzureRmDiagnosticSetting-CategoriesOnly
{
try
{
$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
$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

Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
Assert-AreEqual "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.ServiceBus/namespaces/ns1/authorizationrules/ar1" $actual.EventHubName
Expand Down Expand Up @@ -198,7 +198,7 @@ function Test-SetAzureRmDiagnosticSetting-TimegrainsOnly
{
try
{
$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
$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

Assert-AreEqual $actual.StorageAccountId "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/Microsoft.Storage/storageAccounts/montest3470"
Assert-AreEqual "workspace1" $actual.WorkspaceId
Expand Down
3 changes: 2 additions & 1 deletion src/ResourceManager/Insights/Commands.Insights/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* Overview of change #1
- Additional information about change #1
-->
## Current Release
## Current Release
* Removed plural names "Categories" and "Timegrains" parameter in favor of singular parameter names
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ public class SetAzureRmDiagnosticSettingCommand : ManagementCmdletBase
/// </summary>
[Parameter(ParameterSetName = SetAzureRmDiagnosticSettingOldParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The log categories")]
[ValidateNotNullOrEmpty]
[Alias("Category")]
public List<string> Categories { get; set; }
public List<string> Category { get; set; }

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

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

// Name defaults to 'service'
Expand Down Expand Up @@ -275,15 +272,15 @@ protected override void ProcessRecordInternal()

SetWorkspace(properties);

if (this.Categories == null && this.MetricCategory == null && this.Timegrains == null)
if (this.Category == null && this.MetricCategory == null && this.Timegrain == null)
{
WriteDebugWithTimestamp("Changing the enable properties");
SetAllCategoriesAndTimegrains(properties);
}
else
{
WriteDebugWithTimestamp("Setting categories and time grains");
if (this.Categories != null)
if (this.Category != null)
{
SetSelectedCategories(properties);
}
Expand All @@ -293,7 +290,7 @@ protected override void ProcessRecordInternal()
SetSelectedMetricsCategories(properties);
}

if (this.Timegrains != null)
if (this.Timegrain != null)
{
SetSelectedTimegrains(properties);
}
Expand Down Expand Up @@ -392,18 +389,18 @@ private void SetSelectedTimegrains(DiagnosticSettingsResource properties)
{
if (!this.isEnbledParameterPresent)
{
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrains' parameter.");
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrain' parameter.");
}

if (this.Timegrains != null && this.Timegrains.Count > 0)
if (this.Timegrain != null && this.Timegrain.Count > 0)
{
if (properties.Metrics == null)
{
properties.Metrics = new List<MetricSettings>();
}

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

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

foreach (string category in this.Categories)
foreach (string category in this.Category)
{
LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));
if (logSettings == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Sets the logs and metrics settings for the resource.
```
Set-AzDiagnosticSetting -ResourceId <String> [-Name <String>] [-StorageAccountId <String>]
[-ServiceBusRuleId <String>] [-EventHubName <String>] [-EventHubAuthorizationRuleId <String>]
[-Enabled <Boolean>] [-Categories <System.Collections.Generic.List`1[System.String]>]
[-Enabled <Boolean>] [-Category <System.Collections.Generic.List`1[System.String]>]
[-MetricCategory <System.Collections.Generic.List`1[System.String]>]
[-Timegrains <System.Collections.Generic.List`1[System.String]>] [-RetentionEnabled <Boolean>]
[-Timegrain <System.Collections.Generic.List`1[System.String]>] [-RetentionEnabled <Boolean>]
[-WorkspaceId <String>] [-RetentionInDays <Int32>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```
Expand Down Expand Up @@ -82,7 +82,7 @@ All the other categories remain the same.

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

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

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

## PARAMETERS

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

```yaml
Type: System.Collections.Generic.List`1[System.String]
Parameter Sets: OldSetDiagnosticSetting
Aliases: Category
Aliases:

Required: False
Position: Named
Expand Down Expand Up @@ -324,14 +324,14 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Timegrains
### -Timegrain
Specifies the time grains to enable or disable for metrics, according to the value of *Enabled*.
If you do not specify a time grain, this command operates on all available time grains.

```yaml
Type: System.Collections.Generic.List`1[System.String]
Parameter Sets: OldSetDiagnosticSetting
Aliases: Timegrain
Aliases:

Required: False
Position: Named
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
"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."
"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."
"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'."