The arcpy.sharing module can be used to share web layers using Python.
What is 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 either ArcGIS Enterprise or ArcGIS Online. A sharing draft is a configurable set of properties for a web layer. To create the sharing draft, use the getWebLayerSharingDraft function from the map class. Creating a sharing draft is the first step to automate 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.
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. 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. Any advanced web layer properties can be set by modifying the service definition draft using third-party XML libraries, such as the xml.dom.mindom standard Python library. See MapImageSharingDraft for a code sample.
To create the service definition draft, you must be signed in to a portal. Your portal can be either ArcGIS Enterprise or ArcGIS Online. Portal information is obtained from the Portals page in ArcGIS Pro. To add, set, or edit portal connections, see Manage portal connections. The arcpy SignInToPortal function also allows you to sign in to a portal.
Ältere Versionen: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 continuing backward compatibility.
Arcpy.sharing classes are as follows: