ArcGIS server 10.8.1
I have well over 200 services in my testing environment. I would like to change them all to shared. Is there a way using notebook?
@Anonymous User Yes, you will need to iterate through each service, check if it's dedicated, and then update the provider if it is using the ChangeProvider operation. Ex:
import requests, json # Variables username = 'siteadmin' password = 'siteadmin' server = "ags.esri.com" # Disable warnings requests.packages.urllib3.disable_warnings() # Function to change provider def changeProvider(): print("\tChanging provider") url = serviceURL + '/changeProvider' params = {'f': 'pjson', 'token': token, 'provider': 'DMaps'} r = requests.post(url, data=params, verify=False) response = json.loads(r.content) print(f"\t{response['status']}") # Generate ArcGIS Server Token tokenURL = f'https://{server}:6443/arcgis/admin/generateToken' params = {'f': 'pjson', 'username': username, 'password': password, 'client': 'requestip'} r = requests.post(tokenURL, data=params, verify=False) response = json.loads(r.content) token = response['token'] # Query AGS service propoerties in ROOT baseUrl = f'https://{server}:6443/arcgis/admin/services' params = {'f': 'pjson', 'token': token} r = requests.post(baseUrl, data=params, verify=False) catalog = json.loads(r.content) services = catalog['services'] for service in services: if service['type']!= 'StreamServer' and service['type'] != 'GPServer': params = {'f': 'pjson', 'token': token} serviceURL = f"{baseUrl}/{service['serviceName']}.{service['type']}" r = requests.post(serviceURL, data=params, verify=False) response = json.loads(r.content) # Check if provider is dedicated if response['provider'] == 'ArcObjects11': # Execute function to change provider print(f"{service['serviceName']} is dedicated") changeProvider() # Query AGS service propoerties in folders folders = catalog['folders'] for folderName in folders: if str(folderName) not in ('Hosted', 'System', 'Utilities', 'DataStoreCatalogs'): baseUrl = f'https://{server}:6443/arcgis/admin/services/{folderName}' params = {'f': 'pjson', 'token': token} r = requests.post(baseUrl, data=params, verify=False) catalog = json.loads(r.content) services = catalog['services'] for service in services: if service['type'] != 'StreamServer' and service['type'] != 'GPServer': serviceURL = f"{baseUrl}/{service['serviceName']}.{service['type']}" r = requests.post(serviceURL, data=params, verify=False) response = json.loads(r.content) if response['provider'] == 'ArcObjects11': # Execute function to change provider print(f"{service['serviceName']} is dedicated") changeProvider()
Hi @Anonymous User,
You can use the Change Provider operation.
This operation is used to update an individual service to use either a dedicated or shared instance type is right in the documentation and I see no way to do multiple. One at at time is just as easily completed using the server manager. Thanks
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.