Azure服务主体权限不足,无法管理其他服务主体

Azure服务主体权限不足,无法管理其他服务主体,azure,powershell,azure-active-directory,azure-powershell,Azure,Powershell,Azure Active Directory,Azure Powershell,我可以使用Azure或使用azcli从门户控制台创建服务主体 az ad sp create-for-rbac --name "myspuser" --password "adfhrrreeuwrgwejdfgds" 然后,我在订阅级别分配所有者角色,并登录到powershell控制台 Login-AzureRmAccount -Credential (New-Object System.Management.Automation.PSCredential ('a92b2ea2-aaaa-00

我可以使用Azure或使用
az
cli从门户控制台创建服务主体

az ad sp create-for-rbac --name "myspuser" --password "adfhrrreeuwrgwejdfgds"
然后,我在订阅级别分配所有者角色,并登录到powershell控制台

Login-AzureRmAccount -Credential (New-Object System.Management.Automation.PSCredential ('a92b2ea2-aaaa-0000-0a0a-1238ec953226', $(ConvertTo-SecureString 'abcewior23h23ius' -AsPlainText -Force))) -ServicePrincipal -TenantId 0cedca99-00f4-40d1-aa41-80d67ece2de8;
在这里,除了检查其他用户之外,我几乎可以执行任何类似于部署机器的操作

当我执行

Get-AzureRmADServicePrincipal
我得到的只是
get AzureRmADServicePrincipal:没有足够的权限来完成操作。
这适用于我的标准用户登录

我的目标是创建一个自动化系统,用户可以通过ARM模板在MSDN订阅中使用jenkins部署完整的环境。由于powershell不支持某些登录,我想让我的用户为此使用服务主体。我的自动化需要创建一个SP,该SP将使用需要读取资源组机器属性的jenkins从linux机器上使用

我错过了什么?如何分配服务主体用户权限以管理其他服务主体帐户?

似乎需要使用将目录角色分配给服务主体

您可以选择所需的特定目录角色,请参阅

注意:您需要首先

在这种情况下,您可以尝试将
应用程序管理员
角色分配给您的服务主体。(如有必要,您可以分配
公司管理员
角色。)

样本:

# Fetch role instance
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}

# If role instance does not exist, instantiate it based on the role template
if ($role -eq $null) {
    # Instantiate an instance of the role template
    $roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object {$_.displayName -eq 'Application Administrator'}
    Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId

    # Fetch role
    $role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}
}

# Add the SP to role
Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId  -RefObjectId <your SP ObjectID>
#获取角色实例
$role=Get-AzureADDirectoryRole | Where对象{$\.displayName-eq'Application Administrator'}
#如果角色实例不存在,请基于角色模板对其进行实例化
如果($role-eq$null){
#实例化角色模板的实例
$roleTemplate=Get-AzureAddirectoryLoteTemplate |其中的对象{$\u0.displayName-eq'Application Administrator'}
启用AzureADDirectoryRole-RoleTemplateId$roleTemplate.ObjectId
#获取角色
$role=Get-AzureADDirectoryRole | Where对象{$\.displayName-eq'Application Administrator'}
}
#将SP添加到角色
添加AzureAddirectoryLember-ObjectId$role.ObjectId-ReObjectId
这里有一个类似的问题供您参考,请参见此。

您似乎需要使用将目录角色分配给您的服务主体

您可以选择所需的特定目录角色,请参阅

注意:您需要首先

在这种情况下,您可以尝试将
应用程序管理员
角色分配给您的服务主体。(如有必要,您可以分配
公司管理员
角色。)

样本:

# Fetch role instance
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}

# If role instance does not exist, instantiate it based on the role template
if ($role -eq $null) {
    # Instantiate an instance of the role template
    $roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object {$_.displayName -eq 'Application Administrator'}
    Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId

    # Fetch role
    $role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}
}

# Add the SP to role
Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId  -RefObjectId <your SP ObjectID>
#获取角色实例
$role=Get-AzureADDirectoryRole | Where对象{$\.displayName-eq'Application Administrator'}
#如果角色实例不存在,请基于角色模板对其进行实例化
如果($role-eq$null){
#实例化角色模板的实例
$roleTemplate=Get-AzureAddirectoryLoteTemplate |其中的对象{$\u0.displayName-eq'Application Administrator'}
启用AzureADDirectoryRole-RoleTemplateId$roleTemplate.ObjectId
#获取角色
$role=Get-AzureADDirectoryRole | Where对象{$\.displayName-eq'Application Administrator'}
}
#将SP添加到角色
添加AzureAddirectoryLember-ObjectId$role.ObjectId-ReObjectId

这里有一个类似的问题供您参考,请参见此。

所有者角色不适用于Azure AD,而目录角色仅适用于用户。 服务原则=应用程序而不是用户。 虽然用户可以链接到服务主体,但我个人还没有看到它的实际用途

要使用服务主体管理服务主体,您需要分配API权限。 我无法告诉您如何使用Powershell执行此操作,因为我还没有找到用于此操作的命令,真是太遗憾了。提示microsoft azure。 进入门户,从AAD打开应用程序并转到API权限。您将能够为旧版Azure AD和MS Graph分配权限

根据我的经验,旧的AAD权限在更多的情况下工作,并提供了更多的粒度,但我确实将其作为一个问题进行了报告,并且可能会改变MS Graph权限是前进的方向

我知道这是一个古老的话题,但在我自己寻找其他问题时,它突然出现,我仍然想回答

编辑:允许服务主体API权限管理应用程序您将能够让应用程序管理其他应用程序。
但是,您真的确定要让普通用户能够管理这些应用程序吗?它可能会产生深远的安全影响,具体取决于您授予此服务主体的权限。

所有者角色不适用于Azure AD,而目录角色仅适用于用户。 服务原则=应用程序而不是用户。 虽然用户可以链接到服务主体,但我个人还没有看到它的实际用途

要使用服务主体管理服务主体,您需要分配API权限。 我无法告诉您如何使用Powershell执行此操作,因为我还没有找到用于此操作的命令,真是太遗憾了。提示microsoft azure。 进入门户,从AAD打开应用程序并转到API权限。您将能够为旧版Azure AD和MS Graph分配权限

根据我的经验,旧的AAD权限在更多的情况下工作,并提供了更多的粒度,但我确实将其作为一个问题进行了报告,并且可能会改变MS Graph权限是前进的方向

我知道这是一个古老的话题,但在我自己寻找其他问题时,它突然出现,我仍然想回答

编辑:允许服务主体API权限管理应用程序您将能够让应用程序管理其他应用程序。 但是,您真的确定要让普通用户能够管理这些应用程序吗?它可能会有深远的影响