Azure DevOps Pipelines push Docker image to Container Registry Denied - azure

I am currently trying to use Azure Pipelines to build a Docker image and push it to the Azure Container Registry. I have a Service Connection setup, and but the build is failing with "denied." I suspect the reason for this is because my Container Registry is setup to only allow from "selected networks" and is restricted to a few IPs. I validated this by temporarily allowing all networks, and then the build/push succeeded.
Is there any way to get Azure Pipelines to successfully push a Docker image to the Container Registry that is only allowing selected networks? I thought that was what the Service Connection was for?

I'm afraid you're right. The possible reason is that you set it as select networks and do not add the IP address of the DevOps to allow the traffic. As I know, the IP address of the DevOps will change over time, here is the description:
In some setups, you may need to know the range of IP addresses where
agents are deployed. For instance, if you need to grant the hosted
agents access through a firewall, you may wish to restrict that access
by IP address. Because Azure DevOps uses the Azure global network, IP
ranges vary over time.
So you need to allow an IP range, not the single IP address. And it's not a secure way. Well, the most secure way from my experience is that control the access permission for all the people, not the networks. You can create multiple service principals and grant them with different roles to control the permission. For example, use the role AcrPull, it only has permission to pull the images. More details about the roles here. You can even control the permission on the repositories, here is more message about it.
By the way, the firewall to select the networks, I think it's more suitable for the resources inside the Azure, for this, you can use the endpoint to achieve it.

Please make sure that your service connection has AcrPush permission.
You can check it or add if needed here:
(You will find your connection under name 'your-organization-your-project')

Related

Limit access to an azure dev-ops repository to specific IP addresses

I want to limit an azure repository to some IP addresses, while other repositories will be open to different IP addresses. To do so, I tried:
1 – to find a setting in azure dev ops to limit access to a repo to IP addresses – I could not find such a setting.
2 – to create a new organization in azure dev ops, transfer the repo to that new organization, and find a setting in azure dev ops to limit access to an organization to IP addresses – I could not find such a setting.
3 – to use azure ad conditional access to limit access to azure dev-ops – it can be done to the entire azure dev-ops application, but not to a specific origination \ repo.
4 – to create another azure dev-ops application in our subscription – I could not find how to do it.
Any idea what I need to do?
Limit access to an azure dev-ops repository to specific IP addresses
As we know the Azure devops services is a cloud service, so we could directly restrict it to your IP address range with Azure devops settings.
To resolve this request, you could create your Azure DevOps Server and set up a firewall on the server machine, so that only some specified IP address can access the Azure devops server.
Besides, if you do not want to set your Azure DevOps Server, you could also try to use Azure AD's conditional access to prevent logins from certain geographies and address ranges.
You could check this guide Learn about Active Directory and Various Azure Services and this post for some more details.

What is the Azure Container Registry IP range to whitelist?

I have an Azure App Service which uses an Azure container registry (SKU: Basic).
I would like to put in networking restrictions under SCM portion.
Where can I find the Azure Container Registry IP range to whitelist?
If your organization has policies to allow access only to specific IP addresses or address ranges, download Azure IP Ranges and Service Tags – Public Cloud
To find the ACR REST Endpoint IP ranges, search for “AzureContainerRegistry“ in the JSON file. Also, you can filter for Specific Regions.
Note
IP address ranges for Azure services can change, and updates are
published weekly. Download the JSON file regularly, and make necessary
updates in your access rules. If your scenario involves configuring
network security group rules in an Azure virtual network or you use
Azure Firewall, use the AzureContainerRegistry service tag instead.
For more details, you could refer to configure rules to access an Azure container registry behind a firewall.

Set a password for an Azure public-IP

