Python script using an MXD to publish Map Service

1499
3
11-01-2017 02:09 PM
LarryAdgate
Occasional Contributor

I know this information is out there but I guess I'm not searching for it Correctly:

I'm looking for an example using a python script to publish a map service using an .mxd file.   

Tags (1)
0 Kudos
3 Replies
RebeccaStrauch__GISP
MVP Esteemed Contributor

You might want to look at the ArcGIS Server Administrator toolkit

http://www.arcgis.com/home/item.html?id=12dde73e0e784e47818162b4d41ee340   which has

  ...tools for starting and stopping services, modifying log settings, registering server object extensions (SOEs), and publishing services from service definition files.

old blog  Downloadable tools for ArcGIS Server administration | ArcGIS Blog 

(The tools are a starting point, although you may need to update for your purposes.  For example, I have modified some of the scripts to do things like find running services that use datasource X.gdb  then stop those services, replace the fgdb, then start just those back up (instead of trying to remember which you stopped).    There is a never beta version of those tools..but I don't have the link handy.)

Also check out

CreateMapSDDraft—Help | ArcGIS for Desktop 

PublishMSDToServer—Help | ArcGIS for Desktop 

and some of the related links to get started.

RandyBurton
MVP Regular Contributor

An old question on Geonet:

How to publish a feature service to ArcGIS Online from an mxd USING PYTHON?

Which leads to this blog post (last comment suggests code -on GitHub- can be made to work with 10.5):

Updating your hosted feature service for 10.2

JonathanQuinn
Esri Frequent Contributor

If you want to write your own script, you'll need to use the Create Map SD Draft tool, Stage Service tool, and Upload Service Definition tool.