-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Compute] Add cmdlets for CRP Log Analytics. #5665
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
Conversation
maddieclayton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will check this again when test coverage is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these tests should have a positive test case (can you create a new blob and container and put the logs there?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot check in SAS Uri to GitHub because of credscan. If I add a positive case with real SAS Uri and then remove secrets, then anyone who runs this test with record mode will fail. Wayne already tested this manually and I also can see that this Powershell command sends a correct REST call from recorded json file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you create a new storage account in test, do the manipulations there, and remove the storage account, you should not have a security issue. I believe that this code is working now, but we need positive tests to ensure it continues working in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maddieclayton I added positive test case. Note that storage cmdlets are not available in compute test, so I had to manually run those cmdlets. So I commented out any manual steps in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you are able to access the cmdlets, as it is being done here:
Line 42 in bbe5ee9
| New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype |
Line 481 in cd0497d
| New-AzureStorageContainer -Name $containerName -Context $context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maddieclayton I update the test
…nto loganalytics # Conflicts: # src/ResourceManager/Compute/ChangeLog.md
| #> | ||
| function Test-ExportLogAnalyticThrottledRequests | ||
| { | ||
| $loc = "West Central US"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use Get-Location everywhere a location is set: https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Common.ps1#L583
Please ensure you specify all three parameter values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maddieclayton this API is only available in this location. Get-Location gives a different location, so I need to give a specific location for this API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you are able to access the cmdlets, as it is being done here:
Line 42 in bbe5ee9
| New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype |
Line 481 in cd0497d
| New-AzureStorageContainer -Name $containerName -Context $context |
| #> | ||
| function Test-ExportLogAnalytics | ||
| { | ||
| $rgname = "hyleelog"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually give this value, because I created the resource group manually for setting up my test. (because I cannot run storage cmdlets during the test.) So, I should not use getassetname because it gives a random name.
| $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"); } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| .SYNOPSIS | ||
| Test Export Log Analytic Request Rate By Interval | ||
| #> | ||
| function Test-ExportLogAnalyticRequestRateByInterval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change test names to reflect that this is a test for failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Position = 3, | ||
| Mandatory = false)] | ||
| [AllowNull] | ||
| Mandatory = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved offline.
| ## SYNTAX | ||
|
|
||
| ``` | ||
| Export-AzureRmLogAnalyticRequestRateByInterval [-FromTime] <DateTime> [-GroupByOperationName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerate this once you reorder the parameters in cs file so that this syntax makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the help generator has a bug. The parameters have positional values except switch parameters, but the help generator does not generate Syntax correctly according to the positional values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't own the help generator, so if you would like to file a bug you can do so here: https://github.com/PowerShell/platyPS. For now, the best way to solve this issue is order the parameters in the cs file in the order you want them shown in the syntax.
| ``` | ||
| ### -GroupByOperationName | ||
| Group query result by by Operation Name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you say by twice
| ``` | ||
| ### -GroupByOperationName | ||
| Group query result by by Operation Name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'MaxUnhealthyInstancePercent'.","Change the type for parameter 'MaxUnhealthyInstancePercent' back to 'System.Nullable`1[System.Int32]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'SkuCapacity'.","Change the type for parameter 'SkuCapacity' back to 'System.Nullable`1[System.Int32]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]' for parameter 'OsDiskCaching'.","Change the type for parameter 'OsDiskCaching' back to 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.GrantAzureRmDiskAccess","Grant-AzureRmDiskAccess","0","2030","The parameter 'Access' is no longer optional for the parameter set 'DefaultParameter' for cmdlet 'Grant-AzureRmDiskAccess'.","Make 'Access' optional for the parameter set 'DefaultParameter'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these two lines, we are not accepting breaking changes in non preview modules until May.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a bug fix. Access should be a mandatory in CRP API. not giving this value in Powershell results in a bad request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved offline.
…nto loganalytics # Conflicts: # src/ResourceManager/Compute/ChangeLog.md
99608dc to
90b5c52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set the "preferredLocation" parameter in Get-Location, it will be set to that location if it is available in the service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use getassetname for all resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maddieclayton Get-ComputeTestResourceName uses getassetname.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we determined that you are able to run the storage cmdlets here. Why are these lines still commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maddieclayton the test framework does not work with data plane cmdlets in playback mode. If I uncomment these lines, this test only works in record mode test.
| $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"); } |
There was a problem hiding this comment.
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?
| Position = 3, | ||
| Mandatory = false)] | ||
| [AllowNull] | ||
| Mandatory = true)] |
There was a problem hiding this comment.
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.
| Mandatory = true, | ||
| ValueFromPipelineByPropertyName = true, | ||
| ValueFromPipeline = false)] | ||
| [AllowNull] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
| }); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
| Position = 3, | ||
| Mandatory = false)] | ||
| [AllowNull] | ||
| Mandatory = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved offline.
| ## SYNTAX | ||
|
|
||
| ``` | ||
| Export-AzureRmLogAnalyticRequestRateByInterval [-FromTime] <DateTime> [-GroupByOperationName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't own the help generator, so if you would like to file a bug you can do so here: https://github.com/PowerShell/platyPS. For now, the best way to solve this issue is order the parameters in the cs file in the order you want them shown in the syntax.
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'MaxUnhealthyInstancePercent'.","Change the type for parameter 'MaxUnhealthyInstancePercent' back to 'System.Nullable`1[System.Int32]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'SkuCapacity'.","Change the type for parameter 'SkuCapacity' back to 'System.Nullable`1[System.Int32]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]' for parameter 'OsDiskCaching'.","Change the type for parameter 'OsDiskCaching' back to 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]'." | ||
| "Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.GrantAzureRmDiskAccess","Grant-AzureRmDiskAccess","0","2030","The parameter 'Access' is no longer optional for the parameter set 'DefaultParameter' for cmdlet 'Grant-AzureRmDiskAccess'.","Make 'Access' optional for the parameter set 'DefaultParameter'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved offline.
3890923 to
7b500c8
Compare
|
on demand here: https://azuresdkci.westus2.cloudapp.azure.com/view/PowerShell/job/powershell-demand/578/ (and 577) |
|
failing on demand test is now skipped, okay to merge. |
Design review accepted : https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/13
This PR also contains the following bug fixes.
#5189
#5101
#3735
Description
Checklist
CONTRIBUTING.mdplatyPSmodule