Azure Powershell 作业抛出错误 : Operation returned an invalid status code 'Forbidden'

标签 azure azure-devops azure-sql-database azure-powershell

我的脚本中有一个名为

的命令

Set-AzSqlServerActiveDirectoryAdministrator -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>

关于Azure Powershell 作业抛出错误 : Operation returned an invalid status code 'Forbidden' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63954681/

相关文章:

azure - 为 Nginx docker 容器启用 HTTPS

azure - 将文件上传到 Azure BLOB 存储 - Parallel.Foreach 比 Foreach 慢

azure - 在 Bicep 模块中创建时获取 Function App 默认主机 key

javascript - 如何在 VS Team Service 自定义选项卡中允许 IFRAME

azure - 在 Azure SQL 中查询来自不同服务器的表

azure - 使用 DTU 定价模型的副本

大型 BCP 操作后,Azure SQL 数据仓库挂起或不响应简单查询

java - 如何从azure keyvault获取证书链

asp.net - ConnectionStrings 的 ServiceDefinition.csdef 和 Web.config 有什么区别?

cordova - Cordova 构建任务时获取 "TypeError: file argument must be a non-empty string"