I'm migrating a Cloud Service application to a Service Fabric application. I'm looking for a ServiceEnvironment equivalent to RoleEnvironment in order to get the service name from the environment variables. https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-environment-variables-reference
Asked
Active
Viewed 68 times
0
-
These are "normal" environment variables, right? Have you tried Environment.GetEnvironmentVariable() ? https://learn.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable?view=netcore-3.1 – Francesc Castells Apr 30 '20 at 21:30
-
I'm looking for a more elegant way to use it instead of environment variable. Of course, I can create a wrapper object. – Shimon Shrem Apr 30 '20 at 21:52
-
Are you looking for a way of managing your services configuration not using environment variables or a different way of reading environment variables? If it's the first, then use Settings.xml https://stackoverflow.com/q/36640752/352826, if it's the latter https://stackoverflow.com/q/33928204/352826 – Francesc Castells Apr 30 '20 at 22:16
-
As I wrote, I looking for a wrapper object in the framework to read the environment variables of the fabric service like Fabric_ServiceName, Fabric_ServicePackageName. I always can create such a wrapper object. However, I'm looking for an object in the framework. – Shimon Shrem May 03 '20 at 17:00
-
In the constructor of your microservice, you get an instance of ServiceContext (the concrete class depends on the type of microservice). This Context https://learn.microsoft.com/en-us/dotnet/api/system.fabric.servicecontext?view=azure-dotnet contains a lot of information, with things like ServiceName, ServiceType, information about the Node, information about the Application, etc. – Francesc Castells May 03 '20 at 17:23
-
Thanks @FrancescCastells for your answer! – Shimon Shrem May 04 '20 at 07:46