Select to view content in your preferred language

Trying to upload Map Service to Federated Portal using Web Layer Sharing Draft method

50
1
6 hours ago
Labels (1)
PrayagShah
Occasional Contributor

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. 

 

0 Kudos
1 Reply
VenkataKondepati
Regular Contributor

For ERROR 001269 (Compressing the service definition failed) after a Pro reinstall, it’s usually one of these:

  1. Path/permissions issue on the output folder
    Staging is writing temp + compressing. UNC paths sometimes fail depending on your Pro / service account context. Try staging to a local folder (e.g., C:\temp\publish\) and then copy/upload.

  2. Corrupt temp/caches after reinstall
    Clear Pro + ArcPy staging caches:

  • Delete contents of %TEMP%

  • Also check Pro sharing scratch (often under your user profile).

  1. Mixed Pro/ArcPy environment or missing components
    After reinstall, the ArcGIS Pro Python environment can be out of sync. Confirm you’re running the script with the Pro conda env (arcgispro-py3) that matches the installed Pro version.

  2. Wrong upload target / inconsistent server URL
    For federated publishing, UploadServiceDefinition typically expects the hosting server admin endpoint or a proper connection. Easiest: publish to PORTAL target instead of direct server URL.

Quick clean fix (most reliable):

  • Stage locally

  • Upload using the portal target

  • Avoid UNC for staging

Minimal change to test:

outdir = r"C:\temp\publish"
arcpy.env.scratchWorkspace = outdir
arcpy.env.workspace = outdir

# Stage locally
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Upload to portal (recommended for hosted/federated)
arcpy.server.UploadServiceDefinition(sd_output_filename, "HOSTING_SERVER")

 

If that works, the root cause is almost always UNC/temp/permissions. If it still fails, check the StageService messages in arcpy.GetMessages(2) and your Pro install logs.

– Venkat

 

0 Kudos