Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Powershell作业引发错误:操作返回无效的状态代码';禁止';_Azure_Azure Devops_Azure Sql Database_Azure Powershell - Fatal编程技术网

Azure Powershell作业引发错误:操作返回无效的状态代码';禁止';

Azure Powershell作业引发错误:操作返回无效的状态代码';禁止';,azure,azure-devops,azure-sql-database,azure-powershell,Azure,Azure Devops,Azure Sql Database,Azure Powershell,我的脚本中有一个名为 设置AZSSQLServerActiveDirectoryAdministrator-ResourceGroupName$ResourceGroupName-ServerName$SqlServerName-DisplayName$SqlServerAdmin 我为这些参数使用了适当的值。问题是,当我从Powershell ISE运行此命令时,它运行得非常完美,但当我在Azure DevOps中的Azure Powershell任务中执行相同操作时,它返回一个错误,表示:

我的脚本中有一个名为

设置AZSSQLServerActiveDirectoryAdministrator-ResourceGroupName$ResourceGroupName-ServerName$SqlServerName-DisplayName$SqlServerAdmin

我为这些参数使用了适当的值。问题是,当我从Powershell ISE运行此命令时,它运行得非常完美,但当我在Azure DevOps中的Azure Powershell任务中执行相同操作时,它返回一个错误,表示:

2020-09-18T11:02:54.0670872Z ##[error]Operation returned an invalid status code 'Forbidden'

我想不出我遗漏了什么。

我找到了同样的解决方案。我们需要使用以下命令将服务主体添加到目录读取器:

Add-AzureADDirectoryRoleMember -ObjectId (Get-AzureADDirectoryRole | where-object {$_.DisplayName -eq "Directory Readers"}).Objectid -RefObjectId <object-id>

添加AzureAddirectoryMember-ObjectId(获取AzureADDirectoryRole | where对象{$\uuu.DisplayName-eq“目录读取器”).ObjectId-ReObjectId

运行管道的服务主体的权限问题?现有的权限/角色是什么?当我进入服务主体的角色和管理员部分时,其中列出了2个:应用程序管理员;云应用程序管理员您需要授予应用程序管理SQL DB的权限。在SQL SErver资源的IAM刀片中,我为所有者提供了订阅服务主体的访问权限。但我还是犯了同样的错误