Many sharing workflows can be automated with Python by using ArcPy functions and classes in the Sharing module and geoprocessing tools in the Publishing, Caching, and Package toolsets. You can turn Python scripts into script tools, which you can open from the Catalog and Geoprocessing panes and run as custom geoprocessing tools. Script tools can also be used in ModelBuilder models, used in the Python window, or called from another script. The workflows in each section below use different ArcPy modules, functions, classes, and geoprocessing tools.
Automate sharing web layers
Automate sharing packages
You can automate creating packages using geoprocessing tools in the Package toolset and sharing them to a portal using the Share Package tool. Additionally, you can use the Share Package tool to publish tile packages, vector tile packages, or scene layer packages as web layers to ArcGIS Online or ArcGIS Enterprise.
Automate sharing a locator
Automate sharing a web tool
Automate publishing services to a stand-alone server
You can automate publishing and updating services with Python using a combination of ArcPy functions and geoprocessing tools in the Publishing toolset.