Publish custom routing services

Custom routing services are geoprocessing services with custom capabilities. While standard routing services only perform specific network analysis workflows with a default set of options, you can publish a custom routing service if you need additional capabilities or further flexibility in the analysis workflows. For example, you can find a route between two stops and generate an elevation profile for that route or combine multiple different network analysis into a single web service. For such an analysis, you can create a custom routing service. Custom routing services are geoprocessing services with custom capabilities. Geoprocessing services allow you to share custom analysis tools in ArcGIS Server, a component of ArcGIS Enterprise. Geoprocessing services often run as web tools hosted in the ArcGIS Enterprise portal. These tools are authored and run in ArcGIS Pro as a script tool before being shared to a server.

Creating a custom routing service (geoprocessing service) is a three-step process as described in the sections below.

Author a script tool

The first step in creating a custom routing service is to create and document a geoprocessing script tool based on an arcpy and arcpy.nax Python module and write the Python code that will implement the logic to run the script tool. The tool is created in a toolbox.

Learn more about creating a Python script tool using arcpy.nax

Publish service

Once you've authored the tool, run it in ArcGIS Pro to ensure the tool completes successfully. When the tool is finished running, in the geoprocessing history, you can share the result as a web tool from ArcGIS Pro. Sharing creates the geoprocessing service item in the server connection. You can add multiple tools that you've run to the same geoprocessing service during publishing. You can publish geoprocessing service from ArcGIS Pro to a stand-alone server that is not federated with an ArcGIS Enterprise portal using an administrator connection. If you are working with a server site federated with an ArcGIS Enterprise portal, you instead share web tools to your ArcGIS Enterprise portal.

Learn how to publish and use a geoprocessing service in this example

Consume service

Once the geoprocessing service has been published to ArcGIS Server, including when a web tool is shared to a portal with a federated server site, authorized users can access the service directly on the server site using various operations in ArcGIS REST API and work with it in ArcGIS Pro, the Geoprocessing widget in ArcGIS Web AppBuilder, custom web apps with ArcGIS API for JavaScript, and more.


Custom routing service cannot be consumed in ArcGIS Pro through the network analysis ribbon.

Tips for authoring geoprocessing services

To improve the performance of geoprocessing services, consider following the tips below:

  • When defining the network dataset parameter in the script tool, for the data type, use Network Dataset Layer instead of Network Dataset or Network Data Source. Before publishing it as a web tool, run the script tool and provide a network dataset from the map. Because the connection to the network dataset is established once when you start the service, you do not need to open the network dataset with each service request, which saves time.
  • When reading the network dataset parameter in the script tool, use GetParameterAsText method instead of GetParameter method, since GetParameterAsText method provides access to the network dataset layer much faster.
  • Write a geoprocessing script tool using the arcpy.nax Python module. This results in faster run times as compared to the services created from the geoprocessing model tool or services created from a script tool using using the layer based workflow.
  • When defining the feature input parameter for the script tool, use Feature Set data type. When you use the feature set and set default to a layer file, the layer file internally references the feature class that defines the schema for the feature set. When the service is published, there is a well-defined schema for the output.
  • Write outputs to a memory-based workspace instead of a file geodatabase.
  • Avoid writing too many messages from the script tool.
  • When sharing the analysis result as a web tool or geoprocessing service, set the input mode for network dataset parameter to constant. Since the service always uses the same network dataset, setting the network dataset as constant ensures that it is not available on the resulting service created by the tool.
  • Select the synchronous mode for short-running requests for best performance.
  • If you select the synchronous mode for the geoprocessing service, you can further improve the geoprocessing service performance by setting reusejobdir property to true. Be mindful of the constraints when setting this property though, since setting reusejobdir to true will use the same job folder for each job. Therefore, if you are writing outputs into the job directory, you must ensure that the outputs have unique name in each run so they are not impacting each other.