13,732 questions
It turns out we need to get Applications
, not ServicePrincipals
.
Private Async Function ShowExpiringSecrets() As Task
Dim oGraphClient As GraphServiceClient
Dim oCredential As DefaultAzureCredential
Dim oResponse As ApplicationCollectionResponse
Dim oSecret As PasswordCredential
Dim oApps As List(Of Application)
Dim oApp As Application
oCredential = New DefaultAzureCredential
oGraphClient = New GraphServiceClient(oCredential)
oResponse = Await oGraphClient.Applications.GetAsync
oApps = oResponse.Value.OrderBy(Function(Application) Application.DisplayName).ToList
For Each oApp In oApps
For Each oSecret In oApp.PasswordCredentials
Console.WriteLine($"{oApp.DisplayName} - {oSecret.EndDateTime}")
Next
Next
End Function
This works. YMMV.