When using a derivative of the template map service publishing examples given in many places throughout ESRI documentation, I have the following working (I've stripped this down significantly)...
# set up a number of parameter for SD Draft generation # shortened for illustration sharing_draft = m.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE", service) sharing_draft.federatedServerUrl = <federatedServerUrl> ... # Create SD Draft files sharing_draft.exportToSDDraft(sddraft_output_filename) .. arcpy.StageService_server(sddraft_output_filename, sd_output_filename) ... # set up a number of parameter for SD Draft # shortened for illustration inSdFile = sd_output_filename inServer = <serverUrl> inServiceName = <service name> ... arcpy.UploadServiceDefinition_server(inSdFile, inServer, inServiceName, ...)
What exactly is the difference - if any - between what I am referring to here as >federatedServerUrl. and <serverUrl>? And what exactly is the format of the URL expected here? I have it working in one environment and am using the exact same string (URL) for both variables. In another environment, the same code fails with
ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Please refer to the error help for potential solutions, or contact Esri Technical Support http://esriurl.com/support. Failed to execute (StageService).
The only difference is that I'm using a different URL but the same one in both places. It's a valid URL that mimics the first environment's URL and includes the webadaptor name. It successfully created the SD Draft file. So the URL seems to work fine for that steps.
Very frustrating. I have used this a bunch of times in both environments and now it fails.
I think and according to the documentation inServer (line 14 in your code above) should be the path to an ArcGIS Server connection created through ArcCatalog/ArcMap/Pro.
"You can use ArcGIS for Server connections listed under the GIS Servers node in the Catalog window, or you can navigate to a different folder where you might have server connection files stored.
If you are connecting to ArcGIS Online, make sure you type My Hosted Services for the server connection with each word capitalized and a space between each word."
...I believe the correct format for the federatedServerURL parameter is: https://server.domain.com/webadaptor
I don't think that's correct. You can use a URL for your REST endpoint or some web adaptor alias for it as your server reference. I have that working in one environment. I'm not saying using an AGS connection file won't work but it's just another way of accomplishing that.