ACI connection to private ACR - azure

We need to set ACR to be available only to selected networks (not public access).
However, when we set this, ACI is not able to pull image from the ACR.
How to solve this?
EDIT:
ACI says:
Failed to pull image "<acrname>.azurecr.io/<imagae-name>:02b6d84d635c3d9ff4182ad1c50d16364695d3d5": rpc error: code Unknown desc Error response from daemon: Head "https://<acrname>.azurecr.io/v2/<image-name>/manifests/02b6d84d635c3d9ff4182ad1c50d16364695d3d5": denied: client with IP 'x.x.x.x' is not allowed access. Refer https://aka.ms/acr/firewall to grant access.

Found few relevent Document1 and Document2 which clearly stated that unfortunately we don't have this feature as of now to access the images from ACR through private network using ACI.
Only an Azure Kubernetes Service cluster or Azure virtual machine can
be used as a host to access a container registry using a service
endpoint. Other Azure services including Azure Container Instances
aren't supported
If your purpose is to make the ACI only be accessible from the VNet, make the image public or accessible from the Internet and delpy the ACI into the VNet.
But it doesn't mean your ACR will be public or your image need to be public image. You can have your private ACR and image but the images will access from the internet not from Selected Networks.

Related

Access private or firewall-protected Azure Container Registry from Github actions workflow

