Azure / Azure/azure-powershell

Get-AzDiagnosticSettingCategory returns categories, but the type doesn't support Diagnostic Settings

Open
#25,880 3 comments 0 reactions 0 assignees View on GitHub
act-observability-squad Azure PS Team bug customer-reported Monitor - Diagnostic Settings needs-team-attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

Get-AzDiagnosticSettingCategory is supposed to "List supported diagnostic setting categories."

When I run it against certain types, it returns one/more categories, but when I try to create with New-AzDiagnosticSetting, it fails saying "the resource type does not support diagnostic settings".

Why am I getting mixed messages? Can the Get command be updated to not return an unsupported category, please?

### Issue script & Debug output

```PowerShell
PS > Get-AzDiagnosticSettingCategory -ResourceId $mydisk.ResourceId

DEBUG: [CmdletBeginProcessing]: Starting command

DEBUG: CmdletBeginProcessing:

DEBUG: CmdletProcessRecordStart:

DEBUG: CmdletGetPipeline:

DEBUG: CmdletBeforeAPICall:

DEBUG: URLCreated: //subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettingsCategories?api-version=2021-05-01-preview

DEBUG: RequestCreated: //subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettingsCategories?api-version=2021-05-01-preview

DEBUG: HeaderParametersAdded:

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:

GET

Absolute Uri:

https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettingsCategories?api-version=2021-05-01-preview

Headers:

x-ms-unique-id : 553

x-ms-client-request-id :

CommandName : Get-AzDiagnosticSettingCategory

FullCommandName : Get-AzDiagnosticSettingCategory_List

ParameterSetName : __AllParameterSets

User-Agent : AzurePowershell/v12.2.0,PSVersion/v7.4.4,Az.DiagnosticSetting/5.2.1

Body:

DEBUG: BeforeCall:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:

OK

Headers:

Cache-Control : no-cache

Pragma : no-cache

Strict-Transport-Security : max-age=31536000; includeSubDomains

x-ms-request-id :

x-ms-ratelimit-remaining-subscription-reads: 249

x-ms-ratelimit-remaining-subscription-global-reads: 3749

x-ms-correlation-request-id :

x-ms-routing-request-id : NORTHCENTRALUS:20240816T133645Z:

X-Content-Type-Options : nosniff

X-Cache : CONFIG_NOCACHE

X-MSEdge-Ref : Ref A: 92F290F0E427417C9DD5594D29618CE1 Ref B: CH1AA2020616035 Ref C: 2024-08-16T13:36:45Z

Date : Fri, 16 Aug 2024 13:36:45 GMT

Body:

{

"value": [

{

"id": "/subscriptions//resourcegroups//providers/microsoft.compute/disks/_osdisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/microsoft.insights/diagnosticSettingsCategories/Disk Performance",

"type": "microsoft.insights/diagnosticSettingsCategories",

"name": "Disk Performance",

"location": null,

"kind": null,

"tags": null,

"properties": {

"displayName": "Disk Performance",

"categoryType": "Metrics"

},

"identity": null

}

]

}

DEBUG: ResponseCreated:

DEBUG: BeforeResponseDispatch:

DEBUG: Finally:

DEBUG: CmdletAfterAPICall:

DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process

DEBUG: CmdletProcessRecordAsyncEnd:

DEBUG: CmdletProcessRecordEnd:

DEBUG: AzureQoSEvent: Module: Az.Monitor:5.2.1; CommandName: Get-AzDiagnosticSettingCategory; PSVersion: 7.4.4; IsSuccess: True; Duration: 00:00:00.2913647; SanitizeDuration: 00:00:00.0001788

Name

----

Disk Performance

PS > New-AzDiagnosticSetting -Name 'test' -ResourceId $mydisk.ResourceId -EventHubName $EventHubCentralName -EventHubAuthorizationRuleId $EventHubCentralPath

DEBUG: [CmdletBeginProcessing]: Starting command

DEBUG: CmdletBeginProcessing:

DEBUG: CmdletProcessRecordStart:

DEBUG: CmdletGetPipeline:

DEBUG: CmdletBeforeAPICall:

DEBUG: URLCreated: //subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettings/test?api-version=2021-05-01-preview

DEBUG: RequestCreated: //subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettings/test?api-version=2021-05-01-preview

DEBUG: HeaderParametersAdded:

DEBUG: BodyContentSet:

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:

PUT

Absolute Uri:

https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.Compute/disks/_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettings/test?api-version=2021-05-01-preview

Headers:

x-ms-unique-id : 554

x-ms-client-request-id :

CommandName : New-AzDiagnosticSetting

FullCommandName : New-AzDiagnosticSetting_CreateExpanded

ParameterSetName : __AllParameterSets

User-Agent : AzurePowershell/v12.2.0,PSVersion/v7.4.4,Az.DiagnosticSetting/5.2.1

Body:

{

"properties": {

"eventHubAuthorizationRuleId": "/subscriptions//resourceGroups//providers/Microsoft.EventHub/namespaces//authorizationrules/sending",

"eventHubName": ""

}

}

DEBUG: BeforeCall:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:

BadRequest

Headers:

Cache-Control : no-cache

Pragma : no-cache

Strict-Transport-Security : max-age=31536000; includeSubDomains

x-ms-request-id : 00000000-0000-0000-0000-000000000000

x-ms-ratelimit-remaining-subscription-resource-requests: 149

x-ms-correlation-request-id :

x-ms-routing-request-id : NORTHCENTRALUS:20240816T134039Z:

X-Content-Type-Options : nosniff

X-Cache : CONFIG_NOCACHE

X-MSEdge-Ref : Ref A: 11E143D284524438B1FC1B32EE259E30 Ref B: CH1AA2020615021 Ref C: 2024-08-16T13:40:38Z

Date : Fri, 16 Aug 2024 13:40:39 GMT

Body:

{

"code": "ResourceTypeNotSupported",

"message": "The resource type 'microsoft.compute/disks' does not support diagnostic settings."

}

DEBUG: ResponseCreated:

DEBUG: BeforeResponseDispatch:

New-AzDiagnosticSetting_CreateExpanded: The resource type 'microsoft.compute/disks' does not support diagnostic settings.

DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response

DEBUG: Finally:

DEBUG: CmdletAfterAPICall:

DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process

DEBUG: CmdletProcessRecordAsyncEnd:

DEBUG: CmdletProcessRecordEnd:

DEBUG: AzureQoSEvent: Module: Az.Monitor:5.2.1; CommandName: New-AzDiagnosticSetting; PSVersion: 7.4.4; IsSuccess: False; Duration: 00:00:01.5568057; SanitizeDuration: 00:00:00; Exception: InternalException;
```

### Environment data

```PowerShell
Name Value

---- -----

PSVersion 7.4.4

PSEdition Core

GitCommitId 7.4.4

OS Microsoft Windows 10.0.22631

Platform Win32NT

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}

PSRemotingProtocolVersion 2.3

SerializationVersion 1.1.0.1

WSManStackVersion 3.0
```

### Module versions

```PowerShell
ModuleType Version PreRelease Name ExportedCommands

---------- ------- ---------- ---- ----------------

Script 3.0.3 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}

Script 5.2.1 Az.Monitor {Add-AzLogProfile, Add-AzMetricAlertRule, Add-AzMetricAlertRuleV2, Add-AzWebtestAlertRule…}

Script 7.3.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
```

### Error output

```PowerShell
Message : [ResourceTypeNotSupported] : The resource type 'microsoft.compute/disks' does not support diagnostic settings.

StackTrace :

Exception : System.Exception

InvocationInfo : {New-AzDiagnosticSetting_CreateExpanded}

Line : New-AzDiagnosticSetting -Name 'test' -ResourceId $mydisk.ResourceId -EventHubName $EventHubCentralName -EventHubAuthorizationRuleId $EventHubCentralPath

Position : At line:1 char:1

+ New-AzDiagnosticSetting -Name 'test' -ResourceId $mydisk.ResourceId - …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HistoryId : 27
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing Get-AzDiagnosticSettingCategory and New-AzDiagnosticSetting, using the diagnosticSettingsCategories and diagnosticSettings API requests shown in the report. Compare how an unsupported Microsoft.Compute/disks resource is handled by each command. Done means unsupported categories are not reported as usable, with the observed disk scenario covered by appropriate validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.