<?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: Publishing web layer in bulk in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877621#M4990</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get this error when I'm trying to create an SD Draft file in ArcGIS Pro. I want to make an .SD file that I can then publish to our ArcGIS Server 10.6.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I have created a valid .ags file. I can use the paramaters I specify in the .ags file to open the admin page of that server. But it IS a stand alone ArcGIS Server....NOT a federated server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error in "sharing.py" at line 91. Here are the lines in that block.....does this indicate this only works for federated servers?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;def exportToSDDraft(self, out_sddraft):&lt;BR /&gt; self.federatedServerUrl = self.targetServer # todo: temp fix&lt;BR /&gt; return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the error I get in ArcGIS Pro python windows:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Traceback (most recent call last):&lt;BR /&gt; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sharing.py", line 91, in exportToSDDraft&lt;BR /&gt; return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))&lt;BR /&gt;ValueError: Target server is not a standalone server or is inaccessible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I'm basically dead in the water until I can figure out what is going on....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Sep 2019 18:29:13 GMT</pubDate>
    <dc:creator>JohnFix2</dc:creator>
    <dc:date>2019-09-13T18:29:13Z</dc:date>
    <item>
      <title>Publishing web layer in bulk</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877620#M4989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am&amp;nbsp;implementing a script to publish web layer in bulk into Enterprise ArcGIS Server v10.7.0 based on below example.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm"&gt;https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am trying is to create a Pro project file which has several maps having multiple feature classes sourced from EGDB,&amp;nbsp;create a script to get all maps and layers in the project file, and publish each of layers as a web layer by reference.&amp;nbsp;Our ArcGIS server is federated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;aprxFile = r"pathto\Bulk_Layer_Publishing.aprx"&lt;/P&gt;&lt;P&gt;outDir = r"pathto\Output_sd"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Reference map to publish&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(aprxFile)&lt;BR /&gt;for m in aprx.listMaps('*'):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; print("Map: " + m.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; serverFolder = m.name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; serviceDirName = "{}\\{}".format(outDir, m.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if not os.path.exists(serviceDirName):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; os.mkdir(serviceDirName)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; for lyr in m.listLayers():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; service_name = lyr.name&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sddraft_filename = "{}\\{}".format(serviceDirName, service_name + ".sddraft")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Create MapServiceDraft and set service properties&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sharing_draft = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', service_name, lyr)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; targetServer = r"pathTo\MyArcGIS.ags"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sharing_draft.targetServer = targetServer&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sharing_draft.serverFolder = serverFolder # same as Map name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sharing_draft.copyDataToServer = False&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sharing_draft.exportToSDDraft(sddraft_filename)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error: Target server is not a standalone server or is inaccessible.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; File "&amp;lt;string&amp;gt;", line 45, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sharing.py", line 91, in exportToSDDraft&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ValueError: Target server is not a standalone server or is inaccessible.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anyone advise me what's wrong with my code??&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2019 03:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877620#M4989</guid>
      <dc:creator>AkiyoshiKawamura1</dc:creator>
      <dc:date>2019-07-05T03:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing web layer in bulk</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877621#M4990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get this error when I'm trying to create an SD Draft file in ArcGIS Pro. I want to make an .SD file that I can then publish to our ArcGIS Server 10.6.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I have created a valid .ags file. I can use the paramaters I specify in the .ags file to open the admin page of that server. But it IS a stand alone ArcGIS Server....NOT a federated server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error in "sharing.py" at line 91. Here are the lines in that block.....does this indicate this only works for federated servers?&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;def exportToSDDraft(self, out_sddraft):&lt;BR /&gt; self.federatedServerUrl = self.targetServer # todo: temp fix&lt;BR /&gt; return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the error I get in ArcGIS Pro python windows:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Traceback (most recent call last):&lt;BR /&gt; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sharing.py", line 91, in exportToSDDraft&lt;BR /&gt; return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))&lt;BR /&gt;ValueError: Target server is not a standalone server or is inaccessible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I'm basically dead in the water until I can figure out what is going on....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877621#M4990</guid>
      <dc:creator>JohnFix2</dc:creator>
      <dc:date>2019-09-13T18:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing web layer in bulk</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877622#M4991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below code works for me.&lt;/P&gt;&lt;P&gt;I repeated this process to publish around 500+ services in bulk.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;federatedServerUrl = "Url to ArcGIS server"&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;aprxProj = arcpy.mp.ArcGISProject("CURRENT")&lt;/PRE&gt;aprxMap = aprxProj.listMaps("Map")[0]&lt;BR /&gt;&lt;BR /&gt;service_name = "Service_Name"&lt;BR /&gt;serviceFolder = "Service_Folder"&lt;BR /&gt;sddraft_filename = "{}\\{}".format(serviceFolder, service_name + ".sddraft")&lt;BR /&gt;sharing_draft = aprxMap.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE", service_name)&lt;/PRE&gt;sharing_draft.federatedServerUrl = federatedServerUrl&lt;BR /&gt;sharing_draft.copyDataToServer = False&lt;BR /&gt;# sharing_draft.offline = False&lt;BR /&gt;sharing_draft.overwriteExistingService = False # True&lt;BR /&gt;sharing_draft.serverFolder = serviceFolder&lt;BR /&gt;sharing_draft.summary = summary&lt;BR /&gt;sharing_draft.tags = tags&lt;BR /&gt;sharing_draft.description = description&lt;BR /&gt;#sharing_draft.credits = "My Credits"&lt;BR /&gt;sharing_draft.useLimitations = "My Use Limitations"&lt;BR /&gt;&lt;BR /&gt;# Create Service Definition Draft file&lt;BR /&gt;sharing_draft.exportToSDDraft(sddraft_filename)&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Read the sddraft xml.
