Azure / Azure/Azure-Lighthouse-samples
Create-AzDiagPolicy.ps1 fails for resourceType Microsoft.NetApp/netAppAccounts/capacityPools/volumes (and potentially others)
- Dominant language
- PowerShell
- Stars
- 323
- Forks
- 313
- PR merge metrics
- No merged PRs in 30d
Description
### 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 -ExportAll -ExportDir policies -AllRegions`
### Error
```
Update-LogAnalyticsJSON : Cannot bind argument to parameter 'nameField' because it is an empty string.
At C:\Users\\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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.