Delete ArcGIS Server services en masse?

1368
6
11-30-2017 01:28 PM
CassandraFollett
New Contributor III

Let's say we've got, you know, 8 pages of services that need to be removed. That's time consuming. 

Are there ways to programmatically remove services much faster than through the GUI in Manager?

(other ways to programmatically / through scripts alter a large number of services would also be of interest, such as starting/stopping/changing pooling or other options)

Installation is ArcGIS Server 10.5 on Linux. 

*Update*

This question was posed because the documentation here says only two options (Manager or ArcMap):
Delete a service—Documentation | ArcGIS Enterprise 

However Vince here, reminded me of the ArcGIS Rest API. Among other tasks and features, it does mention how to Delete Service through a POST with an admin token here:

ArcGIS REST API 

So, I consider this question somewhat resolved, though would keep open out of interest to hear other ways people address managing services programmatically in their organization (custom scripts, etc.)

0 Kudos
6 Replies
VinceAngelo
Esri Esteemed Contributor

There are code samples for using Python to call the REST API.  You need to get a token first.
I don't have my source handy at the moment, but it isn't more than a score or two lines of

actual code.

 -V

CassandraFollett
New Contributor III

So basically you're running that through ArcMap / ArcGIS Pro python interpreter in that case...? 

0 Kudos
CassandraFollett
New Contributor III

I'm not sure if your code was going to involve ArcMap / ArcGIS Pro or not.

But, mentioning the REST API had me look for the ArcGIS REST API.

It seems that Delete Folder and Delete Service (along with many other tasks and requests) are capable of doing through a URL with administrator token, like so: 
ArcGIS REST API 

This is probably the answer I am looking for. 

0 Kudos
VinceAngelo
Esri Esteemed Contributor

Any Python will do, though if you have more than the default urllib it will likely be easier.

- V

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Why don't you just create an admin connection in ArcCatalog and select multiple and erase them there. I think that would work??

0 Kudos
CassandraFollett
New Contributor III

ArcMap and ArcCatalog aren't actually in my workflow, so I wanted to avoid having to boot up desktop applications to manage services.


I think Vince might have been referring to using Python within ArcMap to call the REST API, but that made me remember that I don't need a client at all to do this... so I just successfully deleted the folder with all 8 pages with a token and POST... That's a solution that keeps me happy