Skip to content

[Bug] SPN-based push with npx pa push leads to 403 http error #440

Description

@jonyr34

Describe the bug

I want to use an SPN to do unattended Dev Deployments to a Power Platform Environment. I gave the SPN all necessary permissions. I followed all steps layed out in this MS learn article: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/use-service-principal?tabs=ps

My azure-pipeline.yaml that runs to pa app push command

  npx --no-install pa app push `                                                                                                                                                                                                                                                                                      
    --solution-id "$solutionId" `                                                                                                                                                                                                                                                                                     
    --non-interactive                                                                                                                                                                                                                                                                                                 

Variables:

  env:                                                                                                                                                                                                                                                                                                                
    PA_CLI_USE_SP_AUTH: 'true'                                                                                                                                                                                                                                                                                        
    PA_CLI_SP_CLIENT_ID: $(HIN_CI_CLIENT_ID)                                                                                                                                                                                                                                                                          
    PA_CLI_SP_CLIENT_SECRET: $(HIN_CI_CLIENT_SECRET)                                                                                                                                                                                                                                                                  
    PA_CLI_SP_TENANT_ID: $(HIN_CI_TENANT_ID)  

Error

Error i receive:
HTTP error status: 403 for GET
https://..environment.api.powerplatform.com/powerapps/environment?api-version=1&$filter=name eq '':

{
"error": {
"code": "BusinessAppPlatformRequestFailed",
"message": "The request failed with client error: 'The service principal with id '' for application '' does not have permission to access the environment checkAccess endpoint in tenant ''. The correlation ID is ''.",
"details": [
{
"code": "MultipleErrorsOccurred",
"message": "Multiple errors occurred. Please see details.",
"details": [
{
"code": "Forbidden",
"message": "The service principal does not have permission to access the environment checkAccess endpoint."
}
]
},
{
"code": "FullNonLocalizedError",
"message": "{"error":{"code":"Forbidden","message":"The service principal does not have permission to access the environment checkAccess endpoint."}}"
}
]
}
}

→ Run pa auth login to sign in, or verify access to the environment.
pa app push failed with exit code 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions