<?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: Publish Map service on federated portal in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213481#M65598</link>
    <description>&lt;P&gt;1. First, off I used python 2.7 to create mine not python 3.x. But I would think they are close to each other.&lt;/P&gt;&lt;P&gt;2. A bad certificate will definitely break things. But I am not certain it is the source of your issues. Normally when I have a certificate issues I get an error with a reference to SSL in it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. It looks like the issue is with the server connection parameter (If I am reading the French right?). I would test my server connection with ArcCatalog. You should be able to navigate to it and open it with ArcCatalog.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forestknutsen1_0-1663345857878.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51454iA015C4E0562CBD66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forestknutsen1_0-1663345857878.png" alt="forestknutsen1_0-1663345857878.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 16:31:38 GMT</pubDate>
    <dc:creator>forestknutsen1</dc:creator>
    <dc:date>2022-09-16T16:31:38Z</dc:date>
    <item>
      <title>Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213107#M65584</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;I need to run a script to deploy many mapservice on arcgis service and portal. They are federated. Is there any sample yo do this ?&lt;/P&gt;&lt;P&gt;This script may also be used to update mapservice.&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;Guillaume&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 19:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213107#M65584</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-09-15T19:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213240#M65590</link>
      <description>&lt;P&gt;I have script that publishes a service to Arc server that is federated with portal. I posted the two functions that do most of the work. I hope it helps.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def build_connection(locator_specs, working_dir):
    """
    builds AGS connection
    :param working_dir: script working path
    :param locator_specs: instance of Specs class
    :return: AGS connection
    """
    out_folder_path = 'ags_connections'
    clean_dir(out_folder_path, working_dir)
    use_arcgis_desktop_staging_folder = False
    staging_folder_path = out_folder_path
    server_info = locator_specs.get_arc_gis_servers()
    server = server_info.server
    out_name = '{}.ags'.format(server)
    server_url = 'https://{}:6443/arcgis/admin'.format(server)
    print server_url
    username = server_info.admin_user
    password = xxxx.security.get_password(server, username)
    logger.info(xxxx.indent('Making sever connection: {}'.format(out_name), 2))
    arcpy.mapping.CreateGISServerConnectionFile("ADMINISTER_GIS_SERVICES",
                                                out_folder_path,
                                                out_name,
                                                server_url,
                                                "ARCGIS_SERVER",
                                                use_arcgis_desktop_staging_folder,
                                                staging_folder_path,
                                                username,
                                                password,
                                                "SAVE_USERNAME")
    return os.path.join(out_folder_path, out_name)


