AnsweredAssumed Answered

Publishing web layer in bulk

Question asked by akawamura on Jul 4, 2019
Latest reply on Sep 15, 2019 by akawamura


I am implementing a script to publish web layer in bulk into Enterprise ArcGIS Server v10.7.0 based on below example.


What I am trying is to create a Pro project file which has several maps having multiple feature classes sourced from EGDB, create a script to get all maps and layers in the project file, and publish each of layers as a web layer by reference. Our ArcGIS server is federated.



import arcpy
from arcpy import env
import os

aprxFile = r"pathto\Bulk_Layer_Publishing.aprx"

outDir = r"pathto\Output_sd"


# Reference map to publish
aprx =
for m in aprx.listMaps('*'):

    print("Map: " +
    serverFolder =


    serviceDirName = "{}\\{}".format(outDir,
    if not os.path.exists(serviceDirName):

    for lyr in m.listLayers():
        service_name =

        sddraft_filename = "{}\\{}".format(serviceDirName, service_name + ".sddraft")
        # Create MapServiceDraft and set service properties
        sharing_draft = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', service_name, lyr)
        targetServer = r"pathTo\MyArcGIS.ags"
        sharing_draft.targetServer = targetServer
        sharing_draft.serverFolder = serverFolder # same as Map name
       sharing_draft.copyDataToServer = False




Error: Target server is not a standalone server or is inaccessible.

Traceback (most recent call last):
File "<string>", line 45, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\", line 91, in exportToSDDraft
return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))
ValueError: Target server is not a standalone server or is inaccessible.


Could anyone advise me what's wrong with my code??