I have some queries on service definition / staging files:
Query 1: why are service definitions and other staging files retained on ArcGIS Online after they have been used to publish a hosted feature layer from ArcGIS Pro?
Context: when publishing from ArcGIS Pro to ArcGIS Online (AGOL) in order to create a hosted feature layer, the platform creates two items: 1 Service Definition (SD) file; 1 hosted feature layer. It is not possible to delete the SD file via the standard user interface as the hosted feature layer is 'dependent' on it - so the standard user would leave it alone.
The Problem: this doesn't actually appear to be the case... it is possible to delete the SD file via the ArcGIS Python API with no ill effect on the hosted feature layer. Publish a brand-new layer from Pro to AGOL as a hosted feature layer; delete the generated SD file; make changes in Pro; overwrite the hosted feature layer = no problem. But you will get, yes, another SD file.
Reference: The following post referred to a possible requirement by ArcMap to use the SD files to enable overwriting/updating: Solved: Keep Service Definition Files? - Page 2 - Esri Community
This is going back years and even at that time a user of Pro was flagging the behaviour I'm describing. I can only imagine in 2023 there are many more users have moved from Map to Pro and may be having the same awkward thoughts about this when they see the number (and size!) of these files building up over time.
Query 2: what is the credit charge for service definition files / staging files?
The same post above included the following sentence from an ESRI employee:
A note on credits. The credit charges from the SD file will come from Tile and Data storage at a cost of 1.2 credits per 1 GB per month. So depending on you SD file size, credit charges will be minimal.
As of 2023 there is no clear reference to Service Definition files at all on the AGOL 'Understand credits' page in order to confirm this: Understand credits—ArcGIS Online Help | Documentation
Whilst I hope that sentence from a forum post in 2015 is accurate; the mixed-message that that 'dependent' delete-blocking action above sends is that the SD file is considered part of the hosted feature layer - where feature storage rates are 2.4 credits per 10 MB per month. So what it is?
The published documentation and guidance needs to be clearer on this topic. In the meantime, if anyone can shed any light, that would be appreciated?
[Example of 'other staging files' beyond SD files: the original Shapefile item that's created when adding and publishing a zipped Shapefile as a hosted feature layer. Same behaviour as described above.]
I'd also love to know the answer to both of these questions. It would also help our content be a bit 'cleaner' since we would have multiple files with the same name, which does confuse some of our users. Thanks for posting this, hope someone has an answer!