Specifying map service parameters when publishing with ArcPy?

In addition to modifying the values "after" you publish per Alex, you can modify the values before publishing by opening up the SDDraft and modifying the XML. (not using arcpy, but xml manipulation through built in Python libraries)

There are a ton of samples here at the bottom of the page. I dont think there is one that does exactly what you want, but its not a far leap to modify them to suit your needs.


No, there are currently not. You cannot edit these default settings while publishing the service using ArcPy; you can do this only afterwards with pure Python. The workflow for this would consist of two steps.

  1. Publish a service with default settings using ArcPy.
  2. Modify the service properties using pure Python.

To modify the service properties, refer to the Esri Help which has some ready-to-use examples. An example that would change #instances would include this code snippet (see my comments here):

# Deserialize response into Python object
dataObj = json.loads(data)
httpConn.close()

# Edit desired properties of the service
dataObj["minInstancesPerNode"] = 1
dataObj["maxInstancesPerNode"] = 10

newdict = dataObj["properties"]
newdict["maxRecordCount"] = 5000

# Serialize back into JSON
updatedSvcJson = json.dumps(dataObj)

If you want to do this in one operation format, use pure Python then directly from the beginning: look for this example here (you would need to prepare a huge JSON file with all the settings you need forehand):

Example: Publish a service with detailed parameters