As mentioned earlier, you will only pay for the actual time spent that your Azure Function runs. The consumption plan is billed per second. Microsoft have a great document on Azure Functions pricing at the following URL:
https://azure.microsoft.com/en-us/pricing/details/functions/.