I'm publishing a map service from ArcGIS Pro 2.3 using a Python script. It gets through create a service draft and staging the service with no errors. When uploading the service definition, it succeeds when publishing to the root folder:
arcpy.UploadServiceDefinition_server(sd, arcgis_server)
It fails if I try to publish to a different folder, either creating a new one or using an existing one (made in Server Manager):
arcpy.UploadServiceDefinition_server(sd, arcgis_server, in_folder_type="NEW", in_folder="test_pro")
or
arcpy.UploadServiceDefinition_server(sd, arcgis_server, in_folder_type="EXISTING", in_folder="test_pro")
Each of these fail with an error along the lines of:
Traceback (most recent call last): File "", line 1, in File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\server.py", line 991, in UploadServiceDefinition raise e File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\server.py", line 988, in UploadServiceDefinition retval = convertArcObjectToPythonObject(gp.UploadServiceDefinition_server(*gp_fixargs((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), True))) File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 498, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 001369: Failed to create the service. Failed to execute (Publish Service Definition). Failed. Failed to execute (UploadServiceDefinition).
While I can work with publishing to root for testing purposes, it's not going to be acceptable for production level automation -- our services get organized into a number of directories and never stay in the root. What is causing UploadServiceDefinition_server to fail when I try to specify a target folder as a parameter?