Azure functions can go idle and restart when they are requested on the consumption plan. DPAPI does not always work after wake. I suspect that the function wakes on a non-windows host which does not have the DPAPI.
Moving away from DPAPI seems like the step to take.