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
- arcpy.mapping.CreateMapSDDraft
- Update sddraft file to allow replacement (overwriting the published feature service if already existing)
- arcpy.StageService_server
- arcpy.SignInToPortal_server
- 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').