microsoft / Partner-Center-PowerShell

PowerShell module for managing Partner Center resources.
https://docs.microsoft.com/powershell/partnercenter/
MIT License
130 stars 59 forks source link

Get-PartnerCustomer throwing 'Microsoft.Store.PartnerCenter.Exceptions.PartnerException' #379

Open ac-cm opened 2 years ago

ac-cm commented 2 years ago

Starting sometime yesterday, our scripts using "Get-PartnerCustomer" are failing now (multiple users can reproduce).

Referencing individual customers works without issue. PartnerExceptionError

I'm curious if this is a wide spread issue or if isolated to our tenant.

RinieH commented 2 years ago

We are facing the same issue

mbosgoed commented 2 years ago

When using the Debug mode I see the absolute URI:

Absolute Uri: https://api.partnercenter.microsoft.com/v1//v1/customers?size=500&seekOperation=Next

When looking at the documentation it is going wrong by adding '/v1/' to the uri https://docs.microsoft.com/en-us/rest/api/partner-center/manage-customer-accounts/get-customers

mprentice22153 commented 2 years ago

I have PartnerCenter module v3.0.10 installed. When I run against the production environment I get the error that @ac-cm sees and I can confirm the Uri that @mbosgoed reports. When I run against our sandbox environment the commend works fine with the correct Absolute Uri: https://api.partnercenter.microsoft.com/v1/customers. Is the PartnerCenter module dynamically loading components like the Exchange Online Management module does?

mprentice22153 commented 2 years ago

Upon further review of the debug output I see what I believe is the first 500 of our customers being returned and then the error occurs. Is this a problem with the links and next content?

@RinieH or anyone else encountering this error, can you confirm it happens with more than 500 customers? Anyone not getting this error, do you have fewer than 500 customers?

image

RinieH commented 2 years ago

Hi @mprentice22153 , yes we have well over 500 customers in Partner Center

ac-cm commented 2 years ago

@mbosgoed, I'm pretty sure you've identified the problem regarding the URI having /V1/ duplicated, and I assume this is an issue with the PartnerCenter module not using the correct URI. I have confirmed with Microsoft Support that the maximum number of customers you can receive at one time is 500, however the Continuation Token is produced to apply to each additional {{BaseUrl}}/customers?size=500&seekOperation=Next request. I have been able to get all customers returned using Postman without issue using the corrected URI.

mbosgoed commented 2 years ago

When using calling the API's directly I can continue with the Next URI and get all the results. So the Next URI looks like different than before. Did Microsoft Support confirmed that @ac-cm ?

ac-cm commented 2 years ago

I've provided Microsoft the debug output to highlight the URI issue, but I am guessing that since the PartnerCenter module is not officially supported by Microsoft, and other methods of requesting the customer list is working, that Microsoft will wipe their hands clean on this one and say it is not their problem. I'll provide an update if they provide additional feedback to what I shared.

RinieH commented 2 years ago

Intercept colleague @rvdintercept has created a pull request for a solution to this problem. I can confirm that it works perfectly https://github.com/microsoft/Partner-Center-PowerShell/pull/381

jonwbstr commented 2 years ago

nothing against quick fixes, and as long as the module works I'm happy.

However, this fix will break when the endpoint changes from "v1" to something else.

ac-cm commented 2 years ago

I am honestly surprised this is not getting attention from more partners as being problematic. In theory, this would only affect partners with greater than 500 customers.

mprentice22153 commented 2 years ago

@jonwbstr Yes, this will stop working again when the endpoint changes, and maybe another fix is needed to be a more resilient change but that can probably wait until the new SDK comes out in early December with all the NCE updates.

Can we get someone to publish a new release (3.0.11?) with this fix so we can return to having working functionality in our scripts? Thank you.

jonwbstr commented 2 years ago

It looks like the problem fixed itself. I did open a ticket and get confirmation Microsoft changed how the endpoint was working so maybe they got flooded with similar requests and reverted their change? Either way, the next.uri doesn't include /v1/ any more! yay

"next": { "uri": "/customers?size=500&seekOperation=Next", "method": "GET",

ac-cm commented 2 years ago

I meant to chime in on this earlier. It appears Microsoft fixed their end sometime on Friday 11/19. I also had a ticket opened with Microsoft that originally they denied anything had changed but at least partially confirmed the issue is resolved regardless.