Dela via


Microsoft Entra ID Graph API-avveckling

Microsoft Entra ID (tidigare Azure Active Directory eller Azure AD) Graph API-tjänsten dras tillbaka. Den här tillbakadragningen är en del av ett bredare arbete för att effektivisera Microsoft Entra ID-plattformen och förbättra Microsoft Entra ID-utvecklarupplevelsen.

Mitigeringssteg

Graph API-tillbakadragningen påverkar alla Azure Stack Hub-kunder som använder Entra-ID som identitetsprovider och kräver att du kör skriptet som ingår i den här artikeln för alla program som påverkas. Om du har program som behöver fortsatt åtkomst till Graph-API:erna anger skriptet en flagga som konfigurerar dessa program för ett tillägg som gör att dessa specifika program kan fortsätta att anropa det äldre Graph API:et.

PowerShell-skriptet i den här artikeln anger en flagga för varje program för att konfigurera Graph API-tillägget för varje Entra ID-identitetsprovider för Azure Stack Hub.

För att säkerställa att dina Azure Stack Hub-miljöer som använder Entra-ID som identitetsprovider fortsätter att fungera bör du köra det här skriptet i slutet av februari 2025.

Notera

Om du fördröjer att lägga till den här flaggan efter februari 2025 misslyckas autentiseringen. Du kan sedan köra det här skriptet för att se till att dina Azure Stack Hub-funktioner fungerar efter behov.

Kör skriptet

Kör följande PowerShell-skript i din Entra ID-miljö som används av Azure Stack Hub som den hemkatalogen (huvudidentitetsprovidern för din Azure Stack Hub) samt Entra ID-miljön där du registrerade ditt Azure Stack Hub-system. Det här kan vara en annan katalog än din hemkatalog. Skriptet interagerar med Azure, så du behöver inte köra det på en specifik dator. Du behöver dock minst programadministratör behörigheter i respektive Entra ID-klient för att köra skriptet.

Se till att köra följande skript med administratörsbehörighet på den lokala datorn:

# 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
 
# Target your Azure Cloud instance name; use Get-MgEnvironment to list available clouds and Add-MgEnvironment to add new ones as needed for custom private/secure clouds
$envName = 'Global'

# 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 -Environment $envName -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 or registration in the current directory
$deploymentGuids = $applications.IdentifierUris |
    Where-Object { $_ -like 'https://management.*' -or $_ -like 'https://adminmanagement.*' -or $_ -like 'https://azurebridge*' } |
    ForEach-Object { "$_".Split('/')[3] } |
    Select-Object -Unique
Write-Host "Found '$($deploymentGuids.Count)' total Azure Stack deployments or registrations in directory '$tenantId'"
 
# Find all the Azure Stack application objects for each deployment or registration
$azureStackApplications = @()
foreach ($application in $applications)
{
    foreach ($deploymentGuid in $deploymentGuids)
    {
        if (($application.IdentifierUris -join '') -like "*$deploymentGuid*")
        {
            $azureStackApplications += $application
            break
        }
    }
}
 
# Find which Azure Stack applications require access to the legacy Graph Service
$azureStackLegacyGraphApplications = $azureStackApplications |
    Where-Object {
        ($_.RequiredResourceAccess.ResourceAppId -contains '00000002-0000-0000-c000-000000000000') -or
        ($_.IdentifierUris | Where-Object { $_ -like 'https://azurebridge*' }) }
 
# Find which of those applications need to have their authentication behaviors patched to allow access to legacy Graph
$azureStackLegacyGraphApplicationsToUpdate = $azureStackLegacyGraphApplications | Where-Object {
    $oldLocationSet = $false -eq $_.AdditionalProperties.authenticationBehaviors.blockAzureADGraphAccess
    $newLocationNotSet = $false -eq $_.AuthenticationBehaviors.BlockAzureAdGraphAccess
    return (-not $oldLocationSet -and -not $newLocationNotSet)
}
 
# Update the applications that 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 }
    }
}

Skriptet visar följande exempelutdata:

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) 

Kör skriptet en andra gång för att verifiera att alla program har uppdaterats. Skriptet ska returnera följande utdata om alla program har uppdaterats:

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 

Följande utdata från Get-MgEnvironment kommandot visar de standardmolninstanser som ingår när du installerar Graph-modulen:

C:\> Get-MgEnvironment

Name     AzureADEndpoint                   GraphEndpoint                           Type    
----     ---------------                   -------------                           ----    
USGovDoD https://login.microsoftonline.us  https://dod-graph.microsoft.us          Built-in
Germany  https://login.microsoftonline.de  https://graph.microsoft.de              Built-in
USGov    https://login.microsoftonline.us  https://graph.microsoft.us              Built-in
China    https://login.chinacloudapi.cn    https://microsoftgraph.chinacloudapi.cn Built-in
Global   https://login.microsoftonline.com https://graph.microsoft.com             Built-in

Nästa steg

Viktig information om Azure Stack Hub