Introduction to arcpy.sharing

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. A sharing draft is a configurable set of properties for a web layer or map service.

  • To create the sharing draft for a web layer on ArcGIS Enterprise or ArcGIS Online, use the getWebLayerSharingDraft function from the Map class.

Sharing classes are as follows:

ClassDescription
FeatureSharingDraft

Creates a sharing draft for a hosted web feature layer

TileSharingDraft

Creates a sharing draft for a web tile layer

MapImageSharingDraft

Creates a sharing draft for a map image layer with an optional web feature layer on a federated server

MapServiceDraft

Creates a sharing draft for a map service on a stand-alone server

The sharing draft classes contain the most common web layer and map service properties. Additional properties can be customized 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 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, or MapServiceDraft 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, 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.

Héritage :

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.

Rubriques connexes