Feature Layer Overwrites Fail but Vector Tiles Do Not

517
6
04-21-2022 11:02 AM
QuayeT
by
New Contributor II

I'm using the API to overwrite hosted feature layers and vector tiles using the technical support article below. If ArcGIS Pro isn't running, feature layers don't get overwritten but vector tiles do.  I receive an error saying, "Error Creating and Republishing Service Definition file for <layer name>. ValueError('Unable to connect to portal.')".  As soon as I open ArcGIS Pro and run the script, the feature layers do get overwritten.  I don't even have to be connected to portal.  Any ideas?  This one has everyone stumped, including ESRI!

Overwrite hosted feature services from ArcGIS Pro to ArcGIS Online using Python

https://support.esri.com/en/technical-article/000023164

0 Kudos
6 Replies
kdoshiwork
New Contributor II
  • Basically, its validating the license as hosted data is stored in DataStore once you open your ArcGIS Pro logged in to your portal  it runs your script with Python 3.x
  • Are you running your python script from Task Scheduler ? if yes initialize your python.exe from arcgispro-py3 folder and you will not need to keep your ArcGIS Pro open to run the script.
0 Kudos
QuayeT
by
New Contributor II

Yes, we do use Task Scheduler and reference "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" and the script as the argument but the script still fails on the feature layers.  Also, I'm not signed into any portal in ArcGIS Pro for the script to run without error.

0 Kudos
jcarlson
MVP Esteemed Contributor

Vector tiles are a bit trickier to "overwrite", and can be quite the headache to work with in that way.

In recent updates, you can now publish your feature service with a vector tile service "linked" to it.

jcarlson_0-1650632842932.png

Once published, all you need to do is tell the vector tile service to rebuild its cache, no need to overwrite.

jcarlson_1-1650632867174.png

And for scripting purposes, that button's python equivalent is right here.

Semi-related question: is "overwriting" really what you want to do here? Unless you're making changes to the schema and/or layer arrangement, you're probably better off using a truncate / append process.

Edit to add: For the portal issues, since you're using the ArcGIS Python API, why not use arcgis.GIS('url', 'user', 'password')?

- Josh Carlson
Kendall County GIS
Tiffany_Wu
New Contributor III

Hi Josh! In contrast to the original post here, I have successfully overwritten my hosted feature service but having an error with my tile service. I'm not as familiar with vector tile services but the one I've published is a vector tile service/package. I published directly from ArcGIS Pro, perhaps before the new functionality. Is the recommended workflow to publish a feature service with a vector tile service linked to it? How would I update the vector tile service routinely, using a hosted layer in AGOL that is updated in real-time? 

The error I am having is with the arcpy .publish function where it asks me to specify a file type, but then says my item is not supported. I'm not sure what the issue is.

0 Kudos
QuayeT
by
New Contributor II

Thanks for responding Josh but we are only having issues overwriting feature layers.

0 Kudos
jcarlson
MVP Esteemed Contributor

Ah, sorry! I sort of flip-flopped your post title in my mind when I read it.

So, why is it you're overwriting the feature layer, as opposed to a truncate/append process?

- Josh Carlson
Kendall County GIS
0 Kudos