I'm trying to overwrite an existing map service in ArcGIS server 10.4.1 using ArcPy. It doesn't appear to be able to see my server and gives a value error (ValueError: GIS Servers/arcgis on MYSERVER.nuim.ie_6080 (admin)) when I run using cmd prompt.
It is failing at line 31 saying suggesting that the 'con =' parameter is invalid. I have checked this however and the input I have corresponds with my server name in ArcGIS catalogue.
Any advice would be greatly appreciated.
From your screenshot, it doesn't appear like you're running this from the python window in ArcMap. ArcMap knows how to contruct the full path of the connection files within the GIS Servers folder in the Catalog window. I suggest you copy the connection from the GIS Servers folder to somewhere on your file system, and provide the absolute path to it so the script knows where to find it. You can also point the script to the actual path that the connection file exists in when using GIS Servers, which is C:\Users\<user>\AppData\Roaming\ESRI\Desktop<version>\ArcCatalog\<connection file name>. As you can see, it may be easier to move the file to a more friendly path.
Many thanks for the advice. We were testing the script in the CMD window as we hope to have it run as a Windows scheduled task. I tried it in the Python window in ArcMap and it found the server and didn't give me this error anymore.
I will try the absolute path suggestion which might hopefully let us run this script as a scheduled task in a batch file.
I don't know much (anything) about connection files, but the help (and example within) indicates that the connection string should end in '.ags'. Can you try:
con = 'GIS Servers/arcgis on MYSERVER.nuim.ie_6080 (admin).ags'
I ran into the same problem with ArcGIS Pro 2.9. In the end the end the .ags file was created with my personall account where I should have made it with the "Installation Account -> the account under which the application which uses the .ags file". Therefore the password was not saved and gave me the error above.
In arcmap it was possible to create the .ags file on the fly but with ArcGIS Pro it is not supported anymore. So you need to create it manually on the server where you are running the script. I created the .ags file through -> Connections -> new server. There are three options concerning password management:
1) Make the .ags with the installation account (for me it was the account where we install the application from azure devops) and save the password under the Windows Credential manager.
2) If you have two accounts make on each account the .ags file and save it in the windows credential manager.
3) (not advised because the file becomes a portable key basically) If you have numerous accounts that can use the .ags file select: save username/password to connection file. After clicking on Ok and Yes, save your arcgis Pro project otherwise the password and username will not be saved to the .ags file.
There are all kinds of errors you can have for example:
- Parameters are not valid