Skip to content

Commit e5d7c2f

Browse files
authored
Merge pull request Azure#3252 from AuxMon/dev
Using latest .Net SDK with small modifications
2 parents 772113c + 8047eba commit e5d7c2f

23 files changed

+1345
-129
lines changed

documentation/breaking-changes/upcoming-breaking-changes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
https://github.com/Azure/azure-powershell/blob/dev/documentation/breaking-changes/breaking-change-template.md
2626
-->
2727

28-
# Upcoming Breaking Changes
28+
# Upcoming Breaking Changes
29+

src/ResourceManager/Insights/ChangeLog.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,15 @@
2929
- Remove-AzureRmAutoscaleSetting
3030
- Remove-AzureRmLogProfile
3131
* Add new parameter to Set-AzureRmDiagnosticSetting
32-
- Parameter WorkspaceId is the OMS workspace Id
32+
- Parameter WorkspaceId is the OMS workspace Id
33+
34+
## Version 2.3.1
35+
* Parameter now accepts two more values in New-AzureRmAutoscaleRule
36+
- Parameter ScaleType now accepts the previous ChangeCount (default) plus two more values PercentChangeCount, and ExactCount
37+
- Add a warning message about this parameter accepting two more values
38+
39+
* Add parameter became optional in Add-AzureRmLogProfile
40+
- Parameter StorageAccountId is now optional
41+
42+
* Minor changes to the output classes to expose more properties
43+
- Before the user could see the properties because they were printed, but not access them programatically because they were protected for instance.

src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/NewAzureRmAutoscaleRuleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void NewAutoscaleRuleCommandParametersProcessing()
4545
// New-AutoscaleRule -MetricName <String> -MetricResourceUri <String> -Operator <{Equals | NotEquals | GreaterThan | GreaterThanOrEqual | LessThan | LessThanOrEqual}>
4646
// -MetricStatistic <{Average | Min | Max | Sum}> -Threshold <Double> [-TimeAggregationOperator <{Average | Minimum | Maximum | Last | Total | Count}>]
4747
// -TimeGrain <TimeSpan> [-TimeWindow <TimeSpan>] -ScaleActionCooldown <TimeSpan> -ScaleActionDirection <{None | Increase | Decrease}>
48-
// -ScaleActionScaleType <{ChangeSize | ChangeCount | PercentChangeCount | ExactCount}> -ScaleActionValue <String>
48+
// -ScaleActionScaleType <{ChangeSize | ChangeCount | PercentChangeCount}> -ScaleActionValue <String>
4949
Cmdlet.MetricName = "Requests";
5050
Cmdlet.MetricResourceId = "/subscriptions/a93fb07c-6c93-40be-bf3b-4f0deba10f4b/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/misitiooeltuyo";
5151
Cmdlet.Operator = ComparisonOperationType.GreaterThan;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.Insights">
65-
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.14.0-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
65+
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.14.1-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
6666
</Reference>
6767
<Reference Include="Microsoft.Azure.Test.Framework">
6868
<SpecificVersion>False</SpecificVersion>
@@ -72,6 +72,10 @@
7272
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
7373
<Private>True</Private>
7474
</Reference>
75+
<Reference Include="Microsoft.Bcl.Build">
76+
<SpecificVersion>False</SpecificVersion>
77+
<HintPath>..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll</HintPath>
78+
</Reference>
7579
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7680
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.4\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
7781
<Private>True</Private>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SetDiagnosticSettingCommandTests
3535
private const string resourceId = "/subscriptions/123/resourcegroups/rg/providers/rp/resource/myresource";
3636
private const string storageAccountId = "/subscriptions/123/resourcegroups/rg/providers/microsoft.storage/accounts/myaccount";
3737
private string calledResourceId;
38-
ServiceDiagnosticSettingsCreateOrUpdateParameters calledPutParameters;
38+
ServiceDiagnosticSettingsResource calledPutParameters;
3939

