HOW TO
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.
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

Article ID: 000040862
Get help from ArcGIS experts
Start chatting now