How to add Material Functions to Material programatically

How to add Material Functions to Material programatically
Obviously I mean UMaterialFunction into UMaterial.

I have a pointer to both but cannot figure how to add the function to the material itself, of course I’ve set:

UnrealMaterial->bUseMaterialAttributes = true;

before trying to add the functions