Select to view content in your preferred language

ArcGIS Server Map Services- Portal item relationship: fix broken link?

1071
1
03-22-2019 01:10 PM
Arne_Gelfert
Frequent Contributor

So I've been busy publishing map services from an "old" standalone ArcGIS Server environment to Portal/Federated ArcGIS Server. Which means you create a map services and Portal creates a corresponding item. In the process, I've had to undo and clean up a few things. It's easy to wipe out map services with Python:

from arcgis import gis

mygis = gis.GIS(url, username='arcgis_python')
gis_servers = gisprod.admin.servers.list()

server1 = gis_servers[0]
rest_folder = '<your_REST_endpoint_folder>'

map_services = server1.services.list(rest_folder)

for service in map_services:
    try:
        service.delete()
    except Exception as e:
        print(e.message)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Alternatively, of course, you could simply select the services in ArcCatalog and delete them, if you're so inclined. But the script is convenient, when you have a list of services to remove.

But now what happens is that the service gets removed but the Portal item representing the services does not. Which results in a broken item. This happens even if the item is protected.

The proper way to clean things up would be by removing the Portal item, which takes the map services with it.

item = gisprod.content.get('7db0bc4128eb4d819794815e4654a358')

item.delete(0‍‍)

However, if the map services is gone, is there a way to link that item back to the service?

If I publish the map service again, this creates a new item with a new item Id. The old one doesn't show up more. 

Also, for map services that show up as Portal items, what is the server id, when I interrogate dependencies:

item.dependent_upon()

{'total': 1,
'start': 1,
'num': 1,
'nextStart': -1,
'list': [{'dependencyType': 'serverId', 'id': 'FK7U7Hisd6qRFdPK'}]}

What's the code 'FK7U7Hisd6qRFdPK' reference?

1 Reply
JoshuaPust
Occasional Contributor

You probably figured it out by now, but the code is an ID that your Portal gives to each of your federated server-sites. My hosting_server is a 2machine server-site and gets 1 ID from portal.