I had the exact same issue. The sddraft was created on disk but the stageservice function failed. I believe the error lies in that the path names need to be complete and with double forward slashes for that function to work. I made a model in desktop using the stageservice tool (which required my sddraft) and then the upload service definition tool, exported that to python to see the working syntax, and embedded into my code. Here is the working function that makes a service draft, stages, and uploads it. def createDraftSDandPublishService(): # mxd and connection to server mapDoc = arcpy.mapping.MapDocument('Incidents.mxd') serverConnectionInDesktop = 'GIS Servers\\arcgis on Server1' #service draft staging location sddraft = "C:\\databaseimport\\Incidents.sddraft" sd = "C:\\databaseimport\\Incidents.sd" #publishing options existingServerFolder = "Services_1505" copyData = 'True' #metadata for service serviceName = 'Incidents' tags = 'incidents' summary = 'Incident test' print("start") print("create sddraft....") # create service definition draft analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, serviceName, 'ARCGIS_SERVER', serverConnectionInDesktop, copyData, None, summary, tags) # stage and upload the service if the sddraft analysis did not contain errors if analysis['errors'] == {}: print("no errors") # Execute StageService print("staging....") # Process: Stage Service arcpy.StageService_server(sddraft, sd) print("uploading....") # Process: Upload Service Definition arcpy.UploadServiceDefinition_server(sd, serverConnectionInDesktop, serviceName, "", "EXISTING", existingServerFolder, "STARTED", "USE_DEFINITION", "NO_SHARE_ONLINE", "PRIVATE", "NO_SHARE_ORGANIZATION", "") else: print("errors") # if the sddraft analysis contained errors, display them print analysis['errors']
... View more