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

Create-AzDiagPolicy.ps1 fails for resourceType Microsoft.NetApp/netAppAccounts/capacityPools/volumes (and potentially others) #132

Open
wozneyr opened this issue Nov 1, 2023 · 0 comments

Comments

@wozneyr
Copy link

wozneyr commented Nov 1, 2023

Description

In the Parse-ResourceType function found in the Create-AzDiagPolicy.ps1 script there are currently checks for 1 or 2 / characters, but not 3.

Block in question:

    if($ResourceType.Split("/").count -eq 3)
    {
        $nameField = "fullName"
        $DirectoryNameBase = "Apply-Diag-Settings-$sinkDest-" + $($resourceType.Split("/", 3))[0] + "-" + $($resourceType.Split("/", 3))[1] + "-" + $($resourceType.Split("/", 3))[2] + $KindDirVar
    }
    if($ResourceType.Split("/").count -eq 2)
    {
        $nameField = "name"
        $DirectoryNameBase = "Apply-Diag-Settings-$sinkDest-" + $($resourceType.Split("/", 2))[0] + "-" + $($resourceType.Split("/", 2))[1] + $KindDirVar
    }

Command Ran

.\Create-AzDiagPolicy.ps1 -ExportLA -ValidateJSON -ManagementGroup -ManagementGroupID <management_group_id> -ExportAll -ExportDir policies -AllRegions

Error

Update-LogAnalyticsJSON : Cannot bind argument to parameter 'nameField' because it is an empty string.
At C:\Users\<user>\Documents\WindowsPowerShell\Scripts\Create-AzDiagPolicy.ps1:2376 char:153
+ ... rray $metricsArray -logsArray $logsArray -nameField $RPVar[1] -kind $ ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Update-LogAnalyticsJSON], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Update-LogAnalyticsJSON

Expected Behavior

Diagnostic Policy JSON is generated for Microsoft.NetApp/netAppAccounts/capacityPools/volumes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant