Use of parameters in UploadServiceDefinition_server tool on ArcGIS Online with ArcPy

Discussion created by alextaochen on Dec 3, 2017
Latest reply on Feb 1, 2019 by sjacksonesriaustralia-com-au-esridist

I would need to automate publishing my mxd to ArcGIS Online as a publicly-accessible feature service. So it will be shared by everyone. I am with ArcGIS 10.1 so I cannot use the MXDToWebMap_server tool as it is only available to ArcGIS 10.3 and above.


I am able to get most of the automation done by following the help document:

ArcGIS Help 10.1  to run the following tools in the correct order

  1. arcpy.mapping.CreateMapSDDraft
  2. Update sddraft file to allow replacement (overwriting the published feature service if already existing)
  3. arcpy.StageService_server
  4. arcpy.SignInToPortal_server
  5. arcpy.UploadServiceDefinition_server


The problem I came across is, the feature service is replaced and the Share properties are changed to prvivate even if I manually set up Shared with Everyone.


The help document does not specify whether and how we can set up the Share properties in the sd file before uploading.


I did find there are a whole bunch of parameters for the arcpy.UploadServiceDefinition_server tool:

UploadServiceDefinition_server (in_sd_file, in_server, {in_service_name}, {in_cluster}, {in_folder_type}, {in_folder}, {in_startupType}, {in_override}, {in_my_contents}, {in_public}, {in_organization}, {in_groups})


I am assuming the {in_public} param is the one I need to use. But I would prefer a working example of use of those parameters in the context of publishing to ArcGIS Online (i.e. 'My Hosted Services').