I want to publish my maps on sever manager.

My map data is in PostgreSQL and I want to connect it without using ArcGIS Desktop.

Is there any possibility to publish service without involving ArcGIS Desktop?

2 Answers 2


You can use the arcpy.mapping module in Python to do this without launching Desktop using the CreateMapSDDraft and StageService and UploadServiceDefinintion functions.

Code will look something like this:

import arcpy
mxd = arcpy.mapping.MapDocument(<mxd>)
sddraft= <string representing path and name of sddraft>
service = <service name>
con = <path to server connection file (.ags)>
folder = <string representing where you want to publish the SD draft (default is root)>
sd = <path and name of of output service definition>

arcpy.mapping.CreateMapSDDraft(mxd,sddraft,service,"ARCGIS_SERVER",con,False, Folder)
 del mxd

arcpy.StageService_server(sddraft, sd)
arcpy.UploadServiceDefinition_server(sd, con)

Additionally, you can include arcpy.mapping.AnalyzeForSD(sddraft) with an if/else statement to analyze your service definition prior to publishing and publish the service if no errors are found.

analysis = arcpy.mapping.AnalyzeForSD(sddraft)
if analysis['errors'] == {}:
        # Execute StageService
        arcpy.StageService_server(sddraft, sd)
        # Execute UploadServiceDefinition
        arcpy.UploadServiceDefinition_server(sd, con)
        print (".....Map Service Created")
        # If the sddraft analysis contained errors, display them
        print ("Service could not be published because errors were found during analysis.")

This does require having an ArcMap and ArcGIS for Server license, however.

  • But my employer is saying that I have to do everything using server and postgre database. I even can't use desktop for making .mxd. Just imagine I do not have arcgis desktop package on my machine. I hope it make sense.
    – Mehreen
    Nov 20, 2015 at 15:59
  • It would help to assign some different tags to your questions if you're not looking for an Arc-Desktop, Arc-Server solution. Your best bet then is an OGC solution (like geoserver) to publish a WMS/WCS service.
    – Jeff May
    Nov 20, 2015 at 16:02
  • sure! please edit my question.
    – Mehreen
    Nov 20, 2015 at 16:04
  • In this case, it may be a duplicate. gis.stackexchange.com/questions/15597/…
    – Jeff May
    Nov 20, 2015 at 16:08
  • It doesn't make sense to publish maps without a map publishing tool. Data in a database is just that -- bits on disk. In order to make maps, the data must be formatted, which in the GIS world means a mapping application. Once the drawing rules are established, those rules can be published to a mapping server. It wold take weeks or months to develop a map in Python that would take minutes to build in Desktop.
    – Vince
    Nov 20, 2015 at 16:53

Take a look at Upload Service Definition (Server) and some of the code samples

  • But using Python window means I am still using ArcGIS Desktop indirectly. Am I right???
    – Mehreen
    Nov 20, 2015 at 15:46
  • How I can make SD file without using ArcGIS Desktop
    – Mehreen
    Nov 20, 2015 at 15:46
  • You don't have to use desktop at all, you can use the code in an IDE for isntance. Same with the create SD file code from your previous question.
    – Maksim
    Nov 20, 2015 at 15:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.