powerplatform-build-tools icon indicating copy to clipboard operation
powerplatform-build-tools copied to clipboard

'Requested instance not found' error when running pac admin assign-user

Open ramontebar opened this issue 6 months ago • 0 comments

Describe the bug We are getting the following error when running pac admin assign-user

{"errors":[{"Subject":"Result","Description":"Requested instance 80de3309-2d49-ef11-bfdf-000d3a53722e not found","Code":"instanceNotFound"},{"Subject":"InnerException","Description":null,"Code":null},{"Subject":"AdditionalData","Description":null,"Code":null}],"information":[{"Subject":"Result","Description":"[\"SyncMode: Default\",\"Requested instance 80de3309-2d49-ef11-bfdf-000d3a53722e not found\"]","Code":"instanceNotFound"},{"Subject":"AdditionalResultDetails","Description":"","Code":null},{"Subject":"RequestId","Description":"81c1fd0b-f078-4cce-942e-e3b0dbd4b476","Code":null},{"Subject":"CorrelationId","Description":"c99335ef-ec6d-4661-892e-774cad03980f","Code":null},{"Subject":"SystemUserId","Description":null,"Code":null},{"Subject":"SecurityGroupId","Description":null,"Code":null},{"Subject":"Timestamp","Description":"7/24/2024 10:57:07 AM","Code":null}]}

To Reproduce Steps to reproduce the behavior:

1. Log in with a service principal

pac auth create `
 --applicationId $appId `
 --clientSecret $secret `
 --tenant $tenantId

2. Create a Developer environment

$newEnvironmentResponseJSON = pac admin create `
 --name $environmentName `
 --type 'Developer' `
 --user $userID `
 --async false `
 --json

$newEnvironmentDetails = $newEnvironmentResponseJSON | ConvertFrom-Json
$newEnvironmentID = $newEnvironmentDetails.EnvironmentId

3. Add user to environment as System Administrator

pac admin assign-user `
 --environment $newEnvironmentID `
 --user $userID `
 --role 'System Administrator'

Expected behavior The command pac admin assign-user should run successfully and add the user to the new environment as a System Administrator.

Please notice this error doesn't happen always. It happens right just after the environment has been created. If we wait 10-30 minutes after the environment has been created, it works.

PAC CLI Version 1.32.8+gf89d946

Powershell Version 7.4.2

ramontebar avatar Jul 31 '24 14:07 ramontebar