Azure / Azure/azure-powershell

"Get-AzManagedServicesDefinition" returns wrong error message, "Conflict"

Open
#12,087 6 comments 0 reactions 1 assignee Assigned to @skayani View on GitHub
customer-reported ManagedServices needs-team-attention question Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

## Description
I ran ```Get-AzManagedServicesDefinition``` and got the error ```Get-AzManagedServicesDefinition : Operation returned an invalid status code 'Conflict'```. But when enabling debug I can see that the error is that Managed Service service principal does not have read permissions on the subscription in question.

Please give us more helpfull error messages by default, without having to enable debug.

## Steps to reproduce

```powershell
Get-AzManagedServicesDefinition
```

## Environment data

```
Name Value
---- -----
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

## Module versions

```powershell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.8.1 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 1.3.6 Az.Automation {Export-AzAutomationDscConfiguration, Export-AzAutomationDscNodeReportContent, Export-AzAutomationRunbook, Get-AzAutomation...
Script 1.0.2 Az.ManagedServices {Get-AzManagedServicesAssignment, Get-AzManagedServicesDefinition, New-AzManagedServicesAssignment, New-AzManagedServicesDe...
Script 2.1.0 Az.Resources {Add-AzADGroupMember, Export-AzResourceGroup, Get-AzADAppCredential, Get-AzADApplication...}
```

## Debug output

```
Body:
{
"error": {
"code": "MissingSubscriptionRegistration",
"message": "The managed services resource provider not allowed to access the subscription '. The subscription must be registered to use namespac
e 'Microsoft.ManagedServices'. Please see https://aka.ms/rp-not-register-error for details on how to register subscriptions.",
"details": [
{
"code": "AuthorizationFailed",
"message": "The client '' with object id '' does not have authorization to perform action 'Microsoft.Reso
urces/subscriptions/read' over scope '/subscriptions/' or the scope is invalid. If access was recently granted, please refresh your credentials."
}
]
}
}
```

## Error output

```
Get-AzManagedServicesDefinition : Operation returned an invalid status code 'Conflict'
At line:1 char:1
+ Get-AzManagedServicesDefinition
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzManagedServicesDefinition], ErrorResponseException
+ FullyQualifiedErrorId : Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Commands.GetAzureRmManagedServicesDefinition
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.