4040
public SetDiagnosticSettingCommandTests(Xunit.Abstractions.ITestOutputHelper output)
4141
{
@@ -92,9 +92,9 @@ public SetDiagnosticSettingCommandTests(Xunit.Abstractions.ITestOutputHelper out
9292
Body = request
9393
};
9494

95-
insightsDiagnosticsOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<ServiceDiagnosticSettingsCreateOrUpdateParameters>(), It.IsAny<Dictionary<string,List<string>>>(), It.IsAny<CancellationToken>()))
95+
insightsDiagnosticsOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<ServiceDiagnosticSettingsResource>(), It.IsAny<Dictionary<string,List<string>>>(), It.IsAny<CancellationToken>()))
9696
.Returns(Task.FromResult<Rest.Azure.AzureOperationResponse<ServiceDiagnosticSettingsResource>>(response))
97-
.Callback((string resourceId, ServiceDiagnosticSettingsCreateOrUpdateParameters putParameters, Dictionary<string,List<string>> headers) =>
97+
.Callback((string resourceId, ServiceDiagnosticSettingsResource putParameters, Dictionary<string,List<string>> headers) =>
9898
{
9999
this.calledResourceId = resourceId;
100100
this.calledPutParameters = putParameters;

src/ResourceManager/Insights/Commands.Insights.Test/LogProfiles/AddAzureRmLogProfileTests.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class AddAzureRmLogProfileTests
3434
private Mock<ICommandRuntime> commandRuntimeMock;
3535
private Rest.Azure.AzureOperationResponse<LogProfileResource> response;
3636
private string logProfileName;
37-
private LogProfileCreateOrUpdateParameters createOrUpdatePrms;
37+
private LogProfileResource createOrUpdatePrms;
3838

3939
public AddAzureRmLogProfileTests(ITestOutputHelper output)
4040
{
@@ -50,9 +50,9 @@ public AddAzureRmLogProfileTests(ITestOutputHelper output)
5050

5151
response = Utilities.InitializeLogProfileResponse();
5252

53-
insightsLogProfileOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<LogProfileCreateOrUpdateParameters>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
53+
insightsLogProfileOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<LogProfileResource>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
5454
.Returns(Task.FromResult<Rest.Azure.AzureOperationResponse<LogProfileResource>>(response))
55-
.Callback((string logProfileName, LogProfileCreateOrUpdateParameters createOrUpdateParams, Dictionary<string, List<string>> headers, CancellationToken t) =>
55+
.Callback((string logProfileName, LogProfileResource createOrUpdateParams, Dictionary<string, List<string>> headers, CancellationToken t) =>
5656
{
5757
this.logProfileName = logProfileName;
5858
createOrUpdatePrms = createOrUpdateParams;
@@ -65,7 +65,14 @@ public AddAzureRmLogProfileTests(ITestOutputHelper output)
6565
[Trait(Category.AcceptanceType, Category.CheckIn)]
6666
public void AddLogProfileCommandParametersProcessing()
6767
{
68-
// Null actions
68+
// With mandatory arguments only
69+
cmdlet.Name = Utilities.Name;
70+
cmdlet.Locations = new List<string>() { "East US" };
71+
cmdlet.ExecuteCmdlet();
72+
73+
Assert.Equal(Utilities.Name, this.logProfileName);
74+
75+
// With all arguments
6976
cmdlet.Name = Utilities.Name;
7077
cmdlet.Locations = new List<string>() {"East US"};
7178
cmdlet.RetentionInDays = 10;

src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public static EventData CreateFakeEvent()
5858
value: "Microsoft Resources"),
5959
authorization: new SenderAuthorization(
6060
action: "PUT",
61-
condition: "",
6261
role: "Sender",
6362
scope: "None"),
6463
caller: Caller,
@@ -117,12 +116,12 @@ public static AzureOperationResponse<LogProfileResource> InitializeLogProfileRes
117116

118117
return new AzureOperationResponse<LogProfileResource>()
119118
{
120-
Body = new LogProfileResource(location: "East US", id: "MyLogProfileId")
119+
Body = new LogProfileResource(location: "East US", id: "MyLogProfileId", locations: new string[] { "EastUs" })
120+
121121
{
122122
Categories = new List<string>() { "cat2" },
123123
ServiceBusRuleId = "myBusId",
124124
StorageAccountId = "myStorageAccId",
125-
Locations = new string[] { "EastUs" },
126125
Name = Utilities.Name,
127126
RetentionPolicy = new RetentionPolicy(enabled: true, days: 10),
128127
Tags = null

src/ResourceManager/Insights/Commands.Insights.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Insights" version="0.14.0-preview" targetFramework="net45" />
7+
<package id="Microsoft.Azure.Insights" version="0.14.1-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ public class NewAzureRmAutoscaleRuleCommand : AzureRMCmdlet
2929
private readonly TimeSpan MinimumTimeWindow = TimeSpan.FromMinutes(5);
3030
private readonly TimeSpan MinimumTimeGrain = TimeSpan.FromMinutes(1);
3131

32-
/// <summary>
33-
/// Scale type enum.
34-
/// Keep this enum for backwards compatibility. The only value supported is ChangeCount
35-
/// </summary>
36-
public enum ScaleType
37-
{
38-
ChangeCount
39-
}
40-
4132
#region Cmdlet parameters
4233

4334
/// <summary>
@@ -105,7 +96,7 @@ public enum ScaleType
10596
/// <summary>
10697
/// Gets or sets the scale action value
10798
/// </summary>
108-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The scale type for the setting. It defaults to ChangeCount, only value supported. Warning: This parameter has no effect.")]
99+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The scale type for the setting. It supports these values: ChangeCount (default), PercentChangeCount, ExactCount")]
109100
[ValidateNotNullOrEmpty]
110101
public ScaleType ScaleActionScaleType { get; set; }
111102

@@ -123,7 +114,7 @@ public enum ScaleType
123114
/// </summary>
124115
public override void ExecuteCmdlet()
125116
{
126-
WriteWarning("The parameter ScaleActionType has no effect. It was kept here for backwards compatibility, but it could be removed in the future.");
117+
WriteWarning("The parameter ScaleActionType has been extended, it receives the following values now: ChangeCount (previous only value and current default), PercentChangeCount, ExactCount. The parameter could become mandatory in future versions.");
127118
ScaleRule rule = this.CreateSettingRule();
128119
WriteObject(rule);
129120
}
@@ -156,11 +147,13 @@ public ScaleRule CreateSettingRule()
156147
TimeWindow = this.TimeWindow == default(TimeSpan) ? MinimumTimeWindow : this.TimeWindow,
157148
};
158149

150+
// Notice ChangeCount is (ScaleType)0, so this is the default in this version. It was the only value in the previous version.
159151
ScaleAction action = new ScaleAction()
160152
{
161153
Cooldown = this.ScaleActionCooldown,
162154
Direction = this.ScaleActionDirection,
163-
Value = this.ScaleActionValue
155+
Value = this.ScaleActionValue,
156+
Type = this.ScaleActionScaleType
164157
};
165158

166159
return new ScaleRule()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5555
</Reference>
5656
<Reference Include="Microsoft.Azure.Insights">
57-
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.14.0-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
57+
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.14.1-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
5858
</Reference>
5959
<Reference Include="Microsoft.CSharp" />
6060
<Reference Include="Microsoft.Data.Edm">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class SetAzureRmDiagnosticSettingCommand : ManagementCmdletBase
9999

100100
protected override void ProcessRecordInternal()
101101
{
102-
var putParameters = new ServiceDiagnosticSettingsCreateOrUpdateParameters();
102+
var putParameters = new ServiceDiagnosticSettingsResource(location: string.Empty);
103103

104104
ServiceDiagnosticSettingsResource getResponse = this.InsightsManagementClient.ServiceDiagnosticSettings.GetAsync(resourceUri: this.ResourceId, cancellationToken: CancellationToken.None).Result;
105105

src/ResourceManager/Insights/Commands.Insights/LogProfiles/AddAzureRmLogProfileCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class AddAzureRmLogProfileCommand : ManagementCmdletBase
4141
/// <summary>
4242
/// Gets or sets the storage account parameter of the cmdlet
4343
/// </summary>
44-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The storage account id")]
44+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The storage account id")]
4545
[ValidateNotNullOrEmpty]
4646
public string StorageAccountId { get; set; }
4747

@@ -77,15 +77,14 @@ public class AddAzureRmLogProfileCommand : ManagementCmdletBase
7777

7878
protected override void ProcessRecordInternal()
7979
{
80-
var putParameters = new LogProfileCreateOrUpdateParameters();
80+
var putParameters = new LogProfileResource(location: string.Empty, locations: this.Locations);
8181

8282
if (this.Categories == null)
8383
{
8484
this.Categories = new List<string>(ValidCategories);
8585
}
8686

8787
putParameters.Categories = this.Categories;
88-
putParameters.Locations = this.Locations;
8988
putParameters.RetentionPolicy = new RetentionPolicy
9089
{
9190
Days = this.RetentionInDays.HasValue ? this.RetentionInDays.Value : 0,

0 commit comments

Comments
 (0)