microsoft / CloudAdoptionFramework

Code samples and extended documentation to support the guidance provided in the Microsoft Cloud Adoption Framework
https://aka.ms/CAF
Creative Commons Attribution 4.0 International
854 stars 614 forks source link

When Running the Command docker build -t azurenamingtool . from Linux Server an Error Showed up like nu1301 unable to load the service index for source #162

Closed INPRASHANDHI closed 1 year ago

INPRASHANDHI commented 1 year ago

Hello @BryanSoltis/ Anyone who can Help.

We are trying to run the Docker Image in Linux Server and executing the Command docker build -t azurenamingtool . there is an error showed like nu1301 unable to load the service index for source.

Like Below Image

image

Can you guide or help how we can solve this issue to move Forward.

Awaiting Reply....

INPRASHANDHI commented 1 year ago

Anyone can Advise on this..

BryanSoltis commented 1 year ago

Hello @INPRASHANDHI,

Thank you for writing. I'm not a Docker/container expert, but in researching this error, it usually occurs when the container host cannot access the internet and complete the dotnet restore. The Azure Namign Tool is a .NET 6 Blazor Server application. The container for this is based on the mcr.microsoft.com/dotnet/sdk:6.0 image.

In researching your error, it seems to occur when there is a proxy server the container is attempting to communicate out through. Is this the case? If not, is there are any firewall/gateway in place that could be preventing external access? I can tell you that there are no special paths/URLs with the Azure Naming Tool that it is attempting to load as part of the container creation process.

A good test may be to create a standard container and see if it gives the same error:

https://learn.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows

Hope this helps!

INPRASHANDHI commented 1 year ago

Hello @BryanSoltis Thank you for the reply. I was able to fix the issue and it was the https proxy address issue that was not added.

BryanSoltis commented 1 year ago

Glad you got it working!

-Bryan

dexteravelasco commented 1 year ago

How did you fix it?

I am getting

C:\Users\Dexter.Velasco\Downloads\CloudAdoptionFramework-master\CloudAdoptionFramework-master\ready\AzNamingTool>docker build -t azurenamingtool . [+] Building 54.8s (12/17) => [internal] load .dockerignore 0.0s => => transferring context: 358B 0.0s => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 700B 0.0s => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0 0.6s => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0 0.6s => [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:a3bbff689a86ba7f3ddcee5089a729b20e20e3b4dbfb9d0a43bb3284d9081023 0.0s => [internal] load build context 0.1s => => transferring context: 11.05kB 0.0s => [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:6.0@sha256:f76f95813a87d711928c6b02335614f328cc1c9c53315137fd64ea13b2be09f9 0.0s => CACHED [base 2/2] WORKDIR /app 0.0s => CACHED [final 1/2] WORKDIR /app 0.0s => CACHED [build 2/7] WORKDIR /src 0.0s => CACHED [build 3/7] COPY [AzureNamingTool.csproj, .] 0.0s => ERROR [build 4/7] RUN dotnet restore "./AzureNamingTool.csproj" 54.1s

[build 4/7] RUN dotnet restore "./AzureNamingTool.csproj":

0 0.850 Determining projects to restore...

0 8.204 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 17.25 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 24.63 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 31.75 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 39.21 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 46.63 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 54.01 /src/AzureNamingTool.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

0 54.05 Failed to restore /src/AzureNamingTool.csproj (in 52.93 sec).


Dockerfile:11

9 | WORKDIR /src 10 | COPY ["AzureNamingTool.csproj", "."] 11 | >>> RUN dotnet restore "./AzureNamingTool.csproj" 12 | COPY . . 13 | WORKDIR "/src/."

ERROR: failed to solve: process "/bin/sh -c dotnet restore \"./AzureNamingTool.csproj\"" did not complete successfully: exit code: 1

C:\Users\Dexter.Velasco\Downloads\CloudAdoptionFramework-master\CloudAdoptionFramework-master\ready\AzNamingTool>

binteezyy commented 1 year ago

Hello @BryanSoltis Thank you for the reply. I was able to fix the issue and it was the https proxy address issue that was not added.

What exactly was the fix?