Because the deadline for submitting recorded user presentations for DevSummit 2021 was so tight (February 15!), there were some issues I ran into that I could not resolve in time, mainly revolving around the use of arcpy.mp in ArcGIS Server 10.8.1. As a workaround for the presentation, I created a standalone enterprise 10.8 install on a test box in Flagstaff, which was quite slow.
The recorded presentation is available here:
The slides and sample code are also available here:
It turns out that most of the issues I encountered at 10.8.1 were fixed by a single patch, the "Print Service and Text Element Patch," available here:
Here’s a list of the problems I encountered which were fixed by the patch:
Since installing the patch, I was able to implement the web tool and application on our 10.8.1 Q Portal in Tucson, which is considerably faster. The COTTONWOOD 1 map, which took 51 seconds to run in the presentation, took only 14 seconds to run in the Q Portal.
Authentication: arcpy vs. ArcGIS API for Python
Another issue that I ran into was authentication. While the ArcGIS API for Python correctly encapsulates the identity of the user of the web tool, the arcpy identity is the owner of the ArcSOC process. Why is this a problem? If the layers in a Pro project are not available to the ArcSOC owner, they will not render in the exported PDF. Currently, there is no way for arcpy to sign into portal using the credentials of the web tool user.
[If this is a concern to you, please vote up my idea here: https://community.esri.com/t5/python-ideas/arcpy-sign-into-portal-using-python-api/idi-p/1039109 ]
For the presentation, I worked around the problem by sharing the layers with everyone. However, this is not acceptable for sensitive map data in a Portal which is exposed to the public. The workaround I settled upon is to use the “cryptography” module which is included with ArcGIS Pro:
I created a built-in user in Portal which could access the layers in the Pro project, and created a text file in the project folder containing the encryption key and the encrypted user name and password. I then used that file to sign arcpy into Portal:
def _SignIn(self): # Retrieve credentials and sign in to Portal from cryptography.fernet import Fernet sKeyFile = os.path.join(self.__sProjectDir, "Encrypted.txt") with open(sKeyFile) as f: sContent = f.read() tok = sContent.split("\n") sKey = bytes(tok, encoding="utf-8") sUserTok = bytes(tok, encoding="utf-8") sPassTok = bytes(tok, encoding="utf-8") f = Fernet(sKey) sUser = f.decrypt(sUserTok) sPass = f.decrypt(sPassTok) sPortal = arcpy.GetActivePortalURL() arcpy.SignInToPortal(sPortal, sUser, sPass) return
See the updated version of the Python toolbox (attached) for more info.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.