使用 "run as" 帐户从 Azure Automation 与团队联系

Connect with teams from an Azure Automation with "run as" account

我想从 Azure 自动化分配 Teams 策略。为此,我使用当前版本中的 PowerShell 模块“MicrosoftTeams”。

当我使用用户凭据登录 Teams 时,如下所示,分配有效。

$Cred = Get-AutomationPSCredential -Name 'Teams-Admin'
Connect-MicrosoftTeams -TenantId $tenantId -Credential $Cred

# Grant policys
Grant-CsUserPolicyPackage -Identity $mailAddress -PackageName Test

不过我想用运行-As账号登录,如下图。当我这样做时,出现错误。

$connection = Get-AutomationConnection –Name AzureRunAsConnection
Connect-MicrosoftTeams -TenantId $connection.TenantID `
    -ApplicationId $connection.ApplicationID `
    -CertificateThumbprint $connection.CertificateThumbprint

# Grant policys
Grant-CsUserPolicyPackage -Identity $mailAddress -PackageName Test

错误如下:

Grant-CsUserPolicyPackage : Powershell administered domain is unexpectedly null/empty

“运行-As”帐户的应用注册表具有 Teams 管理员和 Skype for Business 管理员角色。另外,我在API权限和“user_impersonation”权限中将“AppCatalog.ReadWrite.All”、“Group.ReadWrite.All”、“User.Read.All”权限委托给Microsoft Graph至 Skype 和 Teams 租户管理员 API.

目前不支持服务主体名称。我们有这方面的积压项目,但没有要分享的预计到达时间。