2
votes

One of the nice things of Azure Functions is that you can bring your own dependencies with NuGet, npm, etc. If you have an internal NuGet package inside of VSTS Package Management that you want to use as a dependency in your Azure Function, how would you go about including it in your Azure Function usings?

Example: I may want to leverage my internal Data Access Libraries, models, or business logic and then use VSTS Package Management as the way our team manages our internal dependencies. We wouldn't want to publish those out to the public nuget.org gallery ????

Thanks for the help!

1

1 Answers

2
votes

You can reference packages in a private NuGet repository using the information available here.

Once you add your private source to the config file, you can add references to your custom packages following the information outlined here.

(Additional edits from OP...)

Example project.json

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "Contoso.Models": "1.2.0",
        "Contoso.DAL ": "1.2.0"
      }
    }
   }
}
  • project.json is added to root folder for your function.

Example 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="[email protected]" />
      <add key="ClearTextPassword" value="<MyPersonalAccessTokenHere>" />
    </MyVSTSPackageManagementFeed>
  </packageSourceCredentials>
</configuration>
  • nuget.config is added to either the root folder for your function or if you want to use them across all of your functions, you can add it to the host level folder.