João Ramos, Thank you for posting this question on Microsoft Q&A.
Based on the error as available in the attached email,
Get-MgDomain is not being recognized as an available cmdlet. Based on the doc here, it is available in Microsoft.Graph.Identity.DirectoryManagement module.
I would suggest importing the following modules to Azure Automation from gallery to ensure that the module is available for the cmdlet to run.
Hope this helps.
If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.