Follow these simple steps to convert a domain to a federated domain. Take precaution to run the windows powershell from the desktop shortcut. Right click the desktop shortcut and 'Run as administrator'.
Connect-MsolService -Credential $cred
Convert-MsolDomainToFederated -DomainName xxxx.com -SupportMultipleDomain
In Step 3, if you dont have multiple domains in AD then you can leave out the SupportMultipleDomain switch