Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az acr login with private endpoint goes via public route #17137

Open
r3-jerrysteele opened this issue Feb 26, 2021 · 23 comments
Open

az acr login with private endpoint goes via public route #17137

r3-jerrysteele opened this issue Feb 26, 2021 · 23 comments
Assignees
Labels
Container Registry az acr question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@r3-jerrysteele
Copy link

Describe the bug

Command Name
az acr login

Errors:

Error response from daemon: Get https://myregistryname.azurecr.io/v2/: denied: client with IP '<my public IP>' is not allowed access. Refer https://aka.ms/acr/firewall to grant access
Login failed.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Connect to Azure VPN
  • az acr login -n myregistryname --subscription mysubscription

Expected Behavior

Login to the ACR's private endpoint via the connected VPN

Environment Summary

Linux-4.4.0-19041-Microsoft-x86_64-with-debian-bullseye-sid
Python 3.6.10
Installer: DEB

azure-cli 2.19.1

Using WSL1

Additional Context

I am logged into a VPN (Azure Virtual Network Gateway), I have made the necessary adjustments to the /etc/resolv.conf so that the ACR resolves to the Private Link IP:

Server:         10.x.x.x.
Address:        10x.x.x#53

Non-authoritative answer:
myregistryname.azurecr.io canonical name = myregistryname.privatelink.azurecr.io.
Name:   myregistryname.privatelink.azurecr.io
Address: 10.x.x.x

The ACR is configured not to allow public access, but has a private endpoint configured which is known to work

I can curl the URL of the ACR and get a 200 response (as it goes via the private address), it seems that the issue is with azure-cli itself.

ip route 10.x.x.x also shows that the route goes via the VPN interface

@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 26, 2021
@yungezz yungezz added Container Registry az acr Service Attention This issue is responsible by Azure service team. labels Mar 1, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Mar 1, 2021
@ghost
Copy link

ghost commented Mar 1, 2021

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @toddysm, @yugangw-msft.

Issue Details

Describe the bug

Command Name
az acr login

Errors:

Error response from daemon: Get https://myregistryname.azurecr.io/v2/: denied: client with IP '<my public IP>' is not allowed access. Refer https://aka.ms/acr/firewall to grant access
Login failed.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Connect to Azure VPN
  • az acr login -n myregistryname --subscription mysubscription

Expected Behavior

Login to the ACR's private endpoint via the connected VPN

Environment Summary

Linux-4.4.0-19041-Microsoft-x86_64-with-debian-bullseye-sid
Python 3.6.10
Installer: DEB

azure-cli 2.19.1

Using WSL1

Additional Context

I am logged into a VPN (Azure Virtual Network Gateway), I have made the necessary adjustments to the /etc/resolv.conf so that the ACR resolves to the Private Link IP:

Server:         10.x.x.x.
Address:        10x.x.x#53

Non-authoritative answer:
myregistryname.azurecr.io canonical name = myregistryname.privatelink.azurecr.io.
Name:   myregistryname.privatelink.azurecr.io
Address: 10.x.x.x

The ACR is configured not to allow public access, but has a private endpoint configured which is known to work

I can curl the URL of the ACR and get a 200 response (as it goes via the private address), it seems that the issue is with azure-cli itself.

ip route 10.x.x.x also shows that the route goes via the VPN interface

Author: r3-jerrysteele
Assignees: -
Labels:

Container Registry, Service Attention, needs-triage, question

Milestone: -

@yungezz
Copy link
Member

yungezz commented Mar 1, 2021

route to appropriate team

@yugangw-msft
Copy link
Contributor

@r3-jerrysteele, sorry for missing this. The best way to diagnose this is to verify the DNS setting. If not resolving to the private ip, then the error is expected. Doc is here:

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-private-link#validate-private-link-connection.

Please let us know what you found out

@yugangw-msft yugangw-msft self-assigned this Mar 25, 2021
@yugangw-msft yugangw-msft assigned toddysm and unassigned yugangw-msft May 16, 2021
@fieldp
Copy link

fieldp commented Nov 18, 2021

Hi. I have the exact same issue. Not sure if it's a CLI issue or user error, so I posted it on the Microsoft Q&A forum. https://docs.microsoft.com/en-us/answers/questions/632408/trying-to-access-an-azure-container-registry-with.html

@LahariChidura
Copy link

I am facing the same issue.
The ACR DNS resolves to private IP address in the vnet -
image

however, az acr login throws this error -
image

@fieldp
Copy link

fieldp commented May 17, 2022 via email

@mdheerendra
Copy link

mdheerendra commented May 20, 2022

I have this same issue, I've created a Azure Resourse Manager Service Connection and While using Azure CLI command az acr build --image reponame:imagename --registry acrname --file Dockerfile . with self hosted agent, I'm getting the same error.

@ttasharski73
Copy link

ttasharski73 commented May 23, 2022

I found that using docker login / docker build correctly uses the private endpoint.

I created a token on the ACR with a PW

Using this to login as example
echo $ACR_PW| docker login -u $ACR_USER --password-stdin registryUrl

This to build as example
docker build -t registryUrl/imagename --file DockerFile .

@lordisp
Copy link

lordisp commented Jul 6, 2022

I'm running private hosted devops agents. Login works but building the image using az acr build get still somehow routed over the public route:

