Unable to build docker image due to not finding a private nuget feed source

Viewed 44

Have been attempting to build a docker image for an azure function for the last few days. The project in question gets packages from a private feed. This feed is using azure artifacts. I have tried multiple ways to connect to the private feed based on different solutions found on the web. This involves moving some credentials into nuget.config itself and using a PAT (Personal access token) to connect to the feed, as well as using a VSS_NUGET_EXTERNAL_FEED_ENDPOITNS variable in the docker file and passing in the PAT/Endpoint there via the docker build --build arg method. All of these result in the same error.

error NU1301: Unable to load the service index for source

as noted in the docker file below, you can see commented out attempts to get the artifacts cred provider which is an entirely separate issue and I do not think it is required. If it becomes required i can debug that later, but would like to get past this not finding source error first.

Docker File

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS installer-env

ARG NUGET_PAT
ARG NUGET_ENDPOINT

#RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1'))
#RUN Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1 -UseBasicParsing -OutFile "c:\installcredprovider.ps1"
#RUN powershell -File ./installcredprovider.ps1 -AddNetfx
#RUN apt-get update && apt-get install -y libcurl4
#RUN Invoke-WebRequest "https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1" -OutFile installcredprovider.ps1
#RUN .\installcredprovider.ps1
    
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${NUGET_ENDPOINT}\", \"password\":\"${NUGET_PAT}\"}]}"

# Build requires 3.1 SDK
COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
    mkdir -p /home/site/wwwroot && \
    dotnet publish *.csproj --configfile nuget.config --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:4-appservice
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

Nuget Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <!-- Clears sources (i.e. cleans up other VS package sources and prevents duplicates) -->
        <clear />

        <!-- NuGet.org feed -->
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />

        <add key="<redacted>" value="<redacted>" />

    </packageSources>

</configuration>
0 Answers
Related