Select to view content in your preferred language

How to create an arcgis server connection file with the python 3.x environment (from ArcGIS Pro)

7549
8
Jump to solution
03-04-2021 06:25 AM
Labels (1)
LorenzMeyer1
Regular Contributor

Hi

Has anyone found a way on how to create an arcgis server connection file (*.ags) with the python environment coming with ArcGIS Pro? I mean with python 3.x and not the old python 2.7 from ArcMap.

There is an function to create a connection file, but this only runs with python 2.7 (old stuff).

https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/creategisserverconnectionfile.htm

Thanks

1 Solution

Accepted Solutions
MaxSquires
Frequent Contributor

agreed. this has been a major bummer for automation.  

the following works:

 

# in the same conda environment where i normally import arcpy:

import arcgisscripting
arcgisscripting._createGISServerConnectionFile("ADMINISTER_GIS_SERVICES", "C:/admin", "new.ags", "https://maxscoolserver.org/raster", "ARCGIS_SERVER", True, "C:/admin", "sitemanager", "password123")

 

MaxSquires_1-1618518511995.png

MaxSquires_2-1618518531573.png

warning: this is a private method so may not be a great idea, but i'm going to do it until something better comes along.

View solution in original post

8 Replies
nutscrewbolt
Emerging Contributor

We are also facing a similar issue. The arcpy function to create arcgis server connection file - CreateGISServerConnectionFile is no longer exposed or available with python 3.x? The automated python solution to enable one touch deployment on our CI/CD servers are dependent on creating .ags files on the fly. Any idea if this is exposed with python 3.x

 

0 Kudos
MaxSquires
Frequent Contributor

agreed. this has been a major bummer for automation.  

the following works:

 

# in the same conda environment where i normally import arcpy:

import arcgisscripting
arcgisscripting._createGISServerConnectionFile("ADMINISTER_GIS_SERVICES", "C:/admin", "new.ags", "https://maxscoolserver.org/raster", "ARCGIS_SERVER", True, "C:/admin", "sitemanager", "password123")

 

MaxSquires_1-1618518511995.png

MaxSquires_2-1618518531573.png

warning: this is a private method so may not be a great idea, but i'm going to do it until something better comes along.

LorenzMeyer1
Regular Contributor

Great, thanks.

Exactly what I was looking for.

0 Kudos
nutscrewbolt
Emerging Contributor

Thank you so much. Exactly what I was looking for @MaxSquires 

0 Kudos
RehanChaudhary
Frequent Contributor

Hi @MaxSquires i am getting a runtime error when i am using this function in a jupyter notebook. my instance lookes somtehing like this . what could be the issue?

import arcgisscripting
acrcgissripting._createGISServerConnectionFile("PUBLISH_GIS_SERVICES", "/arcigs/home", "test.ags", "https://serverurl", "ARCGIS_SERVER", True, "/arcgis/home", "username", "password","SAVE_USERNAME")

 

0 Kudos
MichaelLakey
Occasional Contributor

Excellent!  I will try this until there is a better alternative.

0 Kudos
PeterKnoop
MVP Regular Contributor

I think arcpy.management.CreateDatabaseConnection might be what you are looking for?

0 Kudos
MaxSquires
Frequent Contributor

i don't think so.