DSC does not locate/load module it needs as part of a configuration

Can someone please help me with the following issue

I am using DSC in Azure (Azure Automation DSC)

I receive the following error message,

PowerShell DSC resource MSFT_ScriptResource failed to execute Get-TargetResource functionality
with error message: The term ‘MyFunction’ is not recognized as the name of a cmdlet, function, script file, or
operable program.

Here is the background

function MyFunction {

#code here ......

}
Export-ModuleMember -Function MyFunction

I saved the above as a .PSM1 and imported to Azure Automation (to the Modules section)
I see the module in Azure Automation and when I click on it I can see the MyFunction ‘activity’ so all looks good

I then do the following in my DSC

Configuration MyConfig {

Import-DSCResource -ModuleName MyFunction

Script MyScript {
getScript = {code here}

test-Script = {
code .....
$X = MyFunction
code...
}

setScript = {coe here}

}

So basically I am calling MyFunction (which shows as an ‘activity’ when looking at the module in the modules section of azure automation). However it cannot be found hence the message at the top of this post

However I receive the error that the MyFunction is

Do you know what I am doing wrong here please? am I missing a step, do I need to do something else?

Thanks

CXMelga