0
votes

enter image description hereI am facing Access denied error while performing a SPFx deployment through Azure DevOps. The error says, "Error: Access denied. You do not have permission to perform this action or access this resource". I am using a service account to deploy the sppkg file on App Catalogue, which has Site collection admin permission level, and The account which I am using on dev-ops is my corporate account. I am also able to connect to SPO Online successfully. The command where this error is coming is like this:

o365 spo app add -p $(System.DefaultWorkingDirectory)/_myCI/drop/sharepoint/solution/myspfx.sppkg --overwrite --appCatalogUrl https://$(tenant).sharepoint.com/$(catalogsite) --scope sitecollection
1
Did you run o365 login before running the app add command? Could you share your devops pipeline? - Levi Lu-MSFT
STEP 1: Use Node 10.x //ALL OK-- STEP 2:install -g @pnp/office365-cli //ALL OK-- STEP 3: o365 spo app add -p $(System.DefaultWorkingDirectory)/_myCI/drop/sharepoint/solution/myspfx.sppkg --overwrite --appCatalogUrl https://$(tenant).sharepoint.com/$(catalogsite) --scope sitecollection //Throws error: Error: Access denied. You do not have permission to perform this action or access this resource. - Rishi Vedpathi
@LeviLu-MSFT added screenshot and steps - Rishi Vedpathi
You might need to move the script o365 spo app add to the Step Connect SPO Site. If you login in your SPO site using a script task. The console session will be closed when the task is completed and that might cause the login session cannot persist in the following steps. - Levi Lu-MSFT
how can I write both commands in one action item? Not sure about the syntax - Rishi Vedpathi

1 Answers

0
votes

You can try moving the script o365 spo app add to the Step Connect SPO Site. See below syntax using "|" to run multiple line scripts in the script task.

- script: |
   Connect SPO Site
   o365 spo app add

See here for example in bash task.