azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

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

Open rpstester opened this issue 6 months ago • 2 comments

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

PS > Get-AzDiagnosticSettingCategory -ResourceId $mydisk.ResourceId                                                                             

DEBUG: [CmdletBeginProcessing]: Starting command

DEBUG: CmdletBeginProcessing:

DEBUG: CmdletProcessRecordStart:

DEBUG: CmdletGetPipeline:

DEBUG: CmdletBeforeAPICall:

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

DEBUG: RequestCreated: //subscriptions/<subid>/resourceGroups/<RGNAME>/providers/Microsoft.Compute/disks/<vmname>_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/<subid>/resourceGroups/<RGNAME>/providers/Microsoft.Compute/disks/<vmname>_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettingsCategories?api-version=2021-05-01-preview

 

Headers:

x-ms-unique-id                : 553

x-ms-client-request-id        : <requestid>

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               : <requestid>

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

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

x-ms-correlation-request-id   : <requestid>

x-ms-routing-request-id       : NORTHCENTRALUS:20240816T133645Z: <requestid>

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/<subid>/resourcegroups/<rgname>/providers/microsoft.compute/disks/<vmname>_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/<subid>/resourceGroups/<RGNAME>/providers/Microsoft.Compute/disks/<vmname>_OsDisk_1_12d67929090c4777b27a7b1eac3bfd81/providers/Microsoft.Insights/diagnosticSettings/test?api-version=2021-05-01-preview

DEBUG: RequestCreated: //subscriptions/<subid>/resourceGroups/<RGNAME>/providers/Microsoft.Compute/disks/<vmname>_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/<subid>/resourceGroups/<RGNAME>/providers/Microsoft.Compute/disks/<vmname>_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        : <requestid>

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/<subid>/resourceGroups/<rgname>/providers/Microsoft.EventHub/namespaces/<eventhubname>/authorizationrules/sending",

    "eventHubName": "<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   : <requestid>

x-ms-routing-request-id       : NORTHCENTRALUS:20240816T134039Z: <requestid>

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

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

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

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

rpstester avatar Aug 19 '24 14:08 rpstester