-
Notifications
You must be signed in to change notification settings - Fork 0
Managed identities
Jiri Formacek edited this page Dec 30, 2024
·
1 revision
Module fully supports authentication with managed identities.
This sample assumes that code runs in environment supporting Azure Managed identity and uses it to get tokens.
#create factory that uses managed identity, without scopes
#factory is stored is session varioable so no need to store it explictly if it is single factory used
New-AadAuthenticationfactory -UseManagedIdentity
#get tokens from factory stored in session variable
$configToken = Get-AadToken -Scopes 'https://azconfig.io'
$vaultToken = Get-AadToken -Scopes 'https://vault.azure.net'
This sample assumes that code runs in environment supporting user-assigned Azure Managed identity and uses it to get tokens, and shows access token properties.
Get-AadToken
uses implicit authentication factory cached by most recent call of New-AadAuthenticationFactory
.
#create a factory with default scopes and client id of user assigned Managed identity
New-AadAuthenticationfactory `
-DefaultScopes 'https://azconfig.io/.default' `
-UseManagedIdentity `
-ClientId '3a174b1e-7b2a-4f21-a326-90365ff741cf'
#retrieve a token from factory and examine its content
Get-AadToken | Test-AadToken -PayloadOnly