Creating a Personal Access Token for Azure Artifacts
Posted May 24, 2025
Reading time: 1 minute
If your .NET solution uses a private Azure Artifacts feed, and you work with dotnet
on the command line, you may
occasionally need to refresh your Azure DevOps Personal Access Token.
I use the dotnet ef
command line tool to create, remove, and script out my database migrations. Usually everything
works as expected, but periodically I start seeing build warnings like this:
C:\Program Files\dotnet\sdk\9.0.300\NuGet.targets(186,5): warning : The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with –interactive for
dotnet
, /p:NuGetInteractive=“true” for MSBuild or removing the -NonInteractive switch forNuGet
The solution is pretty simple, though not entirely straightforward.
I tried running dotnet restore --interactive
, but since my private NuGet packages are cached on disk, this skipped
actually communicating with Azure Artifacts, and thus I was never prompted to authenticate.
In the past, I have done a Build -> Clean Solution
from within Visual Studio 2022, and then run dotnet restore --interactive
. I was
prompted, I authenticated, and everything worked perfectly.
This time, I tried to do everything from the command line:
dotnet nuget locals all --clear
And this mostly worked, but when I tried to do a dotnet restore --interactive
, I kept getting weird errors about access being
denied to certain MSBuild tasks.
Rebooting resolved this issue.
After the reboot, I once again ran dotnet restore --interactive
, and I was prompted to authenticate in the browser. After authenticating,
I had a new Personal Access Token in Azure DevOps, and the build warnings when using dotnet ef
went away.
Hopefully this helps someone. This post is really for Future Jon, though, when he runs into this again. :)