Azure Functions 的好处之一是您可以 bring your own dependencies使用 NuGet、npm 等。如果 VSTS Package Management 中有一个内部 NuGet 包如果您想将其用作 Azure Function 中的依赖项,那么如何将其包含在 Azure Function usings
中?
示例:我可能想要利用内部数据访问库、模型或业务逻辑,然后使用 VSTS 包管理作为我们团队管理内部依赖项的方式。我们不想将它们发布到公共(public) nuget.org 画廊 😀
感谢您的帮助!
最佳答案
您可以使用可用信息 here 引用私有(private) NuGet 存储库中的包.
将私有(private)源添加到配置文件后,您可以按照 here 概述的信息添加对自定义包的引用。 .
(OP 的其他编辑...)
示例project.json
{
"frameworks": {
"net46":{
"dependencies": {
"Contoso.Models": "1.2.0",
"Contoso.DAL ": "1.2.0"
}
}
}
}
project.json
已添加到您的函数的根文件夹中。
示例nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyVSTSPackageManagementFeed" value="https://contoso.pkgs.visualstudio.com/_packaging/Contoso/nuget/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSourceCredentials>
<MyVSTSPackageManagementFeed>
<add key="Username" value="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d60684d6e626379627e62236e6260" rel="noreferrer noopener nofollow">[email protected]</a>" />
<add key="ClearTextPassword" value="<MyPersonalAccessTokenHere>" />
</MyVSTSPackageManagementFeed>
</packageSourceCredentials>
</configuration>
nuget.config
添加到函数的根文件夹中,或者如果您想在所有函数中使用它们,则可以将其添加到主机级文件夹中。
关于azure - 如何通过 Azure Functions 在 VSTS 包管理中使用 NuGet 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42773297/