HOW TO
Some organizations require portal item IDs to remain consistent when migrating content across ArcGIS Enterprise environments such as development, staging, and production. ArcGIS API for Python provides the clone_items() method, which supports preserving item IDs in ArcGIS Enterprise 10.9.1 and later through the preserve_item_id parameter. However, the clone_items() method does not support cloning map services. Refer to ArcGIS API for Python: Cloning Content for more information. Due to this limitation, organizations must republish the map service in the target environment. When a service is published, Portal for ArcGIS automatically creates a new portal item with a new item ID.
Note: Portal for ArcGIS does not allow modifying the item ID of existing items, as described in the article, FAQ: Is it possible to change the item ID of existing items in Portal for ArcGIS?.
This article provides the steps to add a new portal item with the desired item ID to Portal for ArcGIS and update the map service's portalProperties in the ArcGIS Server Administrator Directory so that the service references the desired item ID.
Note:
Prerequisites to performing this workflow: • Administrator privileges are required in both the Portal for ArcGIS and ArcGIS Server target environments. • The user must have permission to publish services to ArcGIS Server. • The desired (source) portal item ID must be known before beginning the workflow. • ArcGIS API for Python must be installed and configured in ArcGIS Pro or a Python environment.
from arcgis.gis import GIS
# Connect to the target portal
gis1 = GIS("https://<machinename>/portal", "<username>", "<password>")
# Create the new portal item that points to the existing map service
gis1.content.add(
item_properties={
"type": "Map Service",
"title": "<exampletitle>",
"url": "https://<machinename>/server/rest/services/<servicename>/MapServer"
},
item_id = '<desired item ID>') # desired item ID from source portal
"portalProperties": {
"isHosted": false,
"portalItems": [{
"itemID": "<desired item ID>",
"type": "MapServer"
}]
},
Article ID: 000030927
Get help from ArcGIS experts
Start chatting now