I would like to add security (e.g. a login with a password) for the public-ip for my Azure VM. Because else everybody could e.g. deploy smart contracts via the cakeshop links or turn off and on the Ethereum nodes.
Does anybody know how to do it?
It seems that you cannot set a password for the public IP. But you can set the password for the VM. For the security of the VM, you can use the Azure Network Security Group to filter the traffic. For more details, see Filter network traffic with a network security group.
For more security to the VM, you can try the Identity of Azure AD. Take a look at this Configure managed identities for Azure resources on a VM. Hope this will help you.
There is no such thing as a password for a public IP, a public IP is just a resource assigning IP's to a network interface, nothing more.
If you are hosting an application in Azure it is up to you to make sure this is secure. Ideally, this would be done through authentication at the application layer, to prevent users from being able to do anything in the application without authenticating. If your application does not provide this then you may want to take a closer look at your application and whether it is fit for purpose.
If application level authentication is not possible then you could look at adding authentication at the application server level, be this Apache, IIS, Tomcat etc. You would need to look at the appropriate documentation for your application server.

How do I restrict the clients that can access my Azure App Service?

Given that I create an Azure 'App Service'
How do I ensure that this service is only callable from ...
A.> 2 existing external servers (whose IP addresses will be known)
B.> 3 other App Services which I will be creating, but whose IP Addresses may not be known since I may need to scale those out (Over multiple additional instances)
To clarify... Is there some Azure service that will allow me to treat this collective of machines (both real and virtual) as a single group, such that I can apply some test on incoming requests to see if they originate from this group?
on Azure WebApps, You may wish to know; the IP Restrictions (https://learn.microsoft.com/en-us/azure/app-service/app-service-ip-restrictions) allow you to define a list of IP addresses that are allowed to access your app. The allow list can include individual IP addresses or a range of IP addresses defined by a subnet mask. When a request to the app is generated from a client, the IP address is evaluated against the allow list. If the IP address is not in the list, the app replies with an HTTP 403 status code.
You can use IP and Domain Restrictions to control the set of IP addresses, and address ranges, that are either allowed or denied access to in your websites. With Azure WebApps you can enable/disable the feature, as well as customize its behavior, using web.config files located in their website.
Additionally, VNET Integration gives your web app access to resources in your virtual network but does not grant private access to your web app from the virtual network. Private site access is only available with an ASE configured with an Internal Load Balancer (ILB).
If you haven’t checked this already, checkout Integrate your app with an Azure Virtual Network for more details on VNET Integration (https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet)
I strongly suggest dropping the whole what's my IP approach and throwing in OAuth. Azure AD gives you access tokens with moderate effort —
Service to service calls using client credentials (shared secret or certificate)
Else, TLS client authentication would be next on my list. Although that tends to really suck if you have to deal with several programming stacks, TLS offloaders and what not.

Accessing Azure Virtual machine behind proxy / firewwall

I have created a Windows 2016 data center on Microsoft Azure cloud. I also downloaded its RDP file. However, when I am trying to access it from my Organization I get below error. (of course, organization uses proxy/firewall). When I access it from my home internet, I can access the VM successfully.
Currently the networking of the VM has below setting:
Please help to access the azure VM via proxy.
Edit:
Got few great answers. However, being a trainer, I need to keep creating and deleting the VMs on day to day basis, hence requesting network admin to add a particular VM IP to exception list won't help. Is there any other way possible?
Go with Jason's suggestion. Your network admin needs to configure the corresponding rules for the firewall or proxy. What you need to tell the network admin depends on your setup:
If you are dealing with one VM only, then you could either configure the public IP that is assigned to the VM as static and ask the network admin to allow rdp to that IP address, or, alternatively,
if you would like to save costs for the public IP and your organisation's proxy/firewall is capable of working with DNS names, then you could assign a DNS name to the public IP and let the network admin know the DNS name. The DNS name would be something similar to this: myazurevmname.azurelocation.cloudapp.azure.com
If you are planning to access several VM's in Azure, you can either repeat above steps for each of the VM's, however, may want to think about establishing a point-to-site VPN from your local computer which would remove the need for assigning public IP addresses to each of the VM's. The network setup in Azure will be more complex upfront, but it may be worth the effort. However, this will be a separate discussion.
You could set up teamviewer as a service(!) on your VM and then connect to it with teamviewer from your company pc. it'll be a bit laggy but you'll get used to it
Use this tutorial to set up teamviewer
It seems your organization network block it, you should contact your network admin to add it to firewall/proxy.

Resources