Skip to content
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
4 changes: 3 additions & 1 deletion src/ResourceManager/Compute/AzureRM.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ CmdletsToExport = 'Remove-AzureRmAvailabilitySet', 'Get-AzureRmAvailabilitySet',
'Set-AzureRmVmssRollingUpgradePolicy',
'Set-AzureRmVmssDiskEncryptionExtension',
'Disable-AzureRmVmssDiskEncryption',
'Get-AzureRmVmssDiskEncryption', 'Get-AzureRmVmssVMDiskEncryption'
'Get-AzureRmVmssDiskEncryption', 'Get-AzureRmVmssVMDiskEncryption',
'Export-AzureRmLogAnalyticRequestRateByInterval',
'Export-AzureRmLogAnalyticThrottledRequests'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
11 changes: 7 additions & 4 deletions src/ResourceManager/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
- Additional information about change #1
-->
## Current Release
* Log analytic feature
- Added `Export-AzureRmLogAnalyticRequestRateByInterval` cmdlet
- Added `Export-AzureRmLogAnalyticThrottledRequests` cmdlet
* `New-AzureRmVMSS` prints connection strings in verbose mode.
* `New-AzureRmVmss` supports public IP address, load balancing rules, inbound NAT rules.
* WriteAccelerator feature
- Added WriteAccelerator switch parameter to the following cmdlets:
Set-AzureRmVMOSDisk
Set-AzureRmVMDataDisk
Add-AzureRmVMDataDisk
Add-AzureRmVmssDataDisk
Set-AzureRmVMOSDisk
Set-AzureRmVMDataDisk
Add-AzureRmVMDataDisk
Add-AzureRmVmssDataDisk
- Added OsDiskWriteAccelerator switch parameter to the following cmdlet:
Set-AzureRmVmssStorageProfile.
- Added OsDiskWriteAccelerator Boolean parameter to the following cmdlets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<Compile Include="ScenarioTests\DiagnosticsExtensionTests.cs" />
<Compile Include="ScenarioTests\DiskRPTests.cs" />
<Compile Include="ScenarioTests\ImageTests.cs" />
<Compile Include="ScenarioTests\LogAnalyticTests.cs" />
<Compile Include="ScenarioTests\NewVhdVMTests.cs" />
<Compile Include="ScenarioTests\ResourceSkuTests.cs" />
<Compile Include="ScenarioTests\SqlIaaSExtensionTests.cs">
Expand Down Expand Up @@ -311,6 +312,9 @@
<None Include="ScenarioTests\ImageTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\LogAnalyticTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\NewVhdVMTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void RunPsTestWorkflow(
helper.RMStorageModule,
helper.GetRMModulePath("AzureRM.Compute.psd1"),
helper.GetRMModulePath("AzureRM.Network.psd1"),
helper.RMStorageDataPlaneModule,
"AzureRM.Storage.ps1",
"AzureRM.Resources.ps1");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.Compute.Test.ScenarioTests
{
public class LogAnalyticTests
{
public LogAnalyticTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestExportLogAnalyticThrottledRequestsNegative()
{
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticThrottledRequestsNegative");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestExportLogAnalyticRequestRateByIntervalNegative()
{
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticRequestRateByIntervalNegative");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestExportLogAnalytics()
{
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalytics");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# ----------------------------------------------------------------------------------
#
# 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
Test Export Log Analytic Throttled Requests
#>
function Test-ExportLogAnalyticThrottledRequestsNegative
{
$loc = Get-ComputeOperationLocation;
$from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9;
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
Assert-ThrowsContains { `
$result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} `
"the given SAS URI";
}

<#
.SYNOPSIS
Test Export Log Analytic Request Rate By Interval
#>
function Test-ExportLogAnalyticRequestRateByIntervalNegative
{
$loc = Get-ComputeOperationLocation;
$from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9;
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
$interval = "FiveMins";
Assert-ThrowsContains { `
$result = Export-AzureRmLogAnalyticRequestRateByInterval -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -IntervalLength $interval -GroupByThrottlePolicy -GroupByOperationName;} `
"the given SAS URI";
}

<#
.SYNOPSIS
Test Export Log Analytics positive scenario
#>
function Test-ExportLogAnalytics
{
$rgname = Get-ComputeTestResourceName;
$loc = Get-ComputeOperationLocation;
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
$container = "test";
$sastoken = '?fakesas'

New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$key = Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
$context = New-AzureStorageContext -StorageAccountName $stoname -StorageAccountKey $key.Key1;

if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
New-AzureStorageContainer -Name $container -Context $context;
$sastoken = Get-AzureStorageContainer -Name $container -Context $context | New-AzureStorageContainerSASToken -Permission rwdl -Context $context;
}

try
{
$from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9;
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
$sasuri = "https://$stoname.blob.core.windows.net/$container$sastoken";
$interval = "FiveMins";
$result = Export-AzureRmLogAnalyticRequestRateByInterval -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -IntervalLength $interval -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
Assert-AreEqual "Succeeded" $result.Status;
$output = $result | Out-String;
Assert-True { $output.Contains(".csv"); }
Assert-True { $output.Contains("RequestRateByInterval"); }

$result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
Assert-AreEqual "Succeeded" $result.Status;
$output = $result | Out-String;
Assert-True { $output.Contains(".csv"); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to check this file to ensure it has the right format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think checking the content of the file is a scope of Powershell cmdlets test. It should be checked during the API test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check the blob to ensure the file is there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Assert-True { $output.Contains("ThrottledRequests"); }

if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$blobs = Get-AzureStorageBlob -Container test -Context $context;
$request_blob = $blobs | where {$_.name.contains("RequestRateByInterval")};
$throttle_blob = $blobs | where {$_.name.contains("ThrottledRequests")};
Assert-NotNull $request_blob;
Assert-NotNull $throttle_blob;
}
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname;
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public IImagesOperations ImagesClient
}
}

public ILogAnalyticsOperations LogAnalyticsClient
{
get
{
return ComputeClient.ComputeManagementClient.LogAnalytics;
}
}

public IResourceSkusOperations ResourceSkusClient
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public override void ExecuteCmdlet()
[Parameter(
ParameterSetName = "DefaultParameter",
Mandatory = false)]
[AllowNull]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public override void ExecuteCmdlet()
[Parameter(
ParameterSetName = "DefaultParameter",
Mandatory = false)]
[AllowNull]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@ public override void ExecuteCmdlet()
[Parameter(
ParameterSetName = "DefaultParameter",
Position = 3,
Mandatory = false)]
[AllowNull]
Mandatory = true)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change - why is this being added?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved offline - cmdlet fails without the parameter specified.

public AccessLevel Access { get; set; }

[Parameter(
ParameterSetName = "DefaultParameter",
Position = 4,
Mandatory = false)]
[AllowNull]
public int DurationInSecond { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public override void ExecuteCmdlet()
[Parameter(
ParameterSetName = "DefaultParameter",
Mandatory = false)]
[AllowNull]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ protected static object[] ConvertDynamicParameters(RuntimeDefinedParameterDictio
"ImageListByResourceGroup",
"ImageListByResourceGroupNext",
"ImageListNext",
"LogAnalyticExportRequestRateByInterval",
"LogAnalyticExportThrottledRequests",
"ResourceSkuList",
"ResourceSkuListNext",
"SnapshotCreateOrUpdate",
Expand Down Expand Up @@ -262,6 +264,12 @@ protected override void ProcessRecord()
case "ImageListNext":
ExecuteImageListNextMethod(argumentList);
break;
case "LogAnalyticExportRequestRateByInterval":
ExecuteLogAnalyticExportRequestRateByIntervalMethod(argumentList);
break;
case "LogAnalyticExportThrottledRequests":
ExecuteLogAnalyticExportThrottledRequestsMethod(argumentList);
break;
case "ResourceSkuList":
ExecuteResourceSkuListMethod(argumentList);
break;
Expand Down Expand Up @@ -508,6 +516,8 @@ public virtual object GetDynamicParameters()
case "ImageListByResourceGroup": return CreateImageListByResourceGroupDynamicParameters();
case "ImageListByResourceGroupNext": return CreateImageListByResourceGroupNextDynamicParameters();
case "ImageListNext": return CreateImageListNextDynamicParameters();
case "LogAnalyticExportRequestRateByInterval": return CreateLogAnalyticExportRequestRateByIntervalDynamicParameters();
case "LogAnalyticExportThrottledRequests": return CreateLogAnalyticExportThrottledRequestsDynamicParameters();
case "ResourceSkuList": return CreateResourceSkuListDynamicParameters();
case "ResourceSkuListNext": return CreateResourceSkuListNextDynamicParameters();
case "SnapshotCreateOrUpdate": return CreateSnapshotCreateOrUpdateDynamicParameters();
Expand Down
Loading