Just finishing up setting up a new instance of Microsoft Portals for Dynamics 365 I wanted to jot down a couple things to remember for the future if I'm setting up a custom domain (which of course why wouldn't you!)
You do this from the Portal Admin page which you can get to via the Admin Center by selecting the instance, then selecting the Applications tab, and then selecting the portal instance to configure
You must configure a cname from your domain URL of choice to the URL for the portal. Best to do this, get a cup of coffee and then come back and try to add it to the portal page. On the page when you add it, there is a verification query done on the DNS. I found it to be very inconsistent with how quickly it found the changes.
Portals only let you configure one URL, so if you want www.mydomain.com and mydomain.com, you can't just add both with cnames to the portal because only one of them can be mapped and the one that isn't mapped in the portal admin page will get a 404 error page. Best I found to work around this is create the primary e.g. www.mydomain.com as a cname to your portal, configure that in the portal admin page. Then in your DNS, I used the URL forward feature of our provider to redirect mydomain.com to www.mydomain.com. This gets around the lack of support for multiple URLs.
Now you are all excited and try to hit your page, it gives a nice server certificate warning (ok it isn't nice at all people hitting your page will think you've been hacked or are trying to hack them) This is because despite the portals knowing you haven't configured an SSL certificate it still hits the https (SSL) URL. To be fair if you follow the instructions here it does say "you will need an SSL certificate in order to set up a custom host name" - it just leaves out the doom and gloom of the page that will be shown if you don't! So the best thing to do is get your certificate before you even begin the process so you can upload it and set the bindings right after you do the setting of the custom domain URL.