使用azure devops中的azure powershell内联任务将azure sqlsever中的azuresqlserveractivedirecoty管理员设置为azure sqls中的ADgroup

问题描述 投票:0回答:1

我正在尝试在azure devops中执行以下命令,以将AD组设置为setsqlserveradmin。

Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName "xyz" -ServerName "xyzsqlserver" -DisplayName "ADgroup" -ObjectId "27f75d8c-xxxx-xxxx-xxxx-xxxxxxxxxx" 

下面是错误日志

2020-05-07T15:55:05.2211587Z ##[command]Disconnect-AzAccount -Scope Process 
    ErrorAction Stop 2020-05-07T15:55:05.6167436Z ##[command]Clear-AzContext -Scope Process - ErrorAction 
    Stop 2020-05-07T15:55:05.9479005Z ##[error]Cannot find the Azure Active Directory object 'Adgroup'. 
    Please make sure that the user or group you are authorizing is registered in the current 
    subscription's Azure Active directory. To get a list of Azure Active Directory groups use Get- 
    AzADGroup, or to get a list of Azure Active Directory users use Get-AzADUser. 2020-05- 
    07T15:55:06.0117846Z ##[section]Finishing: Azure PowerShell script: InlineScript

注意-我检查了广告组并且相应的objectid是正确的。

PowerShell任务4.0和版本3.1.0

enter image description here

azure-devops azure-active-directory azure-sql-database azure-powershell paas
1个回答
0
投票

我可以重现您的问题,首先,请确保该组与您的服务连接在同一租户中。

enter image description here

然后导航到Azure门户-> Azure Active Directory-> App registrations->查找与您的服务连接有关的AD App注册,请按照以下步骤添加Directory.Read.All应用程序许可Azure Active Directory Graph](不是Microsoft Graph),请不要忘记最后单击Grant admin consent for xxx按钮。

enter image description here

enter image description here

enter image description here

添加许可后,会有一些延迟(30m-1h),然后测试该命令,它可以工作。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.