What I have:
I have an Azure Container Registry (ACR) with public access, and a hosted Github action runner that builds and pushes a Docker image into that ACR.
The problem:
Azure recommends me to disable public access and implement private endpoint instead.
After some researches, I see that this is probably not possible since the Github runner is not in the same VNet of the ACR, And the runner is hosted and managed by Github. Is that true?
Possible workaround Is to allow public access but with a whitelist of IP addresses (Github runner IPs), one problem there is that it's a very long list (reference)
I'm happy to get suggestions of options that I can do.
A self-hosted runner could solve the problem.
https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#about-self-hosted-runners
Create a private endpoint for the ACR (using a Private DNS zone for DNS configuration is the easyest way - https://learn.microsoft.com/en-us/azure/container-registry/container-registry-private-link)
Create a VM in the same Vnet (or in any other connected Vnet according to your network organization)
Install the Github runner application
Use this runner in your workflow
Ensure that The VM is able to connect to github to pick jobs
https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github

dial tcp: lookup: device or resource busy

There is an intermittent issue while downloading docker images in a Linux VM. As per docker service journalctl logs I can see below error-
level=error msg="Handler for POST /images/create returned error: Get
"https://<containerregistry>": dial tcp: lookup
https://<containerregistry>: device or resource busy".
Initialy I thought it could be intermittent connectivity issue with container registry (Azure Container Registry) but that is not the case since even with retries at different time periods I got the same error.
I have checked the docker daemon.json config and don't see any issue with that. I also verified DNS servers in systemd-resolve and can see the expected IPs as required. Interestingly, another VM with same configs works fine.
I am using .Net Client for Docker Remote API (https://github.com/dotnet/Docker.DotNet) to trigger docker image updates. The client is hosted in a Linux VM which is triggered by via socket as an RPC call. It reaches the client and executes the API ImageOperation.CreateImageAsync.
Can someone help with this? Please let me know if I can add more details.
• Regarding the error that you are encountering, I would suggest you to please check the azure container registry health first by executing the below command: -
az acr check-health --name registryname --vnet virtualnetworkname
Then, check the internet upload and download speed through ‘AzureSpeed’ tool to the container registry which hosts the images layers. Also, it may be that the image size may not be supported for the registry service tier due to which it is not available.
• Ensure that both your ‘docker client’ and ‘docker daemon’ are configured for proxy behavior behind HTTPS proxy. If you have changed or updated any proxy settings, kindly ensure to restart the daemon service.
• Check the ‘Registry resource logs in the ContainerRegistryLoginEvents table’ for further diagnosis of an attempted connection. Also, check whether the registry is accessible over the internet and allow access to the public registry endpoints from all networks. If the container registry is configured for selected virtual network with a service endpoint, then disabling public network access also disables access over the service endpoint.
• If a private endpoint is configured for the container registry, confirm that the DNS resolves the registry's public FQDN such as myregistry.azurecr.io to the registry's private IP address. Use a network utility such as ‘dig’ or ‘nslookup’ for DNS lookup. Ensure that DNS records are configured for the registry FQDN and for each of the data endpoint FQDNs as per the below documentation link: -
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-private-link#dns-configuration-options
• If a service endpoint to the registry is configured, confirm that a network rule is added to the registry that allows access from that network subnet. Also, ensure that the resource provider for Azure Container Registry is registered.
For more details regarding the further steps to take to perform regarding the error that you have encountered, kindly refer to the documentation link below: -
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-troubleshoot-access#configure-service-access

Azure Storage - Firewall and Endpoints usage

I have recently come across the Private Endpoint feature in Azure Storage and trying to implement it for secure access from a VNet. However, I am getting access issues while using Firewall, Virtual Network Service Endpoint and Private Endpoint all together.
I have two VNets (VNet1 & VNet2) in my subscription and an on-premises machine with Public IP to connect to Azure Storage. Following is my setup.
VNet1 with a Subnet enabled with Service Endpoint feature is whitelisted in Storage account firewall.
Next, I have created a Private Endpoint to this storage account (for blob service) from VNet2 which is also hosted inside the same Vnet.
Finally, I have whitelisted the Public IP of my on-premises VM to connect to the storage account under Firewall section.
Given the above setup, when I am trying to access this storage account blob containers inside a VM placed under VNet2, I am getting authorization issues.
May I please check if this setup is valid? Do Private Endpoint and Service Endpoint features work in Parallel?
Yes, private endpoints can be created in subnets that use Service Endpoints. Clients in a subnet can thus connect to one storage account using private endpoint, while using service endpoints to access others.
There are multiple ways to connect to storage account:
Using a private endpoint (private link) to connect to storage account: Please find the referred document here.
Using Service Endpoint and Private endpoint: Please find the referred document here.
You can find more details in this public document.

Steps for deployment of Container Instance with Virtual Network

I'd like to automate the deployment of a virtual network (that is peered with another network) and container instance connected to that network.
I'd just want to confirm that I'd do the correct steps. I'll be using Azure REST API.
Deploy a Virtual Network with a subnet
Create a Peering to the other virtual network
Create a Network Profile
Deploy the Container with the created network profile.
Step 3 is a bit weird for me because it's different than what I do in the Azure Portal. In the Portal, I just select the virtual network that I want my container to be connected to. Looking at MSDN Docs it seems to me that REST API requires me to create that Network Profile first. Am I right?
When you deploy an container using az container create the az cli will create the network profile for you in the background.
This might be why you might not have seen explicit creation of the network profile before.
A network profile is a network configuration template for Azure resources. It specifies certain network properties for the resource, for example, the subnet into which it should be deployed. When you first use the az container create command to deploy a container group to a subnet (and thus a virtual network), Azure creates a network profile for you. You can then use that network profile for future deployments to the subnet.
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-vnet#network-profile
You steps are looking good.

Can an Azure Container Registry instance reside in my private Azure VNet so that it's not exposed on the internet?

Using Azure Container Registry to support Kubernetes service instance. Is there any way to put the acr instance in my private Azure VNet so that it's not exposed via the internet? I'm using OpenVPN to get into my VNet
Unfortunately, it seems impossible to put the Azure Container Registry in a Vnet. You just can access the container registry through the Server name. Take a look at another case that I answered.
Currently you cannot put the registry on a VNET, but it's on the roadmap in the next few months.
ACR now supports VNET as a preview feature. Please see this:
https://azure.microsoft.com/en-us/updates/azure-container-registry-firewall-rules-and-virtual-network-in-preview/

Resources