az acr login --name myreg.azurecr.io
az acr build --registry myreg.azurecr.io --image xxx:yyy .
========================== Starting Command Output ===========================
/usr/bin/bash /agent/_work/_temp/771f368c-362a-4c11-8df9-b49ece019f58.sh
WARNING: The login server endpoint suffix '.azurecr.io' is automatically omitted.
Login Succeeded
WARNING: The login server endpoint suffix '.azurecr.io' is automatically omitted.
WARNING: Packing source code into tar to upload...
WARNING: Excluding '.git' based on default ignore rules
WARNING: Excluding '.gitignore' based on default ignore rules
WARNING: Uploading archived source code from '/tmp/build_archive_c4dc880b67914c5d9e0fdabd3ca87293.tar.gz'...
WARNING: Sending context (854.722 KiB) to registry: myreg...
WARNING: Queued a build with ID: cb4
WARNING: Waiting for an agent...
2022/07/06 22:12:39 Downloading source code...
2022/07/06 22:12:40 Finished downloading source code
2022/07/06 22:12:41 Using acb_vol_055ad1ce-aff6-4195-bf76-f619d26a7abf as the home volume
2022/07/06 22:12:41 Setting up Docker configuration...
2022/07/06 22:12:41 Successfully set up Docker configuration
2022/07/06 22:12:41 Logging in to registry: myreg.azurecr.io

failed to login, ran out of retries: failed to set docker credentials: Error response from daemon: Get "[https://acrlhggixiservicesp.azurecr.io/v2/"](https://myreg.azurecr.io/v2/%22): denied: client with IP '20.50.200.13' is not allowed access. Refer https://aka.ms/acr/firewall to grant access.
: exit status 1

The only way to get this working is building the image using docker build, tag it to the acr and push it:

az login --identity
az acr login --name myreg.azurecr.io
docker build -t foo:v1.0 .
docker tag foo:v1.0 myreg.azurecr.io/foo:v1.0
docker push myreg.azurecr.io/foo:v1.0

I believe this is a bug in az acr build cli

@vf-doctor
Copy link

Just want to add that I am also experiencing the same issue. Doing a nslookup or dig on the acr endpoint resolves to the private IP address but az acr build routes via the public endpoint.

And because I am running the agent in an azure container instance I have had problems getting docker to run inside the container. So the workaround noted above is not as easy for me to deploy.

@thedheerendra
Copy link

thedheerendra commented Aug 29, 2022

I had found with a Microsoft Case that you need to whitelist those 2,3 public IPs on ACR(with private endpoints) which will appear with that error. Those IPs are somehow useful for build.

@vf-doctor
Copy link

vf-doctor commented Aug 29, 2022

@thedheerendra Unfortunately, when you turn off public access entirely you no longer are able to whitelist any public IPs. The az acr build generates ACR tasks which use dedicated compute nodes to perform the container build. These virtual nodes exist outside the virtual network the build agent is running in. That seems to be the crux of the issue.

@eiji102030
Copy link

eiji102030 commented Nov 15, 2022

I have the same issue. Are there any updates?

@sbussetti
Copy link

sbussetti commented Feb 13, 2023

confirmed this issue on macos and ubuntu operating systems today
az acr login seems to work for me via private endpoint. It's az acr build that I have this issue with. It seems they have worked around this issue this way: Azure/acr#603

@Wompipomp
Copy link

We have the same issue. az acr build gets routed via public route :(

@sbussetti
Copy link

@Wompipomp see Azure/acr#603

@flavian-anselmo
Copy link

Any updates on this ?

@toddysm
Copy link

toddysm commented Aug 4, 2023

Changing the assignment to @northtyphoon and @terencet-dev for next steps.

@rajeshkaremane
Copy link

rajeshkaremane commented Sep 8, 2023

have same issue while running az cli on build agent and acr over private link

Work around
az acr login --name registryname
cd $(Build.SourcesDirectory)
docker buildx build -t registryname.azurecr.io/reponame:$(Build.BuildId) --platform=linux/arm64 .
docker push registryname.azurecr.io/reponame:$(Build.BuildId)
if ($LastExitCode -ne 0)
{
Write-Host “##vso[task.complete result=Failed;]DONE”
exit 1
}

@AurimasNav
Copy link

In my case it is az acr run --cmd "acr purge.." that is failing to work via private endpoint, probably the same root cause as for build.

@Yeseh
Copy link

Yeseh commented Nov 14, 2023

have same issue while running az cli on build agent and acr over private link

Work around az acr login --name registryname cd $(Build.SourcesDirectory) docker buildx build -t registryname.azurecr.io/reponame:$(Build.BuildId) --platform=linux/arm64 . docker push registryname.azurecr.io/reponame:$(Build.BuildId) if ($LastExitCode -ne 0) { Write-Host “##vso[task.complete result=Failed;]DONE” exit 1 }

This problem seems to still be present. This workaround did the trick for us.

@fortunkam
Copy link

Did this ever get resolved? I am seeing the same exact problem as the original post. nslookup resolves the correct vnet address of the ACR, az acr login tries to work via the public address (and recommends adding my IP to the acr firewall)

@ldvy
Copy link

ldvy commented Jul 21, 2024

I have the same problem. The xxx.azurecr.io correctly resolves to xxx.privatelink.azurecr.io and goes through the internal endpoint to the ACR. However, upon running az acr login it seems to go over public internet.
Ridiculous that this hasn't been fixed for this long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Container Registry az acr question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests