Hi! I have a Map Image Layer (MapServer) stored on our Portal. This needs to update weekly, so I'm trying to figure out how to update this using python. The tool I use to update is called "Overwrite Web Layer". Unfortunately, this is not a geoprocessing tool, so there is no python command.
I've tried exporting map to SD, and then using the SD to overwrite the map image server. That did not work. That code is below.
Any help would be greatly appreciated!
arcpy.server.UploadServiceDefinition(
in_sd_file=r"T:\NRYANGISWKSP\Projects\OpenGov\_FINAL SCRIPT\OpenGov_MAT.sd",
in_server="https://gis.cityofgoosecreek.com/arcgis",
in_service_name="OpenGov_Map_Layers",
in_cluster="",
in_folder_type="FROM_SERVICE_DEFINITION",
in_folder="",
in_startupType="STARTED",
in_override="USE_DEFINITION",
in_my_contents="NO_SHARE_ONLINE",
in_public="PRIVATE",
in_organization="NO_SHARE_ORGANIZATION",
in_groups=None,
in_item_id=None
)
Solved! Go to Solution.
Hey Nryan it would be worth trying the following sample. Let me know if you get stuck with it.
Hope that helps,
Hey Nryan it would be worth trying the following sample. Let me know if you get stuck with it.
Hope that helps,
This worked perfectly, thank you!
Hello, we have this process from saved SD files. I would recommend doing it with the Python API for ArcGIS rather than arcpy, as the code would be more portable since it would not require a license on the agent executing the code unlike arcpy. All the code needed to publish or stop the service is available in the Python API for ArcGIS. For example, we run our code in a DevOps pipeline on dynamically created agents without any Esri products installed locally on the agent.
basically it's just a few lines of code: