Skip to content
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

Log Analytics new parameters Group By ApplicationId and UserAgent #14015

Merged
merged 14 commits into from
Jan 29, 2021
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
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>Compute</PsModuleName>
Expand Down
7 changes: 7 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/LogAnalyticTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public void TestExportLogAnalyticRequestRateByIntervalNegative()
TestRunner.RunTestScript("Test-ExportLogAnalyticRequestRateByIntervalNegative");
}

[Fact]
[Trait(Category.AcceptanceType, Category.LiveOnly)]
public void TestExportLogAnalyticGroupByParameters()
{
TestRunner.RunTestScript("Test-ExportLogAnalyticGroupByParameters");
}

[Fact(Skip = "BUG: LogAnalytics does not work.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait("Re-record", "ClientRuntime changes")]
Expand Down
62 changes: 62 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/LogAnalyticTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,68 @@ function Test-ExportLogAnalyticRequestRateByIntervalNegative
"the given SAS URI";
}

<#
.SYNOPSIS
Test Export Log Analytics group by parameters
#>
function Test-ExportLogAnalyticGroupByParameters
{

# Setup
$rgname = Get-ComputeTestResourceName;
$loc = "westus2";

try
{
New-AzResourceGroup -Name $rgname -Location $loc -Force;

$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
$container = "contain";
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$key = Get-AzStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
Assert-NotNull $key;

$from = Get-Date -Year 2021 -Month 1 -Day 4 -Hour 9;
$to = Get-Date -Year 2021 -Month 1 -Day 5 -Hour 9;

$context = New-AzStorageContext -StorageAccountName $stoname -StorageAccountKey $key.Value[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check the way your module depends on Az.Storage to see whey New-AzStorageContext cannot be recognized.

Copy link
Member Author

@Sandido Sandido Jan 26, 2021

Choose a reason for hiding this comment

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

@msJinLei , this build error is not present on my local VS.

Compute.Test.csproj does not directly refer to Az.Storage, rather it refers to Az.Compute, https://github.com/Azure/azure-powershell/blob/SandidoDataDogRelease2/src/Compute/Compute.Test/Compute.Test.csproj#L15 .

Compute.csproj refers to WindowsAzure.Storage 9.3.0 https://github.com/Azure/azure-powershell/blob/SandidoDataDogRelease2/src/Compute/Compute/Compute.csproj#L19,
and this cmdlet has been used before without a build error, https://github.com/Azure/azure-powershell/blob/SandidoDataDogRelease2/src/Compute/Compute.Test/ScenarioTests/LogAnalyticTests.ps1#L123.

Copy link
Member Author

@Sandido Sandido Jan 26, 2021

Choose a reason for hiding this comment

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

Could this error be due to the CredScan check failing instead? New-AzVMConfig is also not recognized as a cmdlet.
Error:
Exception:System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Azure.Management.Compute, Version=42.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

This may be causing all Az Compute cmdlets to not function. And the Az Storage cmdlets which is a dependency from Az Compute.


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

$sasuri = "https://$stoname.blob.core.windows.net/$container$sastoken";

$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByUserAgent;
Assert-AreEqual "Succeeded" $result.Status;

if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$blobs = Get-AzStorageBlob -Container $container -Context $context;
$throttle_blob = $blobs | where {$_.name.contains("ThrottledRequests")};
Assert-NotNull $throttle_blob;
}

$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByApplicationId;
Assert-AreEqual "Succeeded" $result.Status;

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

<#
.SYNOPSIS
Test Export Log Analytics positive scenario
Expand Down
Loading