<?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: I need a complete workflow for publishing layers or layer collections in Python. in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055842#M30135</link>
    <description>&lt;P&gt;Brian - In addition to what Michael has posted, everything you need to get started is contained in this sample:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#C_GUID-4EAB8A36-C06E-488C-8F0F-AC32014A3716" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#C_GUID-4EAB8A36-C06E-488C-8F0F-AC32014A3716&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Or you can go here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/createweblayersddraft.htm#C_GUID-AAC21E52-6C69-46D2-ADD8-C62224CE5826" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/createweblayersddraft.htm#C_GUID-AAC21E52-6C69-46D2-ADD8-C62224CE5826&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and look at the last sample in the list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For either one, you could put them in a conditional like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    for m in aprx.listMaps("AppraiserLayers"):
        print("Map: " + m.name)
        for lyr in m.listLayers():
            if  lyr.name == 'PropertySalesPublic':
                lyrList = []
                lyrList.append(m.listLayers(lyr.name)[0])
                print(lyr.name)
                stageSDDraft(m, lyr.name, "snippit", lyrList, "descript","Portal Folder","tags","sd folder on your drive")
                print(lyr.name + " Draft Created")
                arcpy.StageService_server('C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sddraft', 'C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sd')
                print(lyr.name + " Service Staged")
                arcpy.UploadServiceDefinition_server('C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sd', 'My Hosted Services', "","","","","","OVERRIDE_DEFINITION","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION","")
                print(lyr.name + " Service Uploaded")
                message = message + "\n" + "1. " + (lyr.name) + " Service Uploaded"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I still like to keep the old blog that Michael posted in his reply handy because its helpful to see how to use both arcpy and the arcgis api together&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2021 19:45:30 GMT</pubDate>
    <dc:creator>DavidColey</dc:creator>
    <dc:date>2021-05-07T19:45:30Z</dc:date>
    <item>
      <title>I need a complete workflow for publishing layers or layer collections in Python.</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055806#M30130</link>
      <description>&lt;P&gt;I keep finding examples on how to publish services using existing SD files but not a complete workflow from defining a feature layer or collection of feature layers to be published, creating the SDDraft, and then uploading and publishing it.&lt;/P&gt;&lt;P&gt;Step 1, create an sddraft file.&lt;/P&gt;&lt;P&gt;Step 2, Use "Stage Service" to turn an .sddraft into an .sd&lt;/P&gt;&lt;P&gt;Step 3, Use "Upload Service Definition" to upload and publish it.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 1 is missing&lt;/STRONG&gt;. I found "CreateMapSDDraft" but this reads an MXD to publish a map and I want to publish feature services and I no longer use ArcMap or MXD files.&lt;/P&gt;&lt;P&gt;When I author in ArcPro, it creates the file, stages it, uploads it, and deletes it. I find this annoying, I'd like to at least get a copy of the sddraft so I can republish later under control of a Python script. I'd like to be able to create and maintain sddraft files without monkeying around in the ArcPro GUI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055806#M30130</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-05-07T18:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: I need a complete workflow for publishing layers or layer collections in Python.</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055818#M30131</link>
      <description>&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/analytics/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/" target="_blank"&gt;Have you seen the below link:&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/analytics/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/" target="_blank"&gt;https://www.esri.com/arcgis-blog/products/analytics/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055818#M30131</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-05-07T18:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: I need a complete workflow for publishing layers or layer collections in Python.</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055830#M30134</link>
      <description>&lt;P&gt;I have not, that looks like a good lead. THANKS&lt;/P&gt;&lt;P&gt;In the meantime I found the "save as sd" option in ArcPro, created an SD, unpacked it, and threw my hands up in the air as it's another complex nest of uglified XML and JSON files. Still, better than the old days of binary files like MXDs!!&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 19:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055830#M30134</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-05-07T19:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: I need a complete workflow for publishing layers or layer collections in Python.</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055842#M30135</link>
      <description>&lt;P&gt;Brian - In addition to what Michael has posted, everything you need to get started is contained in this sample:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#C_GUID-4EAB8A36-C06E-488C-8F0F-AC32014A3716" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#C_GUID-4EAB8A36-C06E-488C-8F0F-AC32014A3716&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Or you can go here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/createweblayersddraft.htm#C_GUID-AAC21E52-6C69-46D2-ADD8-C62224CE5826" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/createweblayersddraft.htm#C_GUID-AAC21E52-6C69-46D2-ADD8-C62224CE5826&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and look at the last sample in the list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For either one, you could put them in a conditional like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    for m in aprx.listMaps("AppraiserLayers"):
        print("Map: " + m.name)
        for lyr in m.listLayers():
            if  lyr.name == 'PropertySalesPublic':
                lyrList = []
                lyrList.append(m.listLayers(lyr.name)[0])
                print(lyr.name)
                stageSDDraft(m, lyr.name, "snippit", lyrList, "descript","Portal Folder","tags","sd folder on your drive")
                print(lyr.name + " Draft Created")
                arcpy.StageService_server('C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sddraft', 'C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sd')
                print(lyr.name + " Service Staged")
                arcpy.UploadServiceDefinition_server('C:/ArcProProjects/PortalUpdates/Appraiser/' + lyr.name + '.sd', 'My Hosted Services', "","","","","","OVERRIDE_DEFINITION","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION","")
                print(lyr.name + " Service Uploaded")
                message = message + "\n" + "1. " + (lyr.name) + " Service Uploaded"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I still like to keep the old blog that Michael posted in his reply handy because its helpful to see how to use both arcpy and the arcgis api together&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 19:45:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/i-need-a-complete-workflow-for-publishing-layers/m-p/1055842#M30135</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2021-05-07T19:45:30Z</dc:date>
    </item>
  </channel>
</rss>

