Introduction to arcpy.sharing

The sharing module allows you to create a sharing draft from a map in an ArcGIS Pro project, which can then be shared to ArcGIS Enterprise, ArcGIS Online, or ArcGIS Server. A sharing draft is a configurable set of properties for a web layer. Creating a sharing draft is the first step in automating the publishing of a map, layer, table, or list of layers and tables to a web layer using Python. The sharing draft can then be saved as a service definition draft (.sddraft) file.

To create the sharing draft for ArcGIS Enterprise or ArcGIS Online, use the getWebLayerSharingDraft function from the Map class.

To create the sharing draft for ArcGIS Server, use the arcpy.sharing.CreateSharingDraft function.

Once the service definition draft has been created, it can then 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. Stage Service 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 ArcGIS Enterprise, a server federated with ArcGIS Enterprise, or ArcGIS Online using the Upload Service Definition tool. When the service is published, a corresponding web layer is automatically created.

The sharing draft classes contain the most common web layer properties. These properties can be edited within 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 service or map image layer. See MapImageSharingDraft and MapServiceDraft for code samples.

Legacy:

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.

arcpy.sharing classes are as follows:

ClassDescription
FeatureSharingDraft

Creates a sharing draft for a web feature layer

TileSharingDraft

Creates a sharing draft for a web tile layer

MapImageSharingDraft

Creates a sharing draft for a map image layer

MapServiceDraft

Creates a sharing draft for a map service