microsoft / powerplatform-build-tools

Power Platform Build Tools automate common build and deployment tasks related to Power Platform. This includes synchronization of solution metadata (a.k.a. solutions) between development environments and source control, generating build artifacts, deploying to downstream environments, provisioning/de-provisioning of environments, and the ability to perform static analysis checks against your solution using the PowerApps checker service.
MIT License
187 stars 38 forks source link

Could not find connection '<GUID>' for API 'shared_office365' #533

Closed dspencelink closed 1 year ago

dspencelink commented 1 year ago

Describe the issue

This issue has stumped me for days. We have a Solution with a flow, a power app, 4 environment variables and 4 connection references. I use ALM Accelerator to commit the solution to Azure DevOps, then when I try to deploy to QA environment, the step named 'Import Managed Solution as Update' fails every time. If I enable debugging on the pipeline, this is the error:

Microsoft.Dynamics.PowerPlatformConnectionReferences.Plugins.PreValidateConnectionReferenceCreate Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Request failed with: NotFound and error: {"error":{"code":"ConnectionNotFound","message":"Could not find connection '8718b22cd7cd4273aeaf3ce8b8acffc7' for API 'shared_office365'."}} and request url https://api.powerapps.com/providers/Microsoft.PowerApps/scopes/service/apis/shared_office365/connections/8718b22cd7cd4273aeaf3ce8b8acffc7?api-version=2018-10-01&amp;%24expand=permissions(%24filter%3dmaxAssignedTo('d161b18f-af4e-44f0-abd2-067d13b5c6ee')&amp;%24filter=environment+eq+'c14c9f13-5908-eecf-9002-bb5ee724a811'

If I run Get-AdminPowerAppConnection in powershell, I can find that connection ID in our Prod environnment (I'm deploying to QA).

ConnectionName : 8718b22cd7cd4273aeaf3ce8b8acffc7 ConnectionId : /providers/Microsoft.PowerApps/scopes/admin/environments/ProdGUID/apis/shared_office365/connections/8718b22cd7cd4273aeaf3ce8b8acffc7 FullConnectorName : /providers/Microsoft.PowerApps/scopes/admin/environments/ProdGUID/apis/shared_office365 ConnectorName : shared_office365 DisplayName : PowerAutomate@liprop.com CreatedTime : 2023-07-25T14:38:06.5419228Z CreatedBy : @{id=IDGUID; displayName=My Service Account; email=svc Account email; type=User; tenantId=; userPrincipalName=svc account UPN} LastModifiedTime : 2023-09-12T20:26:51.8655704Z EnvironmentName : ProdGUID Statuses : {@{status=Connected}}

I can see the connection in Prod and QA and they show as connected. I even tried creating new connections and a completely new Solution with new app and connection references. Help? Thanks.

image

Expected Behavior

I'm able to deploy other solutions to QA, just this one is giving me fits. I should be able to deploy to QA and prod.

What component are you experiencing the issue with?

Import Managed Solution as Update task in platform builder tools

What solution version are you using?

1.0.20230802.1

Steps To Reproduce

  1. Create solution
  2. Add flows, apps and connection references
  3. Test migrating to a different environment

Anything else?

No response

dspencelink commented 1 year ago

I finally figured it out! I finally noticed that the Connection Pre-check was querying for a connection ID that existed in Prod but not in QA but the query was looking for that ID in QA environment (which didn't exist obviously). In the ALM Accelerator for Admins app, I had previously renamed the default deployment steps of Validation --> Test --> Prod to be named 'Test --> QA --> Prod' to reflect our naming standards. I had also updated the 'EnvironmentName' of the Test environment to be QA so it showed QA everywhere I could find and in all variables. There must be something hardcoded in the deployment steps where it didn't like that so renaming back to the default fixed the issue.

image