Hey @JakeSkinner,
I made a script for the publication of feature services from Arcgis pro to Online. but what i did is publish all the layers separately, each layer has its own service. to do this i used a loop, now i want to update the layers i had posted, if you have any idea how to do it please !
This is the script that i used :
import arcpy
import os
# Sign in to portal
arcpy.SignInToPortal('https://.arcgis.com', 'UserName', 'Password')
in_server = "https://*********.fr/server/"
# Set output file names
outdir = r"F:\Projet_ArcGisPro\TEST\Output"
# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"F:\Projet_ArcGisPro\TEST\TEST.aprx")
m = aprx.listMaps()[0]
lyrs = m.listLayers()
for lyr in lyrs:
service = lyr.name
sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service, lyr)
sharing_draft.summary = lyr.name
sharing_draft.tags = lyr.name
sharing_draft.description = lyr.name
sharing_draft.credits = lyr.name
sharing_draft.useLimitations = lyr.name
sharing_draft.portalFolder = "SERVICES_OpenData"
print(service)
sddraft_filename = service + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
# Create Service Definition Draft file
sharing_draft.exportToSDDraft(sddraft_output_filename)
# Stage Service
sd_filename = service + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
# Share to portal
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(sd_output_filename, in_server,"","","","","","","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION")
print("Successfully Uploaded service.")
Thank you for your help 🙂