Score:0

Low cost TCP listener for Azure

kh flag

We've been going through the process of migrating VMs from our data centres into Azure. When migrating, one of the gotchas is networking rules; i.e. there are NSGs, hardware firewalls, OS firewalls, VPN routing rules, etc in various places, each managed by different teams, so saying what needs to be updated & ensuring it has been ahead of migrating the VM can be awkard - and you can't test until the VM's been migrated over... Or that was my initial assumption.

I've realised that we can create the NIC and allocate it an IP in advance of migrating the VM. We can temporarily attach this NIC to a resource that listens on the relevant ports, and thus we can test (e.g. using Test-Connection $myNicIP -Port $myPort from those clients we're interested in).

We can use any VM for this, and since the VM doesn't have to be in the same resource group as its NIC potentially we could just have an arbitrary VM, and run the following PS to create a temporary listener for our test: $s = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, $PortOfInterest);$s.Start();Start-Sleep -Seconds 600;$s.Stop().

However, is there a better option?

  • If there's some way to just enable the NIC to respond without needing to attach it to anything (i.e. for easy testing) that would be ideal... but I guess unlikely.
  • Or is there a better solution; e.g. the above powershell could easily be a serverless function; but for that we need a premium service or ASE, then need to setup a private endpooint for it to attach the nic; so it's several steps to get there. Is there some existing solution that can be deployed in minutes to connect to a NIC and just listen for / accept incoming TCP requests; doing nothing more with them.
Score:1
ng flag

Azure Network Interfaces can only be attached to VM's, so you would need to use a VM.

kh flag
Thanks @SamCogan. NB: You can also attach NICs to private endpoints, which can be used for blobs, static sites, storage account file shares, and more, so maybe there's an option there (I'm not sure what the full list is, but it does cover more than just VMs). That said, maybe a VM's the only resource that has the flexibility to host such a generic TCP listener.
ng flag
Yes, that is true, I forgot about private endpoints. As far as I know there are no options that would allow you to undertake action based on the traffic delivered to the NIC other than VMs.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.