Azure Pipelines NuGet Restore Failed (service connection / feed auth)
A NuGetCommand@2/DotNetCoreCLI@2 restore could not authenticate to a package feed. An external feed needs a valid NuGet service connection; an internal Azure Artifacts feed needs the pipeline (or its build identity) authorized to read it.
What this error means
Restore fails with a 401/403 or "unable to load the service index" for a feed. The build then fails because packages were not restored.
##[error]The nuget command failed: Unable to load the service index
for source https://pkgs.dev.azure.com/org/_packaging/internal/nuget/v3/index.json.
Response status code: 401 (Unauthorized).Common causes
External feed service connection missing or expired
A private external feed needs a NuGet service connection with valid credentials. A missing connection, or an expired token/key, returns 401.
Internal feed not authorized for the build identity
An Azure Artifacts feed must grant the pipeline's build service identity read access. Without it, restore from the internal feed is unauthorized.
How to fix it
Restore with the right feed and auth
Use the feed/service connection inputs so restore authenticates.
steps:
- task: NuGetAuthenticate@1
- task: DotNetCoreCLI@2
inputs:
command: restore
feedsToUse: select
vstsFeed: 'Platform/internal'
# for external feeds: externalFeedCredentials: 'nuget-conn'Authorize the build identity / refresh the connection
- For internal feeds, grant the pipeline's build service identity Reader on the feed.
- For external feeds, create/refresh the NuGet service connection credentials.
- Run
NuGetAuthenticate@1before restore so credentials are wired up.
How to prevent it
- Authorize the build identity on internal Artifacts feeds.
- Keep external-feed service connection credentials current.
- Run
NuGetAuthenticate@1ahead of restore steps.