<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Automate Overwrite Web Layer to Publish Map Image Layer in Publishing and Managing Services Questions</title>
    <link>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621215#M1399</link>
    <description>&lt;P&gt;Hey Nryan it would be worth trying the following &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/mapimagesharingdraft-class.htm#:~:text=Finish%20Publishing%22)-,Overwrite%20a%20map%20image%20layer,-The%20following%20script" target="_self"&gt;sample&lt;/A&gt;. Let me know if you get stuck with it.&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jun 2025 15:59:15 GMT</pubDate>
    <dc:creator>David_McRitchie</dc:creator>
    <dc:date>2025-06-05T15:59:15Z</dc:date>
    <item>
      <title>How to Automate Overwrite Web Layer to Publish Map Image Layer</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621200#M1398</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tool.png" style="width: 594px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/133842i4C2900706AA51D88/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tool.png" alt="Tool.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 15:42:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621200#M1398</guid>
      <dc:creator>Nryan</dc:creator>
      <dc:date>2025-06-05T15:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Automate Overwrite Web Layer to Publish Map Image Layer</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621215#M1399</link>
      <description>&lt;P&gt;Hey Nryan it would be worth trying the following &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/mapimagesharingdraft-class.htm#:~:text=Finish%20Publishing%22)-,Overwrite%20a%20map%20image%20layer,-The%20following%20script" target="_self"&gt;sample&lt;/A&gt;. Let me know if you get stuck with it.&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 15:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621215#M1399</guid>
      <dc:creator>David_McRitchie</dc:creator>
      <dc:date>2025-06-05T15:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Automate Overwrite Web Layer to Publish Map Image Layer</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621287#M1400</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;basically it's just a few lines of code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; arcgis.gis &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; GIS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; arcgis.gis.server &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; Server&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;gis&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; GIS(&lt;/SPAN&gt;&lt;SPAN&gt;url&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;urlPortal&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;username&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;username&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;password&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;password&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;serverManager&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;gis&lt;/SPAN&gt;&lt;SPAN&gt;.admin.servers&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;federatedServer&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;next&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;serveur&lt;/SPAN&gt; &lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;serveur&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;serverManager&lt;/SPAN&gt;&lt;SPAN&gt;.list() &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt; &lt;SPAN&gt;serveur&lt;/SPAN&gt;&lt;SPAN&gt;.url &lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt; &lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;urlFederated&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/admin'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;succes&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;federatedServer&lt;/SPAN&gt;&lt;SPAN&gt;.publish_sd(&lt;/SPAN&gt;&lt;SPAN&gt;sd_file&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;sdFilePath&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;folder&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;serviceFolder&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 18:27:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621287#M1400</guid>
      <dc:creator>SimonP</dc:creator>
      <dc:date>2025-06-05T18:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Automate Overwrite Web Layer to Publish Map Image Layer</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621289#M1401</link>
      <description>&lt;P&gt;This worked perfectly, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 18:29:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/how-to-automate-overwrite-web-layer-to-publish-map/m-p/1621289#M1401</guid>
      <dc:creator>Nryan</dc:creator>
      <dc:date>2025-06-05T18:29:17Z</dc:date>
    </item>
  </channel>
</rss>

