Publish geoprocessing services in a Python script

You can write a Python script to run a geoprocessing workflow and publish it as a geoprocessing service. The primary method of running a script is to use ArcPy.

From ArcGIS Pro 3.2 or later, you can also publish a script tool that publishes a different web tool or one of the layers to the same or another ArcGIS Enterprise. Within the script tool, ensure that the script signs into the portal and the script has sufficient publishing permissions.

Once a customized tool is run successfully, use ArcPy functionality to publish it as a geoprocessing service. First, create a service definition draft file using either the GeoProcessingSharingDraft class and CreateSharingDraft, or the CreateGPSDDraft function. Then, create a service definition file using the Stage Service tool, and use the Upload Service Definition tool to complete the publishing process.

The GeoProcessingSharingDraft class and CreateSharingDraft function are only available from ArcGIS Pro 3.0 and later.