I am trying to write a script that creates feature layers in ArcGIS Enterprise based on layers in an ArcGIS Pro Project. I do not want to copy the data to the server, only reference it. The data comes out of a SDE database that is also registered with the respective ArcGIS Server.
While doing the process manually works well (right-click layer --> Share as Weblayer --> Reference registered data), if I try to do the same with Python, I always end up with a hosted feature layer, which means that the data has been copied to the server instead of referencing it.
This is the code I use. Am I missing something?
featDraft = Map.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", "REF_" + service6, layer) featDraft.copyDataToServer = "False" featDraft.description = metadata_description featDraft.allowExporting="True" featDraft.overwriteExistingService="True" featDraft.portalFolder="REF_" + Mapname featDraft.tags=Tags mapDoc.save() featDraft.exportToSDDraft(sddraft_output_filename) # Stage Service sd_filename = service6 + ".sd" sd_output_filename = os.path.join(outdir, sd_filename) arcpy.StageService_server(sddraft_output_filename, sd_output_filename, 5) # Share to portal print("Uploading Service Definition...") arcpy.UploadServiceDefinition_server(sd_output_filename, "My Hosted Services")
Follow up: Putting a arcpy.GetMessages(1) into my code gives me the following error:
WARNING 000710: Unable to connect to the server
I assume that this means that the script is not able to access the database where the data resides to reference it. However, I am not sure where to put this information. Any ideas?