17

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:
Pang
  • 9,564
  • 146
  • 81
  • 122
Vinyl Warmth
  • 2,226
  • 3
  • 25
  • 50
  • Is the `Password` value that you got above the token that you got directly from your feed? Or did you generate it with `nuget.exe sources add|update` on your local machine? – brettsam Oct 05 '16 at 13:17
  • @brettsam I generated the token from the `Team Services` online portal – Vinyl Warmth Oct 05 '16 at 13:24
  • You can try to create an alternative credential on VSTS, then add your feed source by using nuget.exe sources add -name {your feed name} -source {your feed URL} -username {alternative user name} -password {your PAT} command. On the other hand It seems that the issue is not related to credential (unable to load the service index for source), what're detail steps to create and user Azure function? – starian chen-MSFT Oct 06 '16 at 05:52

1 Answers1

46

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>
Pang
  • 9,564
  • 146
  • 81
  • 122
brettsam
  • 2,702
  • 1
  • 15
  • 24
  • 1
    I just tried this myself and it worked. Can you re-post exactly what your nuget.config looks like above? And double-check that your PAT has all the correct 'Packaging read' permissions? Ultimately this is a nuget config issue not entirely related to Azure Functions, so you should be able to set this up locally on your machine and test it out more quickly than doing it through the Functions sites. That may help you narrow it down. – brettsam Oct 05 '16 at 15:38
  • Looks like I had an issue creating the PAT, thanks for all your help – Vinyl Warmth Oct 10 '16 at 08:10
  • 3
    how to encrypt the PAT value? – Vista Nov 03 '22 at 06:36