Did you manage to run and deploy that code?
you may need this line:
The rest is more a question for the Power Platform forums to help:
https://powerusers.microsoft.com/t5/Power-Apps-Community/ct-p/PowerApps1
This post suggests "registering a custom API in PowerApps" but I couldn't find it anymore. That post also seems pretty old:
https://powerapps.microsoft.com/nl-be/blog/using-azure-functions-in-powerapps/
Most other sites suggest using power automate to invoke the azure function and call the power automate in the canvas app. For that you can use the Http task
Than add the power automate to the app: