I have a script to publish data from an SDE to ArcGIS Enterprise. The script will enable feature access in the SD draft before publishing. I'm looking for some guidance or examples on how to also change the Instance Type to Dedicated and set the min/max # of instances. The script I have defaults the services to Shared Instance.
'''Modify the .sddraft file to enable overwriting services'''
# Read the file
doc = DOM.parse(sddraft_output_filename)
# Enable overwrite existing service
tagsType = doc.getElementsByTagName('Type')
for tagType in tagsType:
if tagType.parentNode.tagName == 'SVCManifest':
if tagType.hasChildNodes():
tagType.firstChild.data = 'esriServiceDefinitionType_Replacement'
'''Modify the .sddraft file to enable feature access'''
# Find all elements named TypeName
# This is where the addition layers and capabilities are defined
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
# Get the TypeName to enable
if typeName.firstChild.data == 'FeatureServer':
extension = typeName.parentNode
for extElement in extension.childNodes:
# Enable feature access
if extElement.tagName == 'Enabled':
extElement.firstChild.data = 'true'
# Get all the value tags.
values = doc.getElementsByTagName('Value')
for value in values:
if value.hasChildNodes():
# Change the default WebCapabilities from 'Query,Create,Update,Delete,Uploads,Editing' to just 'Query'.
if value.firstChild.data == 'Query,Create,Update,Delete,Uploads,Editing':
value.firstChild.data = 'Query,Create,Update,Delete'
Solved! Go to Solution.
@DonMorrison1 Thanks for the response. I do actually have a script to change the instance type to dedicated and set the min/min instances after a service is published. FYI you can change the Instance Type from
https://<services-url>/<folder>/<serviceName.serviceType>/changeProvider
Use 'ArcObjects11' for Dedicated and 'DMaps' for Shared
In terms of setting the service to Dedicated with the Min/Max before publishing, I think I have that figured out now.
keys = doc.getElementsByTagName('Key')
for key in keys:
k = key.firstChild.data
v = key.nextSibling.firstChild
if k == 'MinInstances':
v.data = 0 # min instance
elif k == 'MaxInstances':
v.data = 1 # max instance
elif k == 'provider':
v.data = 'ArcObjects11' # Dedicated Instance
The way I was able change the min and max instances was using the REST API after the publish is complete. I call "https://<services-url>/<folder>/<serviceName.serviceType>" to get the JSON definition of the service, edit the JSON, then call "https://<services-url>/<folder>/<serviceName.serviceType>/edit" to send it back. There is probably an easier way... I'm not sure about the instance type.
@DonMorrison1 Thanks for the response. I do actually have a script to change the instance type to dedicated and set the min/min instances after a service is published. FYI you can change the Instance Type from
https://<services-url>/<folder>/<serviceName.serviceType>/changeProvider
Use 'ArcObjects11' for Dedicated and 'DMaps' for Shared
In terms of setting the service to Dedicated with the Min/Max before publishing, I think I have that figured out now.
keys = doc.getElementsByTagName('Key')
for key in keys:
k = key.firstChild.data
v = key.nextSibling.firstChild
if k == 'MinInstances':
v.data = 0 # min instance
elif k == 'MaxInstances':
v.data = 1 # max instance
elif k == 'provider':
v.data = 'ArcObjects11' # Dedicated Instance
Very good. If I recall correctly, I opted for the JSON route only because the python code seemed simpler doing the updates that way versus navigating through the dom.