Azure Pipelines error - User lacks permission to complete this action. You need to have 'ReadPackages'.
A colleague contacted me because she couldn't get the build pipeline running successfully. The build always failed on the NuGet restore task:
This is the error that we got:
##[error]The nuget command failed with exit code(1) and error(Unable to load the service index for source https://tfs.server.be/tfs/DefaultCollection/_packaging/797f899f-9ad1-4158-93bc-8f3293cf4a59/nuget/v3/index.json.
Response status code does not indicate success: 403 (Forbidden - User 'Build\534a066a-3992-4851-a816-b189836bee69' lacks permission to complete this action. You need to have 'ReadPackages'. (DevOps Activity ID: 8D53BF1D-E45E-49C4-879F-6CBD8635D1CE)).
The error above indicates that the account running the build agent doesn’t have the necessary rights to connect to our Azure Artifacts nuget feed.
This is because by default Azure DevOps automatically restrict the scope of the job agent to the agent itself. As a result, it has no visibility of any services outside of it, including our own Nuget feed.
- To change this, you need to go to your Azure DevOps project settings:
- There go to Pipelines –> Settings:
- Uncheck the "Limit job authorization scope to current project" toggles: