Thank you for asking this question on the **Microsoft Q&A Platform. **
Assuming that the Azure Function is in the same virtual network as the VM (If not check this documentation https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-vnet)
The reason is that the Function App does not have permission to access the VM,
A way to authenticate is via Automation Account https://serverfault.com/questions/893506/how-to-log-in-to-azure-vm-automatically-from-azure-function
Depending on the language that you are using in your Function you can authenticate in your VM in diverse ways
Hope this helps!
----------
Accept Answer and Upvote, if any of the above helped, this thread can help others in the community looking for remediation for similar issues.
NOTE: To answer you as quickly as possible, please mention me in your reply.