Hello everyone,
I am trying to upload a map service every night, and it was working without any issues until I had to uninstall and reinstall ArcGIS Pro. Since then, the process has been crashing with the following error message:
arcgisscripting.ExecuteError: ERROR 001269: Compressing the service definition failed.
Failed to execute (StageService).
Steps I have tried:
1. Saved the service draft and service with unique names, but the process still failed.
2. Signed into the portal before starting the process, but the same error occurred.
3. Tried publishing the service directly from ArcGIS Pro, and it worked successfully.
4. Created the .sddraft file from ArcGIS Pro and then used it in a Python script, but it failed with the same error.
I took help from the documentation:
https://pro.arcgis.com/en/pro-app/3.4/arcpy/sharing/mapimagesharingdraft-class.htm
Here is my code:
import arcpy
import os
# Sign in to portal
arcpy.SignInToPortal("xyzxyzxyzxyzxyz",
"xyzxyzxyzxyzx", "xyzxyzxyzxy")
# Set output file names
outdir = r"\\atc-sr-gis01\gis_ssd\Test"
service_name = "BackLayers_Test_New"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"\\atc-sr-gis01\GIS_SSD\ArcGIS_Projects\Web_Editor\BackLayers_Test.aprx")
m = aprx.listMaps('Layers')[0]
# Create MapImageSharingDraft and set metadata, portal folder, and server folder properties
server_type = "FEDERATED_SERVER"
federated_server_url = "xyzxyzxyzxyzxy"
sddraft = m.getWebLayerSharingDraft(server_type, "MAP_IMAGE", service_name)
sddraft.federatedServerUrl = federated_server_url
sddraft.summary = "BackLayers_Test_New"
sddraft.tags = "BackLayers_Test_New"
# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)
# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, federated_server_url)
print("Finish Publishing")
Any insights on this would be greatly appreciated.