def publish_service(gis_server_connection_file, working_dir, location_dir):
    """
    creates sd file and publishes it to server
    :param gis_server_connection_file: AGS connection
    :param working_dir: script directory
    :return: None
    """
    gis_server_connection_file = os.path.join(working_dir, gis_server_connection_file)
    out_sd_folder = 'sd'
    clean_dir(out_sd_folder, working_dir)
    service_name = 'CW_Composite'
    locator_path = os.path.join(location_dir, service_name)
    sddraft_file = os.path.join(working_dir, out_sd_folder, 'cw_composite.sddraft')
    sd_file = os.path.join(working_dir, out_sd_folder, 'cw_composite.sd')
    summary = 'CEA address locator'
    tags = 'address, locator, geocode'
    folder_name = 'Locator'
    logger.info(xxxx.indent('Building SDDraft: {}'.format(sddraft_file), 2))
    analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sddraft_file, service_name,
                                                  connection_file_path=gis_server_connection_file,
                                                  summary=summary,
                                                  tags=tags,
                                                  max_result_size=20,
                                                  max_batch_size=500,
                                                  suggested_batch_size=150,
                                                  folder_name=folder_name,
                                                  copy_data_to_server=True)
    if analyze_messages['errors'] == {}:
        logger.info(xxxx.indent('Staging service {}:'.format(sd_file), 2))
        arcpy.server.StageService(sddraft_file, sd_file)
        logger.info(xxxx.indent('Uploading sd: {}'.format(sd_file), 2))
        arcpy.server.UploadServiceDefinition(sd_file, gis_server_connection_file)
        logger.info(xxxx.indent(arcpy.GetMessages(), 2))
        logger.info(xxxx.indent('Success: service published', 2))
    else:
        logger.error(xxxx.indent(analyze_messages['errors'], 2))
        logger.error(xxxx.indent('Failure: service was not published'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 01:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213240#M65590</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-09-16T01:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213278#M65591</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I try to use this help :&amp;nbsp;&lt;A href="https://pro.arcgis.com/fr/pro-app/2.9/arcpy/sharing/mapservicedraft-class.htm" target="_blank"&gt;MapServiceDraft—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;but i have this error :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GuillaumeArnaud_0-1663310496707.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51409iBF13AFA28156CB8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GuillaumeArnaud_0-1663310496707.png" alt="GuillaumeArnaud_0-1663310496707.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It could be an error with certificate.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 06:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213278#M65591</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-09-16T06:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213481#M65598</link>
      <description>&lt;P&gt;1. First, off I used python 2.7 to create mine not python 3.x. But I would think they are close to each other.&lt;/P&gt;&lt;P&gt;2. A bad certificate will definitely break things. But I am not certain it is the source of your issues. Normally when I have a certificate issues I get an error with a reference to SSL in it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. It looks like the issue is with the server connection parameter (If I am reading the French right?). I would test my server connection with ArcCatalog. You should be able to navigate to it and open it with ArcCatalog.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forestknutsen1_0-1663345857878.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51454iA015C4E0562CBD66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forestknutsen1_0-1663345857878.png" alt="forestknutsen1_0-1663345857878.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 16:31:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1213481#M65598</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-09-16T16:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1214087#M65624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your reply, I just found that is an error when ags con is allready open.&lt;/P&gt;&lt;P&gt;Yes it's a french arcgis pro.&lt;/P&gt;&lt;P&gt;When I launch the script first time when arcgis pro open, it ask me for trust certificate and deploy mapservice, when I launch it again (or after click on ags connexion to view it's content), I have the error.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;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;Thanks for your time.&lt;/P&gt;&lt;P&gt;Guillaume&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 05:52:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1214087#M65624</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-09-20T05:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1214338#M65638</link>
      <description>&lt;P&gt;hmmm.... normally ArcMap only asks me to trust the certificate if there is an issue with it. I wonder if you are using a self signed certificate or maybe one that has expired. You can check your certificate in chrome.&lt;/P&gt;&lt;P&gt;Click on the little lock thing to get the info:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forestknutsen1_1-1663700602163.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51668i9F4291A20D5E6DD4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forestknutsen1_1-1663700602163.png" alt="forestknutsen1_1-1663700602163.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is one of mine:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forestknutsen1_0-1663700449047.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51667iAF04C0FF20BB6677/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forestknutsen1_0-1663700449047.png" alt="forestknutsen1_0-1663700449047.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Or you may see something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forestknutsen1_2-1663700819731.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/51669iD2B7330ABFABE976/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forestknutsen1_2-1663700819731.png" alt="forestknutsen1_2-1663700819731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Of course you need to check the one on the ArcGIS Server, not the Portal one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 19:08:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1214338#M65638</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-09-20T19:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216390#M65687</link>
      <description>&lt;P&gt;It's a dev server so certificate is auto sign so not secure.&lt;/P&gt;&lt;P&gt;I want to publish it from arcgis pro.&lt;/P&gt;&lt;P&gt;As I say before, it work first time :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GuillaumeArnaud_0-1664260861336.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52253i984C9B2879924E79/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GuillaumeArnaud_0-1664260861336.png" alt="GuillaumeArnaud_0-1664260861336.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But not when i relaunch it :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GuillaumeArnaud_2-1664260964273.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52255i385E9B1298F8A509/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GuillaumeArnaud_2-1664260964273.png" alt="GuillaumeArnaud_2-1664260964273.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If i restart arcgis pro, i can run script 1 time without craches&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:30:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216390#M65687</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-09-27T07:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216621#M65691</link>
      <description>&lt;P&gt;I see, that is weird. But it asks you if you want to trust the machine the first time?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 17:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216621#M65691</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-09-27T17:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216836#M65700</link>
      <description>&lt;P&gt;Yes it ask me and i approve.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 06:09:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1216836#M65700</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-09-28T06:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1217486#M65714</link>
      <description>&lt;P&gt;Yes, I think it is your self-signed certificate. My guess is the first time is asks you and runs fine. The next time it does not ask (for whatever reason) and fails. We used put self signed certificates on our dev and test machines, but now we put "real" ones on all of our servers. Situations like this was one of the motivating factors. Can you put a singed certificate on the server?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 16:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1217486#M65714</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-09-29T16:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1219721#M65771</link>
      <description>&lt;P&gt;Unfortunately no I can't&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 05:33:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1219721#M65771</guid>
      <dc:creator>GuillaumeArnaud</dc:creator>
      <dc:date>2022-10-07T05:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Publish Map service on federated portal</title>
      <link>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1219968#M65779</link>
      <description>&lt;P&gt;Sorry, I am not sure what else to say.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 17:22:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-map-service-on-federated-portal/m-p/1219968#M65779</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2022-10-07T17:22:09Z</dc:date>
    </item>
  </channel>
</rss>

