As to assigning the ip address you do this within the guest operating system exactly the same as if it were installed on a physical machine. You can create an external vSwitch and connect the VM to it. If there were a DHCP server on that network then the guest could get an address assigned that way as well.
When you create a new external vSwitch the internet protocols are removed from the adapter and the Hyper-V Extensible Switch protocol is added turning that physical port into a multi-port virtual switch.
--please don't forget to upvote
and Accept as answer
if the reply is helpful--