本文介绍了无法向 Azure Function 提供 NuGet 包源凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于私有包源的 Azure 函数.

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

我正在将 nuget.config 文件复制到如下所示的应用服务:

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>

注意:我使用我的 Hotmail 帐户电子邮件地址的第一部分,因为这是我用来验证其他地方的私人提要的用户名 - Visual Studio 等.

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.

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

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:homesitewwwrootHttpTriggerSqlDbproject.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.

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

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:

推荐答案

尝试使用 key=ClearTextPassword"(而不是 key=Password").如果您使用 Password,NuGet 会假定该值已加密并会尝试对其进行解密.

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

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

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>

这篇关于无法向 Azure Function 提供 NuGet 包源凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:12