I need to publish a feature service using python from an arcgis pro map to arcgis enterprise (with a federated server). The feature service should be referenced to enterprise geodatabase (not hosted).
I’ve written a script with the following steps/logic but at the end it doesn’t give me what I need. Do you suggest a better solution?
( this is not the code, just the logic. I can share it if it is needed.)
- Publish map service:
o Sign in to the portal (arcpy.SignInToPortal)
o Create a sharing draft form arcgis pro map:
o sharing_draft = m.getWebLayerSharingDraft(server_type="FEDERATED_SERVER", service_type="MAP_IMAGE", service_name=service)
o Export to SD Draft: sharing_draft.exportToSDDraft(sddraft_output_filename)
o Staging: arcpy.server.StageService(in_service_definition_draft=sddraft_output_filename, out_service_definition=sd_output_filename)
o arcpy.server.UploadServiceDefinition
- Enable Feature Access:
o Connect to service api with arcgis Rest API and change the json file:
o response = requests.post(service_url, data=params, verify=True)
o data = response.json()
o data['extensions'][i]['enabled'] = 'true'
o updated_svc_json = json.dumps(data)
o edit_svc_url = service_url + "/edit"
o params = {'token': token, 'f': 'pjson', 'service': updated_svc_json}
o response = requests.post(edit_svc_url, data=params, verify=True)
The script publishes map service from arcgis pro map, referencing to enterprise geodatabase (not hosted), enables the feature access BUT since the server is federated with the portal the script DOESN’T create feature layer item in portal which is the missing part in my workflow. Please advise.