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 microservices with the help of azure Service Fabric. Hosting by Service Fabric provides a great way for hosting microservices 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 the same block of code. It saves effort and time in writing the code. It could be one of the reasons businesses hire ASP.NET developers. If a user plans to host a set of services on Linux and want hosting of the 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 to as guest executables by Service Fabric. It treats these guest executables as stateless services. Hence based on availability, they are placed over nodes in the cluster.
The current template of service fabric allows users to host various .Net services that target complete .Net frameworks such as 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 project targeting .NetCore app as target framework.
The application package of Service fabric:
Every application deployed on the cluster of Service Fabric has to follow a 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.
A subdirectory is composed of the following;
- ServiceManifest.xml: The service is defined in this file.
- Code: The service code is present in this directory.
- dConfig: It contains the configuration settings of the service in the Settings.xml file.
- Data: It is used to store the local data needed by the 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 publishing. 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.
PUBLISHING OF .NETCOREAPP SERVICE
To publish the service of the .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.