I have a script to overwrite an existing locator service, in a standalone ArcGIS Server (10.9.1) The code was originally shared by ArcGIS Geocoding Team here
I'm getting the following error when creating the sd draft file
I already checked and all my paths are correct. Any ideas?
import arcpy
import pprint
from arcgis.gis import server
## Sign in to server
# this connects to a standalone server that has web adaptor installed
EGServer = server.Server(url=f"https://arcgis:6443/arcgis/admin", username, password)
print(' Connected to server')
# Overwrite any existing outputs
arcpy.env.overwriteOutput = True
locator_path = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch"
sdDraft ="\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch\\ElasticSearchLocator.sddraft"
sd_file = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch\\ElasticSearchLocator.sd"
service_name = "ElasticSearchLocator"
summary = "Locator for EnerGov's elastic search"
tags = "EnerGov, locator, elastic search"
## server_connection_file has agssite login
server_connection_file = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\admin on arcgis_6443.ags"
# Create the sd draft file
analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sdDraft, service_name,
server_connection_file, copy_data_to_server=True, summary=summary,
tags=tags, max_result_size=20,max_batch_size=500,
suggested_batch_size=150, overwrite_existing_service=True)
print("Creating SD Draft file")
print(arcpy.GetMessages())
## Stage and upload the service if the sddraft analysis did not contain errors
if analyze_messages['errors'] == {}:
try:
# Execute StageService to convert sddraft file to a service definition
# (sd) file
arcpy.StageService_server(sdDraft, sd_file)
# Execute UploadServiceDefinition to publish the service definition
# file as a service
arcpy.UploadServiceDefinition_server(sd_file, EGServer)
print("The geocode service was successfully published")
except arcpy.ExecuteError:
print("An error occurred")
print(arcpy.GetMessages(2))
else:
## If the sddraft analysis contained errors, display them
print("Error were returned when creating service definition draft")
pprint.pprint(analyze_messages['errors'], indent=2)
Solved! Go to Solution.
At 10.9.1 (ArcGIS Server) you don't need to republish the locator service. The script only needs to stop the service, rebuild the locator and start the service.
Was the address locator created with the CreateAddress Locator (ArcMap) tool or Create Locator (Pro) tool?
Can you try having everything local (instead of network share) as a test to see if the script runs?
The locator was created using the Create Locator (Pro) tool.
Changing everything to my local machine gives me the same value error showing the local path.
Is the script in this link the same as yours?
If so, how do the input parameters look compared to yours?
Yes, the only difference is that I don't have portal setup, so I'm connecting to the server to upload the service.
I am getting this same error, did you find the solution?
No, no solution yet.
A couple of ideas...
At 10.9.1 (ArcGIS Server) you don't need to republish the locator service. The script only needs to stop the service, rebuild the locator and start the service.
Thanks for this info @AliciaShyu I am curious though, what is the source of your locators?
In our situation, they are file based locators and published to servers so not sure how a script stopping/starting the service would even have access to the published locator unless the server resource directory is shared.