Mise hors service de l'API Microsoft Entra ID Graph
Le service Microsoft Entra ID (anciennement Azure Active Directory ou Azure AD) Graph API est en court de retrait. Cette mise hors service s'inscrit dans le cadre d'un effort plus large visant à rationaliser la plateforme Microsoft Entra ID et à améliorer l'expérience des développeurs Microsoft Entra ID.
Étapes de correction
La mise hors service de l’API Graph affecte tous les clients Azure Stack Hub qui utilisent l’ID Entra comme fournisseur d’identité et vous oblige à exécuter le script inclus dans cet article pour toutes les applications affectées. Si vous avez des applications qui ont besoin d'un accès continu aux API Graph, le script définit un indicateur qui configure ces applications pour une extension qui permet à ces applications spécifiques de continuer à appeler l'API Graph héritée jusqu'en juin 2025.
Le script PowerShell fourni dans cet article définit un indicateur pour chaque application afin de configurer l'extension API Graph pour chaque fournisseur d'identité Entra ID d'Azure Stack Hub.
Pour vous assurer que vos environnements Azure Stack Hub qui utilisent Entra ID comme fournisseur d'identité continuent de fonctionner, vous devez exécuter ce script avant la fin février 2025.
Remarque
Si vous retardez l'ajout de cet indicateur au-delà de février 2025, l'authentification échouera. Vous pouvez ensuite exécuter ce script pour vous assurer que vos fonctions Azure Stack Hub fonctionnent comme prévu.
Exécuter le script
Exécutez le script PowerShell suivant dans votre environnement Entra ID qui est utilisé par Azure Stack Hub comme « répertoire de base » (le principal fournisseur d'identité de votre Azure Stack Hub). Le script interagit avec Azure, vous n'avez donc pas besoin de l'exécuter sur une machine spécifique. Cependant, vous devez disposer au minimum des privilèges d'« administrateur d'application » dans le tenant Entra ID concerné pour exécuter le script.
Veillez à exécuter le script suivant avec les privilèges d'administrateur sur la machine locale :
# Install the graph modules if necessary
#Install-Module Microsoft.Graph.Authentication
#Install-Module Microsoft.Graph.Applications
$ErrorActionPreference='Stop'
Import-Module Microsoft.Graph.Authentication
Import-Module Microsoft.Graph.Applications
# Repeat this flow for each of your target directory tenants
$tenantId = 'MyTenantId'
# Sign-in with admin permissions to read and write all application objects
Connect-MgGraph -TenantId $tenantId -Scopes Application.ReadWrite.All
# Retrieve all applications in the current directory
Write-Host "Looking-up all applications in directory '$tenantId'..."
$applications = Get-MgApplication -All -Property id, displayName, appId, identifierUris, requiredResourceAccess, authenticationBehaviors
Write-Host "Found '$($applications.Count)' total applications in directory '$tenantId'"
# Find all the unique deployment guids, each one representing an Azure Stack deployment in the current directory
$deploymentGuids = $applications.IdentifierUris |
Where-Object { $_ -like 'https://management.*' -or $_ -like 'https://adminmanagement.*' } |
ForEach-Object { "$_".Split('/')[3] } |
Select-Object -Unique
Write-Host "Found '$($deploymentGuids.Count)' total Azure Stack deployments in directory '$tenantId'"
# Find all the Azure Stack application objects for each deployment
$azureStackApplications = @()
foreach ($application in $applications)
{
foreach ($deploymentGuid in $deploymentGuids)
{
if (($application.IdentifierUris -join '') -like "*$deploymentGuid*")
{
$azureStackApplications += $application
}
}
}
# Find which Azure Stack applications require access to Legacy Graph Service
$azureStackLegacyGraphApplications = $azureStackApplications |
Where-Object { $_.RequiredResourceAccess.ResourceAppId -contains '00000002-0000-0000-c000-000000000000' }
# Find which of those applications need to have their authentication behaviors patched to allow access to Legacy Graph
$azureStackLegacyGraphApplicationsToUpdate = $azureStackLegacyGraphApplications |
Where-Object { -not ($ab = $_.AdditionalProperties.authenticationBehaviors) -or -not $ab.ContainsKey(($key='blockAzureADGraphAccess')) -or $ab[$key] }
# Update the applications which require their authentication behaviors patched to allow access to Legacy Graph
Write-Host "Found '$($azureStackLegacyGraphApplicationsToUpdate.Count)' total Azure Stack applications which need permission to continue calling Legacy Microsoft Graph Service"
$count = 0
foreach ($application in $azureStackLegacyGraphApplicationsToUpdate)
{
$count++
Write-Host "$count/$($azureStackLegacyGraphApplicationsToUpdate.Count) - Updating application '$($application.DisplayName)' (appId=$($application.AppId)) (id=$($application.Id))"
Update-MgApplication -ApplicationId $application.Id -BodyParameter @{
authenticationBehaviors = @{ blockAzureADGraphAccess = $false }
}
}
Le script affiche l'exemple de sortie suivant :
Looking-up all applications in directory '<ID>'...
Found '###' total applications in directory '<ID>'
Found '1' total Azure Stack deployments in directory '<app ID>'
Found '16' total Azure Stack applications which need permission to continue calling Legacy Microsoft Graph Service
1/16 - Updating application 'Azure Stack - AKS' (appId=<app ID>) (id=<ID>)
2/16 - Updating application 'Azure Stack - Hubs' (appId=<app ID>) (id=<ID>)
3/16 - Updating application 'Azure Stack - Portal Administration' (appId=<app ID>) (id=<app>)
4/16 - Updating application 'Azure Stack - RBAC Administration' (appId=<app ID>) (id=ID)
5/16 - Updating application 'Azure Stack - Container Registry' (appId=<app ID>) (id=ID)
6/16 - Updating application 'Azure Stack - RBAC' (appId=<app ID>) (id=ID)
7/16 - Updating application 'Azure Stack - Hubs Administration' (appId=<app ID>) (id=ID)
8/16 - Updating application 'Azure Stack - Deployment Provider' (appId=<app ID>) (id=ID)
9/16 - Updating application 'Azure Stack - Deployment' (appId=<app ID>) (id=ID)
10/16 - Updating application 'Azure Stack - KeyVault' (appId=<app ID>) (id=ID)
11/16 - Updating application 'Azure Stack' (appId=<app ID>) (id=ID)
12/16 - Updating application 'Azure Stack - Administration' (appId=<app ID>) (id=ID)
13/16 - Updating application 'Azure Stack - Policy Administration' (appId=<app ID>) (id=ID)
14/16 - Updating application 'Azure Stack - Policy' (appId=<app ID>) (id=ID)
15/16 - Updating application 'Azure Stack - Portal' (appId=<app ID>) (id=ID)
16/16 - Updating application 'Azure Stack - KeyVault Administration ' (appId=<app ID>) (id=ID)
Exécutez le script une deuxième fois pour vérifier que toutes les applications ont été mises à jour. Le script doit renvoyer la sortie suivante si toutes les applications ont été mises à jour avec succès :
Looking-up all applications in directory '<ID>'...
Found '####' total applications in directory '<ID>>'
Found '1' total Azure Stack deployments in directory '<ID>>'
Found '0' total Azure Stack applications which need permission to continue calling Legacy Microsoft Graph Service