![](/img/trans.png)
[英]azure App registration using powershell does not create a service principal
[英]how I can make an service principal as an App Registration Owner with azure portal or PowerShell?
所以背景如下:
對於安裝和部署過程,我們需要修改一個客戶創建的應用注冊。 但我們得到的不是正確的Application.ReadWriteAll
但我們可以得到Application.ReadWrite.OwnedBy
。
我知道如果創建如下所示的 Graph Api 調用(由 Postman 執行),它會起作用,因為 Creator 自動成為所有者。 .
HTTP-Post Request:
https://graph.microsoft.com/v1.0/applications
with body:
{
"displayName": "AppRegName"
}
但是我需要使用 azure 門戶或 powershell 之類的標准工具來解決問題,但我發現無法將服務主體作為所有者分配或刪除給應用程序注冊。
有沒有辦法用powershell做到這一點?
與服務主體的身份驗證我不知道該怎么做?
我想在我可以創建一個應用程序注冊之后
$appRegistration = New-AzADApplication -DisplayName "AppRegCreatebyPS"
但我在使用 powershell 方面非常缺乏經驗。 那么如何告訴 powershell 使用服務主體身份驗證來創建應用注冊呢?
一個簡短的額外問題:
我可以稍后刪除服務主體的所有者角色嗎?我該怎么做?
感謝所有讀者,我希望有人能給我一個提示。
您可以從 PowerShell AzureAD 模塊創建應用注冊、應用注冊的服務主體、添加應用程序所有者和刪除應用程序所有者。
在 PowerShell 中安裝 Azure AD 模塊的命令:
Install-Module AzureAD
您可以使用以下命令:
#Connect to Azure AD
Connect-AzureAD
#Create Azure AD app Registration
$appRegistration = New-AzureADApplication -DisplayName "AppRegCreatebyPS"
# Create A service Principal for the above app Registration
New-AzureADServicePrincipal -AccountEnabled $true -AppId $appRegistration.AppId -AppRoleAssignmentRequired $true -DisplayName $appRegistration.DisplayName
# get objectid for the service principal
$serviceprincipal= Get-AzureADServicePrincipal -Filter "DisplayName eq 'AppRegCreatebyPS'"
#Get the old app registration for whom you want set owner
$oldappregistration = Get-AzureADApplication -Filter "DisplayName eq 'Postman'"
#add service principal to the application owner of old app registration
Add-AzureADApplicationOwner -ObjectId $oldappregistration.ObjectId -RefObjectId $serviceprincipal.ObjectId
# verify the owner for the old app registration
Get-AzureADApplicationOwner -ObjectId $oldappregistration.ObjectId
#remove the owner for the old app registration
Remove-AzureADApplicationOwner -ObjectId $oldappregistration.ObjectId -OwnerId $serviceprincipal.ObjectId
參考:
這可以從 bash 或 windows 子系統 linux 中完成,如下所示。
登錄到您的 Azure 帳戶
登錄
執行以下命令
az ad app owner add --id AAAA --owner-object-id AAAA
--id(應用程序 id) , --owner-object-id (所有者對象 id)
參考: https<\/a> :\/\/docs.microsoft.com\/en-us\/cli\/azure\/ad\/app\/owner?view=azure-cli-latest
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.