Hi !
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 ?
This script may also be used to update mapservice.
Thanks for your help
Guillaume
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.
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 = xyz.security.get_password(server, username) logger.info(xyz.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(xyz.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(xyz.indent('Staging service {}:'.format(sd_file), 2)) arcpy.server.StageService(sddraft_file, sd_file) logger.info(xyz.indent('Uploading sd: {}'.format(sd_file), 2)) arcpy.server.UploadServiceDefinition(sd_file, gis_server_connection_file) logger.info(xyz.indent(arcpy.GetMessages(), 2)) logger.info(xyz.indent('Success: service published', 2)) else: logger.error(xyz.indent(analyze_messages['errors'], 2)) logger.error(xyz.indent('Failure: service was not published'))
Hi,
I try to use this help : MapServiceDraft—ArcGIS Pro | Documentation but i have this error :
It could be an error with certificate.
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.
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.
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.
Thanks for your reply, I just found that is an error when ags con is allready open.
Yes it's a french arcgis pro.
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.
sharing.py", line 91, in exportToSDDraftreturn _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))ValueError: Target server is not a standalone server or is inaccessible.
Thanks for your time.
It's a dev server so certificate is auto sign so not secure.
I want to publish it from arcgis pro.
As I say before, it work first time :
But not when i relaunch it :
If i restart arcgis pro, i can run script 1 time without craches
I see, that is weird. But it asks you if you want to trust the machine the first time?
Yes it ask me and i approve.
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?
Unfortunately no I can't
Sorry, I am not sure what else to say.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.