I have a number of ArcGIS Pro projects where I need to change one layer that used to be a feature class in our EGDB (aka SDE) to a feature service.
The online help provides various approaches and in this post, @GaetanPRU provides some code to update the connection properties of a shape file. Following that lead:
# I have a list created a priori of my Pro projects:
for a in aprxList:
aprx = arcpy.mp.ArcGISProject(a[0])
map = aprx.listMaps("Live SDE")[0]
layer = map.listLayers("MSD.SLCOMSD.AddressGridMSD")[0]
cp = layer.connectionProperties
If I list cp, I get the dictionary of the connection properties:
cp
{'dataset': 'MSD.SLCOMSD.AddressGridMSD',
'workspace_factory': 'SDE',
'connection_info': {'authentication_mode': 'DBMS',
'database': 'myDB',
'dbclient': 'sqlserver',
'db_connection_properties': '"bla bla bla',
'password': '<yeahRight>',
'instance': '"sde:sqlserver:bla bla bla',
'server': 'bla bla bla',
'user': 'myUser',
'version': 'sde.DEFAULT'}}
However, I'm unsure as to what my next step is to update the connection properties to a feature service.
That should just about do it....