In this post, .net development company experts will share the details about hosting .net core services with Service fabric. This post will help developers who want to use service fabric to host .net core services.
It is possible to host .net Core services using the concept of Service fabric. The blog is very useful for developers who want to host .Net core services in the form of micro services with the help of azure service Fabric. Hosting by Service Fabric provides a great way for hosting micro services in today’s world to get benefits like scalability, high density and upgradability.
One of the important benefits of Asp.net Core is the ability to write cross-platform apps with same block of code. If a user plans to host a set of services on Linux and want hosting of same services by using Service fabric, then it can be easily achieved with the help of guest services property in Service Fabric. Service Fabric can be used to run with any kind of application like Asp.Net Core, Nodejs or native applications. These applications will be referred as guest executables by Service Fabric. It treats these guest executables as stateless services. Hence on the basis of availability, they are placed over nodes in cluster.
The current template of service fabric allows users to host various .Net services that targets on complete .Net frameworks such as the framework 4.5. If a service is already available that target on only .NetCoreApp or both the .Net Framework 4.0 and the .NetCoreApp, then the available .Net Core templates cannot be used since the only Framework supported by the Service Fabric is .Net Framework 4.5. As a workaround, the solution is to use guest services for projects targeting .NetCore app as target framework.
The application package of Service fabric:
Every application deployed on the cluster of Service Fabric has to follow specific directory structure as shown below:
The root of the directory consists of the ApplicationManifest.xml for defining the complete application. Each service in the application contains a subdirectory that contains the required artifacts for each service.
For deploying any guest service, copy all the required binaries in the Code folder. The data and config folders are not mandatory and are used only when required. It is very easy to achieve the required directory structure in .NetCoreApp projects from Visual Studio with the help of publish. Once a service is published to the folder, all the binaries needed for this service are copied to the folder. The publish location can then be used and mapped to the Code folder in the service.
To publish the service of .Net core app, right click on the core project and select publish. Create a target for custom publish and give it an appropriate name for describing the published service as shown below:
Click on connection. ADD the target location where the project needs to be published. Select file system from the publish method drop-down.
Go to the settings section. Select the configuration as Release-Any CPU.
The steps shared by .net development company experts are for reference purposes only. You can follow them and share your experience with other readers regarding hosting with service fabric.