The Sharing module, arcpy.sharing, is a Python module that allows you to automate your sharing workflows. Use it to create a sharing draft from a map in an ArcGIS Pro project, which is the first step in automating the sharing of a web layer or map service to ArcGIS Enterprise, ArcGIS Online, or ArcGIS Server. You can also create a sharing draft for a web tool or geoprocessing service. A sharing draft is a configurable set of properties for a web layer, web tool, map service, or geoprocessing service.
- To create the sharing draft for a web layer on ArcGIS Enterprise or ArcGIS Online, use the getWebLayerSharingDraft function from the Map class.
To create the sharing draft for a web tool on an ArcGIS Enterprise portal, or a map service or geoprocessing service on a stand-alone ArcGIS Server site, use the CreateSharingDraft function.
Sharing classes are as follows:
Creates a sharing draft for a hosted web feature layer
Creates a sharing draft for a web tool on an ArcGIS Enterprise portal or a geoprocessing service on a stand-alone server
Creates a sharing draft for a map image layer with an optional web feature layer on a federated server
Creates a sharing draft for a map service on a stand-alone server
Creates a sharing draft for a web tile layer
The sharing draft classes contain the most common web layer, web tool, map service, and geoprocessing service properties. Additional properties can be customized in the service definition draft file using standard third-party XML editors or modified using XML Python libraries such as the xml.dom.minidom library. For example, feature access can be enabled on a map image layer or map service. See MapImageSharingDraft and MapServiceDraft for code samples.
After the sharing draft has been configured, it can be saved to a service definition draft (.sddraft) file using the exportToSDDraft function from either the FeatureSharingDraft, TileSharingDraft, MapImageSharingDraft, MapServiceDraft, or GeoprocessingSharingDraft classes.
Once the service definition draft has been created, it can be converted to a fully consolidated service definition (.sd) file using the Stage Service tool. Staging compiles all the necessary information needed to successfully publish the GIS resource. The Stage Service tool will also analyze service definition draft files to determine suitability and sources of potential performance issues before converting a service definition draft file to a service definition file.
Finally, the service definition file can be uploaded and published as a GIS service to a server federated with ArcGIS Enterprise, a stand-alone ArcGIS Server site, or ArcGIS Online using the Upload Service Definition tool. When the service is published to ArcGIS Enterprise or ArcGIS Online, a corresponding web layer is automatically created.
The arcpy.sharing module was introduced at ArcGIS Pro 2.2 to provide a better experience when sharing web layers over the previously existing function, CreateWebLayerSDDraft. The original function is provided only for backward compatibility.