Is it possible to create a new service definition file from an existing ArcGIS service?

I have a python script that updates data on a daily basis. I have figured out how to restart/overwrite my existing service so that it will represent the change in the data. However doing so uses the default settings for the new service.

If possible, I would like to create a new service definition file from an existing service so that I do not have to go back manually and change the following parameters and capabilities:

Max # of Records Returned by Server, Lock Database, Max # of instances per machine,

Any advice would be great. Thanks

Here is the solution:

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

    # 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)
  • What version you are on? – Alex Tereshenkov Jan 20 '14 at 18:15
  • Sorry, I'm using ArcGIS Server 10.2. – George Jan 20 '14 at 18:33

You have several options:

  1. Go to the \%server%\arcgisserver\directories\arcgissystem\arcgisinput\%ServiceName%.MapServer\extracted\v101 and open the .mxd document which will allow you to save a new .sd file for re-use.

  2. Use Python or any scripting language of your choice to modify properties of an existing service. This is done by using ArcGIS REST Administrator API. Here is the sample for modifying properties of an existing service. I use it almost daily and it is very easy to write a script altering properties as needed. This is much more efficient imo than creating a service again from .sd.

  3. Publish a service with the required properties directly set by using ArcGIS REST Administrator API and ArcPy. In this case, you will be able to specify the advanced settings in advance. Again, refer to the samples from 2. above to get started.

  • #3 appears to be what I am looking for. I'll look it over and let you know if it works out for me. (AKA: If I can figure it out on my own...) – George Jan 20 '14 at 20:59
  • Alex, you mentioned that you use similar script on a regular basis. Using the examples you sent me I have been able to edit the min/max # of instances, however I cannot seem to get the Maximum Number of Records Returned by Server to change. From what I gather, the JSON variable should be maxRecordCount. I've tried this both as string and integer with no success. Any extra pointers? – George Jan 20 '14 at 23:00
  • You see, the maxRecordCount is not under Service Properties (check the web page server:6080/arcgis/admin/services/service.MapServer). It is under Properties, that is why you cannot do as in this example: resources.arcgis.com/en/help/main/10.2/index.html#/…. You need to work with another dictionary: dataObj = json.loads(data) >> newdict = dataObj["properties"] >> newdict["maxRecordCount"] = 444 >> updatedSvcJson = json.dumps(dataObj). Start a new question if any problem remains, easier for me to paste the code. – Alex Tereshenkov Jan 21 '14 at 9:40
  • Ok. I will give it a try. Your #2 and/or #3 options should help me answer my initial question. I'll start another post to drill down a more specific question regarding the maxRecordCount if needed. – George Jan 21 '14 at 15:59
  • FYI, adding the following code as Alex mentioned worked: – George Jan 21 '14 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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