I've created a Script Tool in ArcPro 2.5 that uses the Python API to manage hosted layers. It is not passing the Analyze step in the Web Tool publishing workflow to publish to Portal 10.8. The line where the GIS is being declared is causing a broken project data source error. This is a real bummer. I think I have to scrap this entire model. It is simple, but very critical for copying an empty hosted layer in Portal to a new service for a user to edit in a web app.
I've decided to go with a server side python web deployment. I am wondering if there is a way to register the portal somehow for this to work in a web tool. I've not found any documentation stating either way. I was thinking the federation would be registering a connection, but perhaps its just not supported to begin with?
Have you succeeded with publishing your workflow to portal? Can you describe your workaround? I have run into the same issue lately.
Using a restAPI python server app, makes a request to a url and runs python api code to create a new service and layer from an empty hosted feature layer in Portal, then passes the url of the new layer back to the client so it can be edited.
To create the new hosted feature layer from an existing empty hosted feature layer I am using
target_item = template_layer.copy_feature_layer_collection(layout_name, layers=layer_index, description="New Layer Created From Template", owner=target_user.username)
I've not attempted this as a GP Service / WebTool again recently though to see if this data type is supported. It is something I will be testing again soon though.
I've recently found that the Web Tools published from ArcPro 2.7.1 do allow the GIS object to be created. This might work with previous versions as well.
The trick is that the Portal URL has to be provided as a user parameter to the script tool. Otherwise, the Analyze step fails with a broken Project Data Source if the Portal URL is hardcoded.
This is a game changer.