Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't provide NuGet package source credentials to Azure Function

I have an Azure function which has a dependency on a private package feed.

I am copying a nuget.config file to the app service which looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="MyPackageFeed" value="<package feed path>" />
  </packageSources>
  <packageSourceCredentials>
  <MyPackageFeed>
    <add key="Username" value="<first part of Hotmail address, before @ symbol>" />
    <add key="Password" value="<newly generated access token for username>" />
  </MyPackageFeed>
</packageSourceCredentials>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

Note: I use the first part of my Hotmail account email address as this is the username I use to authenticate to the private feed elsewhere - Visual Studio etc.

This is what I am seeing in the Logs in the Azure function portal:

2016-10-05T11:57:16.974 Restoring packages.
2016-10-05T11:57:16.974 Starting NuGet restore
2016-10-05T11:57:18.381 Restoring packages for D:\home\site\wwwroot\HttpTriggerSqlDb\project.json...
2016-10-05T11:57:19.322 Unable to load the service index for source <path to feed>
2016-10-05T11:57:19.322 The parameter is incorrect.

If I change the Password key to ClearTextPassword as suggested by @brettsam, I now get the following:

2016-10-05T14:03:04.479 Please provide credentials for: <path to feed>
2016-10-05T14:03:05.097 Unable to load the service index for source <path to feed>
2016-10-05T14:03:05.097 Response status code does not indicate success: 401 (Unauthorized).
2016-10-05T14:03:05.142 UserName: Password:
like image 569
Vinyl Warmth Avatar asked Oct 05 '16 12:10

Vinyl Warmth


People also ask

How do I add NuGet package to Azure pipeline?

Navigate to your classic pipeline definition, and then select Edit. Select + to add a new task. Search for NuGet, and then select Add to add the task to your pipeline. Name your task and select Restore from the Command.

How do I publish a NuGet package to Azure artifacts from Visual Studio?

Connect to feedSelect Artifacts, and then select your feed from the dropdown menu. Select Connect to feed. Select NuGet.exe. Follow the instructions in Project setup to set up your nuget.

How do I install Azure artifact credential provider?

Select Artifacts and then select your feed. Select Connect to feed. Select NuGet.exe from the left panel. If this is your first time using Azure Artifacts with NuGet.exe, select Get the tools in the top-right corner and follow the instructions to download and install NuGet and Azure Artifacts Credential Provider.


1 Answers

Try using key="ClearTextPassword" (instead of key="Password"). If you use Password, NuGet assumes the value is encrypted and will try to decrypt it.

For example, I created a package feed in VSTS, then created a personal access token and used this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="MyPrivateFeed" value="https://brettsam.pkgs.visualstudio.com/_packaging/stackoverflow/nuget/v3/index.json" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSourceCredentials>
    <MyPrivateFeed>
      <add key="Username" value="brettsam" />
      <add key="ClearTextPassword" value="{PAT}" />
    </MyPrivateFeed>
  </packageSourceCredentials>
</configuration>
like image 123
brettsam Avatar answered Oct 17 '22 22:10

brettsam