HOW TO

List all the services from ArcGIS Server that are referencing a particular database.

First Published: July 7, 2026
Last Published: July 7, 2026

Summary

When upgrading a database (such as SQL Server), it is critical to stop any dependent services to prevent schema locks and data inconsistency. In environments with hundreds of published services, manually identifying these dependencies is both impractical and error-prone. Furthermore, restarting the entire ArcGIS Server Windows service is often not a viable option due to the unnecessary downtime it causes for unrelated services. 

The script below automates this discovery process, providing a targeted list of services that reference a specific database. This allows administrators to perform "surgical" shutdowns, ensuring a smooth upgrade while maintaining high availability for the rest of the site. 

Procedure

  1. Import the necessary modules.
    • import arcgis
    • from arcgis.gis import GIS
    • from arcgis.gis import Datastore
    • import arcgis.gis.admin
  2. Specify the credentials to connect to the portal.
    • portal_url = "https://FQDN/webadaptor_instance"
    • username = "portal_username"
    • password = "portaladmin_password"
    • gis = GIS(portal_url, username, password, verify_cert=False)
  3. Get the list of servers federated with ArcGIS Enterprise Portal
    • gis_servers = gis.admin.servers.list()
  4. Specify the server folder in the for loop to list the services inside the folder (for service in server.services.list()) in which the service resides and get the item information. (for example, folder = "Folder_Name". Leaving this blank fetches all services from the ‘siteroot’ folder.
    • for server in gis_servers:
      • for service in server.services.list():    
        • mi = service.iteminformation
        • manifest1 = mi.manifest["resources"][0]["onPremisePath"]
        • manifest2 = mi.manifest["databases"][0]["onPremiseConnectionString"]
  5. Print all services that are published from the specified database name.
    • if ("DATABASE=Database_name") in manifest2:
      • print(service.properties.serviceName, service.properties.type)
      • print(manifest2)

Here is the result after running the above script:

import arcgis 
from arcgis.gis import GIS 
from arcgis.gis import Datastore 
import arcgis.gis.admin 
portal_url = "https://FQDN/webadaptor_instance" 
username = "portal_username" 
password = "portaladmin_password" 
gis = GIS(portal_url, username, password, verify_cert=False) 

gis_servers = gis.admin.servers.list() 

for server in gis_servers: 
	for service in server.services.list():     
		mi = service.iteminformation 
		manifest1 = mi.manifest["resources"][0]["onPremisePath"] 
		manifest2 = mi.manifest["databases"][0]["onPremiseConnectionString"] 

		if ("DATABASE=Database_name") in manifest2: 
			print(service.properties.serviceName, service.properties.type) 
			print(manifest2) 
Alyssa_Data_1 MapServer
BoundaryAll MapServer
cities MapServer
Defect MapServer
Report_Notes_Attacgment_Table2 MapServer
ReportNotes_Table1 MapServer
Shawn_Krittika_Testing MapServer

result after running the above script

Article ID: 000040862

Software:
  • ArcGIS Server

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options