Azure Pipelines NuGet "Unable to load the service index for source"
NuGet asked the feed for its service index and was rejected, usually with a 401. The feed is reachable, but restore ran without an authenticated NuGet config, so the private Azure Artifacts source refused it.
What this error means
A dotnet restore or NuGet restore step fails with Unable to load the service index for source https://pkgs.dev.azure.com/... and Response status code does not indicate success: 401 (Unauthorized).
error NU1301: Unable to load the service index for source
https://pkgs.dev.azure.com/org/_packaging/feed/nuget/v3/index.json.
Response status code does not indicate success: 401 (Unauthorized).Common causes
Restore ran without feed credentials
The job restored against a private feed without an authenticated NuGet config, so the service index request returned 401.
The build service lacks feed access
Even with a token, the pipeline identity may not be a reader on the feed, so it is unauthorized.
How to fix it
Use the DotNetCoreCLI restore with the feed
Restore through the task that authenticates the internal feed, or run NuGetAuthenticate first.
- task: NuGetAuthenticate@1
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
vstsFeed: 'Platform/feed'Grant the build service read on the feed
- Open the Azure Artifacts feed settings, Permissions.
- Add the project build service identity as a Reader (or Collaborator).
- Re-run restore so the index loads with access.
How to prevent it
- Run NuGetAuthenticate (or the authenticated restore task) before restore.
- Grant the build service Reader on every private feed it restores from.
- Keep
nuget.configpointed at the right feed index URL.