Select to view content in your preferred language

arcpy.server.StageService works in Pro but fails in VSC, propy, proenv with ERROR 999999

982
2
10-26-2023 08:37 PM
DerrickWong
Esri Contributor

Hi all,

I am trying to automate the publishing of map services, and am having issues with the function arcpy.StageService_server. The code works when executed within the python window in ArcGIS Pro 3.x but fails in propy, proenv and visual studio code while using the library in arcgispro-py3.

DerrickWong_0-1698375762018.png

This is for a ArcGIS Server 10.9.1 which is unfederated. 

I have also tested this on another 10.9.1 federated enterprise, as well as 11.1 using getWebLayerSharingDraft function and am able to reproduce the error.

 

 

sd = mp.getWebLayerSharingDraft('FEDERATED_SERVER', 'MAP_IMAGE', servicename)
sd.federatedServerUrl = self.server_url

 

 

For Standalone, I am using:

 

 

sd = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', 'test', mp)
sd.targetServer = '\\\\Server1234\\automate\\agsconnection\\agsconnection.ags'

 

 

I have tried exporting the python script from pro and executing it returns the same result as well.

DerrickWong_1-1698376886523.png

Sample code I am trying to run:

 

 

import arcpy

arcpy.server.StageService(r"C:\Work\Projects\Web Service Automation\sddrafts\test.sddraft", r"C:\Work\Projects\Web Service Automation\sds\test.sd", None)

 

 

I have also tested using double slashes ("C:\\Work\\..."), back slashes, as well as a shared network path (r"\\server\automate\..."  and "\\\\server\\automate\\..) with full control.

I have added a breakpoint and it's throwing an error on the function convertArcObjectToPythonObject in server.py line at 1167:

DerrickWong_2-1698377000034.png

IIS, Server, Portal, DS have all been registered with a CA-Signed SSL Certificate.

I have also tried adding the following line:

 

 

ssl._create_default_https_context = ssl._create_unverified_context

 

 

 

For some more context, I have no issues executing the GIS module on a federated server in VSC. I am able to sign in, create/delete items, etc.

 

Does anyone know why ArcGIS Pro handles this differently from VSCode? 

 

Cheers,

Derrick

0 Kudos
2 Replies
StaticK
MVP

I am in the same boat. The programmatic process to create these services and requirements of editing the xml to change properties introduces a lot places for errors and is terrible. All you get back from the method is 999999. 

Adding a FeatureService should be as easy as sddraft.FeatureService = True but instead the process is 4-5 for/if statements to drill down and find the right Node and add/ change the setting. Same with setting the editing, uploads, etc.,. capabilities-  Why can't the method generate these properties in the xml? sddraft.FeatureService.Capabilities = 'Query,Sync,Editing'  It's ugly...

There could be so many things that cause error too- Are you signing into the server/ portal in your code?

gis = GIS('Pro')

 

0 Kudos
DerrickWong
Esri Contributor

Hi @StaticK

Thanks for your reply. Yeah getting a 999999 isn't ideal and doesn't narrow down what the issue is. It's pretty much trial and error to try to isolate the issue at the moment and we are not having much fun with it.

On the federated server, we did use gis = GISverify_cert = False ....) but it still errors out anywhere outside of Pro.

 

Regards,

 

Derrick

0 Kudos