Open JoranSlingerland opened 11 months ago
Is there a solution for this? I am facing the same issue for az.security version 1.5.1 with runtime ps 5.1 . The command Get-AzSecurityContact gives a 'unable to deserialize the response' error
@dutt0 , We eventually implemented the following workaround:
# Temporary solution due to a bug in az.security 1.5.0 with the command Get-AzSecurityContact. See: https://github.com/Azure/azure-powershell/issues/23499
$azContext = Get-AzContext
$token = Get-AzAccessToken -TenantId $azContext.Subscription.TenantId
$authHeader = @{
'Content-Type' = 'application/json'
'Authorization' = 'Bearer ' + $token.Token
}
$restUri = "https://management.azure.com/subscriptions/$($azContext.Subscription.Id)/providers/Microsoft.Security/securityContacts?api-version=2020-01-01-preview"
$response = Invoke-RestMethod -Uri $restUri -Method Get -Headers $authHeader
$response.properties.phone
# (Get-AzSecurityContact).Phone
@JoranSlingerland It worked! Thanks so much!
Still a problem with Az.Account v2.16.0 and Az.Security v1.6.0.
An even easier workaround to what @JoranSlingerland posted is using the Az built in Invoke-AzRestMethod
. :)
Invoke-AzRestMethod -Method 'Get' -Path (
'/subscriptions/{0}/providers/Microsoft.Security/securityContacts?api-version=2020-01-01-preview' -f $Subscription.'Id'
)
The edit history of this issue was deleted.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @keren-shani.
Description
In the az.security 1.5.0 in combination with ps 7 the command Get-AzSecurityContact gives a unable to deserialize the response error
Issue script & Debug output
Environment data
Module versions
Error output
No response