I am disappointed in the migration for Enterprise solution but admit I may be missing something after many google searches and numerous experiments. I can find no end to end solution and thus had to come up with my own workarounds to fix URLS for maps and apps. Here my take away on the Migration of Enterprise, moving from Dev environment to Test/Prod Environment. As with anything do not do any of this code development on anything that you can not afford to loose.
Manually export the maps/apps from Dev and import to Test/Prod, this will retain the item ids and configuration, which is a must. See the resource on moving content across tiered arcgis enterprise environments above.
Run code to fix Map URLs and item ID's.
Run code to fix App URLS, bonus change color of text in title to indicate different environment.
Why not use python to automate the export and import of maps/apps? I was unable to get the api to connect; see https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-group-manager-cr...
Why do you just export maps/apps? The export of feature layers is problematic. It just fails with no error.
The export/import is not supported for "Hosted Views", that is a large portion of our layers. so export/import of data ends up making little sense for us. We can just host it from ArcGIS Pro to different environments, knowing the data will have different ids, this is unavoidable on the Hosted Views.
Why do care about item ids for feature layers in maps? If you do not match the item ids in the portal where you are migrating your maps to, when a user finds the "description" and clicks on it they will end up on the Rest Endpoint of ArcGIS, this is not something I really like. Note, the ArcGIS Assistant does not fix the item id's when you use it to change the URLS, this is something I found out just recently and is problematic.
See attached code for example of how I am making updates to urls in maps and apps.