doc = DOM.parse(sddraft_filename)

# Find all elements named TypeName. This is where the server object extension
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
    # Get the TypeName we want to enable.
    if typeName.firstChild.data == "FeatureServer":
        extension = typeName.parentNode
        for extElement in extension.childNodes:
            # Enable Feature Access.
            if extElement.tagName == 'Enabled':
                extElement.firstChild.data = 'true'
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Output to a new sddraft with Feature service enabled
sddraft_mod_xml = service_name + '_mod_xml' + '.sddraft'
sddraft_mod_xml_file  = "{}\\{}".format(serviceFolder, sddraft_mod_xml)

f = open(sddraft_mod_xml_file, 'w')
doc.writexml(f)
f.close()

&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Stage Service
sd_filename = "{}\\{}".format(serviceFolder, service_name + ".sd")
arcpy.StageService_server(sddraft_mod_xml_file, sd_filename)

&lt;/PRE&gt;&lt;/PRE&gt;&lt;/PRE&gt;# Publish&lt;BR /&gt;arcpy.UploadServiceDefinition_server(&lt;BR /&gt; in_sd_file=sd_filename,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_server="AGS file to ArcGIS server",&lt;/PRE&gt;in_service_name=service_name,&lt;BR /&gt; in_startupType="STARTED")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 11:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/877622#M4991</guid>
      <dc:creator>AkiyoshiKawamura1</dc:creator>
      <dc:date>2021-12-12T11:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing web layer in bulk</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/1109264#M6751</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/246260"&gt;@AkiyoshiKawamura1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have seen that you have solved this issue. I have a similar problem, I cannot publish my script as a web tool in my&amp;nbsp; Enterprise, because the .sddraft file is not being created, here is part of my script:&lt;/P&gt;&lt;PRE&gt;outdir = &lt;SPAN&gt;r"C:\ArcgisData\Webmapdata\{}"&lt;/SPAN&gt;.format(CHnumber)&lt;BR /&gt;service = CHnumber&lt;BR /&gt;sddraft_filename = service + &lt;SPAN&gt;".sddraft"&lt;BR /&gt;&lt;/SPAN&gt;sddraft_output_filename = os.path.join(outdir&lt;SPAN&gt;, &lt;/SPAN&gt;sddraft_filename)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RiskAssessment_output &lt;/SPAN&gt;= &lt;SPAN&gt;r'C:\ArcgisData\Webmapdata\{}\{}'&lt;/SPAN&gt;.format(CHnumber&lt;SPAN&gt;,&lt;/SPAN&gt;CHnumber)&lt;BR /&gt;&lt;SPAN&gt;#DeforestationRisk_points_lyrx = "C:\\ArcgisData\\RA_visualisation\\Symbology\\polygon.lyrx"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# Reference map to publish&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;aprx_template = arcpy.mp.ArcGISProject(&lt;SPAN&gt;r"C:\ArcgisData\Webmapdata\RA_visualisation.aprx"&lt;/SPAN&gt;)&lt;BR /&gt;aprx_template.saveACopy(&lt;SPAN&gt;r"C:\ArcgisData\RA_visualisation\Temp_projects\{}.aprx"&lt;/SPAN&gt;.format(service))&lt;BR /&gt;log(&lt;SPAN&gt;"created aprx"&lt;/SPAN&gt;)&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(&lt;SPAN&gt;r"C:\ArcgisData\RA_visualisation\Temp_projects\{}.aprx"&lt;/SPAN&gt;.format(service))&lt;BR /&gt;m = aprx.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;layers_in_current = m.listLayers()&lt;BR /&gt;layers_in_current.append(layer_tmp)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;m.addDataFromPath(layer_tmp[&lt;SPAN&gt;0&lt;/SPAN&gt;])&lt;BR /&gt;log(&lt;SPAN&gt;"Layer added to map"&lt;/SPAN&gt;)&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;aprx.save()&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# Create TileSharingDraft and set service properties&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft = m.getWebLayerSharingDraft(&lt;SPAN&gt;"HOSTING_SERVER"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"FEATURE"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;service)&lt;BR /&gt;log(&lt;SPAN&gt;"sddraft properties defined"&lt;/SPAN&gt;)&lt;BR /&gt;sharing_draft.overwriteExistingService = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft.summary = &lt;SPAN&gt;"Testing publishing of layers"&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft.tags = &lt;SPAN&gt;"risk map"&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft.description = &lt;SPAN&gt;"My Description"&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft.credits = &lt;SPAN&gt;"My Credits"&lt;BR /&gt;&lt;/SPAN&gt;sharing_draft.useLimitations = &lt;SPAN&gt;"My Use Limitations"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# Create Service Definition Draft file&lt;BR /&gt;&lt;/SPAN&gt;log(&lt;SPAN&gt;"start creating sddraft file"&lt;/SPAN&gt;)&lt;BR /&gt;sharing_draft.exportToSDDraft(sddraft_output_filename)  &amp;lt;-  IT IS FAILING IN THIS LINE&lt;BR /&gt;log(&lt;SPAN&gt;"sddraft created"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;# Stage Service&lt;BR /&gt;&lt;/SPAN&gt;sd_filename = service + &lt;SPAN&gt;".sd"&lt;BR /&gt;&lt;/SPAN&gt;sd_output_filename = os.path.join(outdir&lt;SPAN&gt;, &lt;/SPAN&gt;sd_filename)&lt;BR /&gt;log(&lt;SPAN&gt;"Staging service"&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.StageService_server(sddraft_output_filename&lt;SPAN&gt;, &lt;/SPAN&gt;sd_output_filename)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This is the error I always get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jos_ManuelMendoza_0-1634743747277.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25631i62EF0E17A1992C1D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jos_ManuelMendoza_0-1634743747277.png" alt="Jos_ManuelMendoza_0-1634743747277.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The weird part is that the tool is working locally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 15:30:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publishing-web-layer-in-bulk/m-p/1109264#M6751</guid>
      <dc:creator>José_ManuelMendoza</dc:creator>
      <dc:date>2021-10-20T15:30:27Z</dc:date>
    </item>
  </channel>
</rss>

