Partner-Center-PowerShell: Get-PartnerAzureBillingAccount fails 'Unauthorized'
Steps to reproduce
When executing the cmdlet is fails. I am using refresh token. Token is scoped to ‘https://api.partnercenter.microsoft.com/user_impersonation’. The user that is impersonated has Global Admin and Admin agent access. Debug does not return different result.
Get-PartnerAzureBillingAccount
Get-PartnerAzureBillingAccount : Operation returned an invalid status code 'Unauthorized'
At line:1 char:1
+ Get-PartnerAzureBillingAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PartnerAzureBillingAccount], ErrorResponseException
+ FullyQualifiedErrorId : Microsoft.Azure.Management.Billing.Models.ErrorResponseException,Microsoft.Store.PartnerCenter.PowerShell.Commands.GetPartnerAzureBillingAccount
What steps can reproduce the defect? Please share the setup, commandline for vstest.console, sample project, target framework etc.
Expected behavior
Share the expected output
Actual behavior
What is the behavior observed?
Diagnostic logs
Please share test platform diagnostics logs.
The logs may contain test assembly paths, kindly review and mask those before sharing.
Environment
Please share additional details about your environment. Version
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 20 (8 by maintainers)
The documentation has been updated and with the release of version 3.0 a more meaningful error will be thrown in this circumstance. Also, when you invoke a command and specify the
Debugparameter you will now see details regarding the actual HTTP request which will help identify the root cause of issues more rapidly.@isaiahwilliams If this is the better solution for authenticating may be it is better to documented it somewhere. I will switch to this way of authenticating so we can put this best practice at place. To clarify connecting to Azure via Az stays the same as there is no refresh token option there correct?
@cblackuk thank you for confirming. If you elect to use the
RefreshTokenparameter as a workaround then the only thing that should change is that you do not need to call theNew-PartnerAccessTokencommand because theConnect-PartnerCentercommand will take care of that step on your behalf.That approach is actually the best solution in my opinion, but I will see if there is a way we can address the issue when using the
AccessTokenparameter.Thank you for sharing this information, and now I see the problem. The reason I was not able to reproduce the issue in my testing was that I was using the following to connect
Through this approach I do not have to exchange the refresh token for an access token, the module handles that for me. Since you are connecting using an access token that raw value is being use to interact with the Azure Resource Manager API which results in the following error from the API to be returned
While I work through the best way to address this limitation, I would recommend you use the
RefreshTokenparameter instead of theAccessTokenparameter when connecting. This works because the module is exchanging the refresh token for an access token that has the correct audience on your behalf.New module has not fixed anything, not sure it was meant to…
@cblackuk for the
get_SerializationSettingserror if we can open a separate issue that will help with tracking. Also, it will be helpful to see the other modules you have loaded. I suspect your error might be due to an assembly binding redirect issue.I have a better error than you:
@cblackuk can you check if you also have this issue. I would assume this is something you want to implement as well (Azure Plan support).