We're trying to script publishing feature services that reference our sde data to a server federated to Portal.
I've had success using getWebLayerSharingDraft to publish a MapImage service to the federated server which seems to reference our sde data, and I've had success publishing a Feature Service but it only seems to publish to the HOSTING_SERVER which makes me think it is being stored in the Data Store associated with the Federated Server and thus is only a copy of our sde data.
If you look at the guts of _mp.py for getWebLayerSharingDraft you'll see that FEDERATED_SERVER is only compatible with MAP_IMAGE and that FEATURE is only compatible with MY_HOSTED_SERVICES or HOSTING_SERVER.
I've tried to go the route of using CreateSharingDraft but that only seems to be able to access a standalone_server and not a federated server.
Has anyone had any luck?
I am having the same problem. Have you found a solution yet?
Unfortunately, I have not.
I seem to be having the same problem. Are you getting and error?
Here is what I see..
File "C:/batch/Publish_Service.py", line 359, in <module>
sharing_draft.exportToSDDraft(sddraft_output_filename)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py", line 66, in exportToSDDraft
return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))
ValueError: Unable to create the manifest (sddraft file). An unspecified error occurred.
Have you found a solution to this problem and remember it?
I am getting the same output
I am having the same issue when trying to overwrite a hosted Map Image Service; it is tripping up on the function to export the draft Service Definition (see error output below). I've confirmed the server is of type 'FEDERATED_SERVER'.
Has anyone else found a solution or workaround?
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py", line 66, in exportToSDDraft
return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))
ValueError: Target server is not a federated server or is inaccessible.
I resolved my problem which was due to my using the server URL reported by listing the servers after connecting to the portal:
print("Connecting to {}".format(portal))
gis = GIS(portal, user, password)
server = gis.admin.servers.list()[0]
The URL reported in the 'server' variable had appended the server manager designation to the URL - once this was removed it was fine.
Near always it is the simplest things over which we trip...*sigh*
I know this post is old, but here's a script from ESRI that's supposed to do this:
https://github.com/jnshill/ArcPyPublishing/blob/master/PublishLayersAsMIL_FA_Timezone.py
I've been trying to do what you say you've accomplished. I'd appreciate a share there 🙂
You need to publish a map image layer with an associated feature layer to reference registered data. Here's a sample: https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/mapimagesharingdraft-class.htm#GUID-98B8320E-...