Azure / Azure/azure-powershell
Set-AzSqlServerActiveDirectoryAdministrator fails when using SPN
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
## Description
Set-AzSqlServerActiveDirectoryAdministrator calls endpoint graph.windows.net even **both** group name and object Id are supplied. Calling the API is not necessary when both arguments are supplied. Similar issue: https://github.com/Azure/azure-powershell/issues/13573
API is called multiple times but this call makes Cmdlet to fail `https://graph.windows.net/***/users/***d?api-version=1.6`
response:
```
Body:
{
"odata.error": {
"code": "Authorization_RequestDenied",
"message": {
"lang": "en",
"value": "Insufficient privileges to complete the operation."
},
"requestId": "95277ba5-xxxx-xxxx-xxxx-7c456ffa071c",
"date": "2021-10-26T16:18:44"
}
}
```
Error message:
```
Set-AzSqlServerActiveDirectoryAdministrator: /home/vsts/work/1/artifactTemplate/AzureSQL/post-deploy.ps1:11
Line |
11 | Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName $rg -S …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find the Azure Active Directory object
| 'tekdata-test-sql-admin'. Please make sure that the user or
| group or application 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 or to
| get a list of Azure Active Directory applications use
| Get-AzADApplication.
```
## Steps to reproduce
run following with SPN
```powershell
Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName xxx-azuresql-dev-rg -ServerName xxx-dev-sqlserver -DisplayName xxx-dev-sql-admin
```
## Environment data
```
Name Value
---- -----
PSVersion 7.1.5
PSEdition Core
GitCommitId 7.1.5
OS Linux 5.8.0-1042-azure #45~20.04.1-Ubuntu SMP W…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
## Module versions
```powershell
6.4.0
```
## Debug output
```
```
## Error output
```
```
Contributor guide
Assessment
This issue has not been assessed yet.