gpt4 book ai didi

azure - 使用 Powershell 将范围添加到 Azure AD 应用程序(公开 API)

转载 作者:行者123 更新时间:2023-12-02 08:13:18 25 4
gpt4 key购买 nike

我想使用 Powershell 将范围添加到 Azure AD 应用/服务主体 (UI=公开 API)。

$app = New-MgApplication -DisplayName $name -SignInAudience "AzureADMyOrg"
Update-MgApplication -ApplicationId $app.id -IdentifierUris @("api://$($app.AppId)")

$oauth_permission_scopes = @{
AdminConsentDescription = "admin desc"
AdminConsentDisplayName = "admin name"
Type = "Admin"
Value = "Read.all"
Id = $([guid]::NewGuid())
}
$sp = New-MgServicePrincipal -AppId $app.AppId -Notes $description -Tags @("HideApp","WindowsAzureActiveDirectoryIntegratedApp") #HideApp=VisibleToUsers
Update-MgServicePrincipal -ServicePrincipalId $sp.Id -Oauth2PermissionScopes $oauth_permission_scopes

但我收到消息:

Update-MgServicePrincipal_UpdateExpanded1: Property 'oauth2PermissionScopes' is read-only and cannot be set.

只能在 UI 中添加吗?!

最佳答案

我尝试在我的环境中重现相同的结果并得到以下结果:

我运行了与您相同的代码来添加范围,并得到了相同的错误,如下所示:

enter image description here

当我在门户中检查相同内容时,应用程序已创建,但范围未添加,如下所示:

enter image description here

要使用 PowerShell 将范围添加到 Azure AD 应用程序(公开 API),您需要按照 Cpt.Whale 的建议修改脚本> 像这样:

$api = @{
oauth2PermissionScopes = @(
@{
AdminConsentDescription = "admin desc"
AdminConsentDisplayName = "admin name"
Type = "Admin"
Value = "Read.all"
Id = $([guid]::NewGuid())
}
)
}

Update-MgApplication -ApplicationId $app.id -Api $api

回应:

enter image description here

当我在门户中检查相同内容时,范围已成功添加到 Azure AD 应用程序的公开 API 选项卡中,如下所示:

enter image description here

关于azure - 使用 Powershell 将范围添加到 Azure AD 应用程序(公开 API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75112560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com