I have a script that runs and will publish and replace vector tile layers in portal. We have many vector tile layers that have to be updated on a regular basis. Every time I run this script, it works for most layers (~30 layers) but 2-3 random layers (it's different every time) end up failing on the replace stage with an error "Failed to replace service". If I go into Portal manually and try to replace the vector tile layers with the updated layer I just published to portal, I get an "undefined" warning and the original vector tile layer doesn't add to a map anymore. The only work around I have found is to delete the original vector tile pack and publish a new one with the same name. However, this requires me to update the script with the new item id and is not ideal. Any idea as to why vector tile layers will randomly fail to be replaced and will become undefined?
In case it helps anyone, I've noticed some of my issues are resolved by double checking which user is uploading and publishing the new vtpk and which user owns the existing, published vtpk it will be replacing. It seems to work best if the same owner owns both the old and new even if they're both admins and thus shouldn't be an issue (at least in my opinion).
I got the same problem. I opened a case with ESRI but the conclusion was that there is no solution.
The best solution was to put a sleep before replaceWebLayer "time.sleep(20)". That helps, but it continue to fail sometimes.
The problem seems to be that the cache generation process is not completed. There is no way to get the process status. It looks like 10.9 allow to check the status, but it does not work on 11.x
Migrated to 11.5 and it is worse than ever: it is now failing systematically 😕
On another identical environment, it works though... The only difference being the load on the server in terms of services published and so on.
@RejeanLabbe, did you manage do get a BUG logged with support ?
Is there any news on that? I am using ArcGIS Enterprise 11.5 and want to update an existing Vector Tile Layer daily, but I keep getting an error:
raise Exception(errormessage)
Exception: Replace service error: Failed to replace service 'Hosted/xyz.VectorTileServer' for 'Hosted/xxx_TEMP.VectorTileServer'.
I was using gis.content.replace_service as well as sending an Payload via POST to the REST API (sharing/rest/content/users/<user>/replaceService) - I also tried arcpy. But getting the same error. If I use the ItemID hardcoded, it's working in most cases.
Has anyone of you found a workaround?
@RainerRockenbauer I dit not reveived more help from ESRI, but I found a workaround that works for now.
Instead of using arcpy.server.ReplaceWebLayer, I use object.update.
def getPortalElementByTitle(portal, title):
element = None
elementList = portal.content.search(query=f"title:{title}")
if elementList :
for oElement in elementList :
if oElement.title == title:
element = oElement
break
return element
existingVectorTile = getPortalElementByTitle(portail, service)
newVectorTile = portal.content.add({
'title': titre,
'type': type,
'tags': tags,
'description': description
}, data=data)
newVectorTile= newVectorTile.publish()
existingVectorTile.update(data=newVectorTile.download(sTempFolder))