Get-AzDiagnosticSetting is not able to retrieve existing diagnostics settings of a key vault .
I have 5 key vaults, all diagnostic logging configures to log audit and metrics to a log analytics workspace.
Cannot retrieve any diagnostics settings using Get-AzDiagnosticSetting and ResourceId
The expected outcome is to be able to retrieve the existing settings .
Issue script & Debug output
# Create a key vault ; assume name is myloggingkeyvault001
# set up diagnostic settings ; all settings are logging into a log analytics workspace
PS /home/daka> $vaultName = "myloggingkeyvault001"
PS /home/daka> $vault = Get-AzKeyVault -Name $vaultName
# private debug info removed
PS /home/daka> $diag = Get-AzDiagnosticSetting -ResourceId $vault.ResourceId
DEBUG: 9:49:19 PM - GetAzureRmDiagnosticSettingCommand begin processing with ParameterSet 'ResourceIdParameterSet'.
DEBUG: 9:49:19 PM - using account id 'MSI@50342'...
WARNING: 9:49:19 PM - *** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 9:49:19 PM - *** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.
DEBUG: [Common.Authentication]: Authenticating using Account: 'MSI@50342', environment: 'AzureCloud', tenant: 'redacted'
DEBUG: 9:49:19 PM - [ManagedServiceIdentityAuthenticator] Calling ManagedIdentityCredential.GetTokenAsync - TenantId:'redacted', Scopes:'https://management.core.windows.net/', UserId:''
DEBUG: ManagedIdentityCredential.GetToken invoked. Scopes: [ https://management.core.windows.net/ ] ParentRequestId:
DEBUG: Request [19340e3f-0421-476a-bbeb-0758cc8ff9f4] POST http://localhost:50342/oauth2/token
Metadata:REDACTED
x-ms-client-request-id:19340e3f-0421-476a-bbeb-0758cc8ff9f4
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.5.0,(.NET 6.0.3; Linux 5.4.0-1077-azure #80~18.04.1-Ubuntu SMP Wed Apr 13 02:07:09 UTC 2022)
Content-Type:application/x-www-form-urlencoded
client assembly: Azure.Identity
DEBUG: Response [19340e3f-0421-476a-bbeb-0758cc8ff9f4] 200 OK (00.0s)
X-Powered-By:REDACTED
ETag:W/"8be-vLE3eLfvp1XZFKLbDNvoyoV4G7E"
Date:Tue, 26 Apr 2022 21:49:19 GMT
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Content-Length:2238
DEBUG: ManagedIdentityCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net/ ] ParentRequestId: ExpiresOn: 2022-04-26T22:26:38.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'redacted', UserId: 'MSI@50342'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com//subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.KeyVault/vaults/redactred/providers/Microsoft.Insights/diagnosticSettings?api-version=2017-05-01-preview
Headers:
x-ms-client-request-id : ce42e225-efcf-4354-9fdf-8b3a0c3c8209
Accept-Language : en-US
Body:
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 : ae9ea9e7-f2b9-4d30-905d-d63720cfe931
Server : Microsoft-IIS/10.0
x-ms-ratelimit-remaining-subscription-reads: 11997
x-ms-correlation-request-id : 877e7bb5-95d8-4ac4-a92f-065e7f9ff2db
x-ms-routing-request-id : WESTUS:20220426T214921Z:877e7bb5-95d8-4ac4-a92f-065e7f9ff2db
X-Content-Type-Options : nosniff
Date : Tue, 26 Apr 2022 21:49:20 GMT
Body:
{
"value": []
}
DEBUG: AzureQoSEvent: Module: Az.Monitor:3.0.1; CommandName: Get-AzDiagnosticSetting; PSVersion: 7.2.2; IsSuccess: True; Duration: 00:00:01.6113254
DEBUG: Finish sending metric.
DEBUG: 9:49:21 PM - GetAzureRmDiagnosticSettingCommand end processing.
PS /home/daka> $diag
PS /home/daka>
Environment data
Name Value
---- -----
PSVersion 7.2.2
PSEdition Core
GitCommitId 7.2.2
OS Linux 5.4.0-1077-azure #80~18.04.1-Ubuntu SMP Wed Apr 13 02:07:09 UTC 2022
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS /home/daka> Resolve-AzError
DEBUG: 9:54:49 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 9:54:49 PM - using account id 'MSI@50342'...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
DEBUG: AzureQoSEvent: Module: Az.Accounts:2.7.6; CommandName: Resolve-AzError; PSVersion: 7.2.2; IsSuccess: True; Duration: 00:00:00.0040134
DEBUG: Finish sending metric.
DEBUG: 9:54:50 PM - ResolveError end processing.
Description
Get-AzDiagnosticSetting is not able to retrieve existing diagnostics settings of a key vault .
I have 5 key vaults, all diagnostic logging configures to log audit and metrics to a log analytics workspace. Cannot retrieve any diagnostics settings using Get-AzDiagnosticSetting and ResourceId
The expected outcome is to be able to retrieve the existing settings .
Issue script & Debug output
Environment data
Module versions
Error output