Using copyDataToServer when publishing a Map Service with a Feature Service to a standalone ArcGis Server

718
2
08-17-2022 02:05 PM
NWSCAD4
New Contributor II

I have an ArcGis Project with a single map that has a single layer whose source is in an Enterprise Geodatabase. I want to use arcpy to publish this map to my standalone ArcGis Server (version 10.9.1) as a Map Service with a Feature Service and I want the source data to be copied to the server when I publish the services.

If I use arcpy.mapping and an mxd file containing the same single layer, then I am able to publish a Map Service with a Feature Service to my standalone ArcGis Server and the source data is copied to the server as specified via the copy_data_to_server parameter of the arcpy.mapping.CreateMapSDDraft method. However, I do not want to use ArcGis Desktop an mxd files anymore, I want to use ArcGis Pro and mapx files instead.

I have a python script where I use arcpy.mp to open the ArcGisProject, get a reference to the map and then I call arcpy.sharing.CreateSharingDraft as follows, to get a MapServiceDraft object:

mapSd = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", "MyMapService", mapObj)

Then I set the following properties on the MapServiceDraft as follows:

mapSd.offline = False
mapSd.copyDataToServer = True
mapSd.targetServer = connection_file

Then I call mapSd.exportToSDDraft to create the sddraft file. I subsequently modify the sddraft file as shown in the "Publish a map service with a feature service" sample in the MapServiceDraft online documentation. Finally, I call arcpy.server.StageService to generate a service definition file based on my draft and I get the following error:

arcgisscripting.ExecuteError: ERROR 001272: \Analyzer errors were encountered ([{"code":"00231","message":"Layer's data source must be registered with the server","object":"MyLayer"}]).

The point of setting copyDataToServer is to trigger the arcpy infrastructure to copy the data from the layer's source, to the ArcGis Server because I do not want to register my data source with the server. The documentation for copyDataToServer on MapServiceDraft certainly suggests that setting this value to True will cause the source data to be copied to the server. But instead of that happening, I get an error suggesting that I have no choice but to register my source, which I do not want to do.

Note, that if I do not modify the sddraft file, such that only a Map Service is published without a corresponding Feature Service, then the publish is successful. This is relevant because it validates the rest of my script apart from the modification of the sddraft file to trigger the creation of a Feature Service along with the Map Service. But of course my goal is to publish a Map Service with a Feature Service as I have always done with ArcMap mxd files and arcpy.mapping.

Does copyDataToServer work?

0 Kudos
2 Replies
RogerDunnGIS
Occasional Contributor II

I visited the documentation page for the MapServiceDraft class and found this bit to the right of the copyDataToServer property:

"Specifies whether the data in your map will be copied to the server. A value of True will copy all of the data in your map, including data that is registered with your server."

I wonder if it requires that the server have a registered data source so that the server can perform the copy, as opposed to ArcGIS Pro packing up, say, local file geodatabases and shapefiles.  Maybe ArcMap was programmed to copy enterprise geodatabase data, but in Pro it's the Server that does that.  I don't know for sure; just guessing.

I understand the desire not to publish the connection to Server, so I'll try and address the unasked question here.  When Server is federated with Portal, you can decide to make the connection an item or not, and whether to share it or not.  Whether you share the connection or not should have no bearing on who can use the service.  You might be able to keep your connection to the database private in Server/Portal.

Here is a screenshot from my Server Administrator.  You can see a column on the right that allows the conversion of database connections to items (one person icon) or the sharing of those items to groups (two people icon).  You can also see how the connection I've selected and clicked Settings for allows (or disallows) the copying of data to the server.

RogerDunnGIS_0-1665092154100.png

 

NWSCAD4
New Contributor II

Thank you for the reply.  We are using a stand alone ArcGis Enterprise server at version 10.9.1.  So Portal doesn't come into play at all.  We don't want to register our source because we don't want ArcGis Server holding connections to it.  So we have historically used "CopyDataToServer" so ArcGis Server will make its own copy of the data at at the time of publishing, leaving the source unaffected by the service.

We tried numerous approaches, but we did not find a single scenario that would allow us to use "CopyDataToServer" without registering our source.  In the end, we discovered that we actually don't need the feature service.  It may be that years ago, when our system was designed, we did, but we do not now.  Therefore, we are just going publish the Map Service without a Feature Service and we don't need to deal with this change in behavior of the copyDataToServer functionality.

0 Kudos