无法向Azure功能提供NuGet包源凭据

Vin*_*mth 4 c# azure nuget azure-devops azure-functions

我有一个Azure功能,它依赖于私有包feed.

我正在将nuget.config文件复制到app服务,如下所示:

<?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>
Run Code Online (Sandbox Code Playgroud)

注意:我使用我的Hotmail帐户电子邮件地址的第一部分,因为这是我用于在其他地方对私有源进行身份验证的用户名 - Visual Studio等.

这就是我在Azure功能门户中的日志中看到的:

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.
Run Code Online (Sandbox Code Playgroud)

如果我按照@brettsam的建议更改Password密钥,ClearTextPassword我现在得到以下内容:

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:
Run Code Online (Sandbox Code Playgroud)

bre*_*sam 13

尝试使用key="ClearTextPassword"(而不是key="Password").如果您使用Password,nuget假定该值已加密并将尝试解密它.

例如,我在VSTS中创建了一个包源,然后创建了一个个人访问令牌并使用它:

<?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>
Run Code Online (Sandbox Code Playgroud)

  • 如何加密PAT值? (3认同)