I am working on a Python script to manage ArcGIS Server services (publish new services, update existing services, delete old services, etc.) in batch across multiple environments (e.g. dev, test and production) and instances (2+ per environment).

To publish services, you can use ArcPy and AGS connection files, but to do anything beyond that (e.g. list existing services, start/stop/delete services), you need to use the AGS Admin REST API, which uses token-based authentication, and to get a token you need to submit the user's name and password.

Having to specify the server URL, username and password each time would be tedious for the user, especially if they are working with more than one AGS instance at a time, as my script does. I'd much prefer if they could just use their preexisting AGS connection files instead, which they need for publishing regardless.

Is there any way to get the connection info (e.g. server URL, username, password) from an AGS connection (.ags) file programmatically -- ideally with Python? arcpy.Describe considers them dumb files and can't do anything with them.

If there's no way to do that then I suppose I will have to require an additional configuration step to generate and store the tokens locally for a long duration as it would be too cumbersome to have to prompt the user for credentials for each AGS instance every time they use the script.


In short, no. There is no way to extract that information from a .ags file without a major effort and some serious reverse engineering. Esri designed it that way because having a file that contained the fully qualified domain name of a server as well as the complete credentials of a user with privileges to access that server would pose a major security risk.

Also, just because a user has permissions to publish a service, doesn't mean they can start and stop services on the GIS Server, so your logic that just because they have a server connection file (.ags file) they should be able to access the Administrator REST endpoints and start/stop services is a little flawed, unless I'm misinterpreting your post.

  • Thanks -- pretty much what I assumed to be the case. Just a pain is all. Of course .ags files would need to be protected, just like .sde files. But at least you can actually use .sde files for their intended purpose. AGS files seem to be much less useful, at least for scripting purposes. And I'm aware of the difference between publisher and administrator connections, we mainly use the latter. – blah238 May 10 '16 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.