Skip to content

Commit

Permalink
Merge pull request #375 from maester365/fb_FixAzureTestConnection
Browse files Browse the repository at this point in the history
Update Azure AD diagnostic settings API calls to use GET method
  • Loading branch information
f-bader authored Jul 21, 2024
2 parents c02b7c1 + 3a515c8 commit 9b6c8c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function Test-MtCisaDiagnosticSettings {
return $null
}

$logs = Invoke-AzRestMethod -Path "/providers/microsoft.aadiam/diagnosticSettingsCategories?api-version=2017-04-01-preview"
$logs = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.aadiam/diagnosticSettingsCategories?api-version=2017-04-01-preview"
$logs = ($logs.Content|ConvertFrom-Json).value
$logs = ($logs | Where-Object { `
$_.properties.categoryType -eq "Logs"
}).name

$configs = @()

$settings = Invoke-AzRestMethod -Path "/providers/microsoft.aadiam/diagnosticSettings?api-version=2017-04-01-preview"
$settings = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.aadiam/diagnosticSettings?api-version=2017-04-01-preview"
$settings = ($settings.Content|ConvertFrom-Json).value

$settings | ForEach-Object { `
Expand Down
3 changes: 3 additions & 0 deletions powershell/public/core/Test-MtConnection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function Test-MtConnection {
$isConnected = $false
try {
$isConnected = $null -ne (Get-AzContext -ErrorAction SilentlyContinue)
# Validate that the credentials are still valid
Invoke-AzRestMethod -Method GET -Path "subscriptions" -ErrorAction Stop | Out-Null
} catch {
$isConnected = $false
Write-Debug "Azure: $false"
}
Write-Verbose "Azure: $isConnected"
Expand Down

0 comments on commit 9b6c8c5

Please sign in to comment.