Skip to content
Latchkey

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.

azure-pipelines
##[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.

azure-pipelines.yml
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

  1. For internal feeds, grant the pipeline's build service identity Reader on the feed.
  2. For external feeds, create/refresh the NuGet service connection credentials.
  3. Run NuGetAuthenticate@1 before 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@1 ahead of restore steps.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →