Does this sample help? Feature layer extrusion | ArcGIS for Developers
What do you mean to publish as a service?
Then go load it？
In that example you skip steps 1. and 2. and instead use ShapefileFeatureTable to create a FeatureLayer, then follow steps 3., 4., and 5.