willthiswork89
willthiswork89

Reputation: 617

nuget package restore fails for webapp with custom nuget.config

I am attempting to fix a problem I have with restoring nuget packages for a .net core 2.0 webapi that has a custom package source.

Basically when including the nuget.config any microsoft packages fail to install because it seems to ignore my nuget reference.

I have found a workaround, that is to remove my custom nuget.config, let the build fail, once it fails it will have downloaded the proper things from nuget.org and then by adding the custom file back in, it will restore those microsoft packages from disk and then reachout to get my custom nuget package.

My nuget Package config looks like this:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="ASPNET Team" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
    <add key="OTL" value="https://www.myget.org/F/{redacted}/api/v3/index.json" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
  <disabledPackageSources />
</configuration>

The Errors from Kudu are:

An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.hosting.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.entityframeworkcore.tools/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.dependencyinjection.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.dependencyinjection.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.

Doing a dotnet restore directly from Kudu console yields the same results. I have pulled the NuGet.config from my development machine which i know successfully restores both microsoft packages and custom packages and attempted to use that and it still failed.

I'm beginning to think its an outbound port blocking firewall thing within azure but some googling of outbound firewall or proxy on webapp was not fruitful.

Upvotes: 1

Views: 959

Answers (1)

willthiswork89
willthiswork89

Reputation: 617

So after researching and dealing with the Kudu team and Nuget team we found that Azure WebApps has a limited amount of threads in basic and free tiers and when nuget restores happen it does so in a parallel asynchronous way and it hits the thread limit and fails.

To fix, you have to deploy a custom deployment script with --disable-parallel on the dotnet restore.

Upvotes: 3

Related Questions