Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get name of node on which my code is executing in azure fabric service?

How can I get the name of the machine on which my code is running in a Azure Fabric Cluster for logging purposes?

I am running a c# code in a fabric cluster with some nodes. I would like to log some information along with the machine name. I am using FabricRuntime, but it is not helping me. What is the best way to do this ?

Thanks.

like image 654
ashok Avatar asked May 14 '17 00:05

ashok


People also ask

What is node in Azure service fabric?

In this article A Service Fabric cluster is a network-connected set of virtual or physical machines into which your microservices are deployed and managed. A machine or VM that's part of a cluster is called a node.

How many nodes can be maintained on a service fabric cluster in Azure?

A single Service Fabric node type/scale set can not contain more than 100 nodes/VMs. To scale a cluster beyond 100 nodes, add additional node types.

What is seed node in service fabric?

Service Fabric has the concept of seed nodes. These are nodes that maintain the availability of the underlying cluster. Seed nodes help to ensure that the cluster stays up by establishing leases with other nodes and serving as tiebreakers during certain kinds of failures.

How do you add a node to a service fabric cluster?

Copy or download the standalone package for Service Fabric for Windows Server to the VM/machine and unzip the package. Run PowerShell with elevated privileges and go to the location of the unzipped package. Run the AddNode. ps1 script with the parameters describing the new node to add.


2 Answers

Use the NodeContext property of the ServiceContext.

So, given the context of a service (either stateful or stateless) or actorservice you can call context.NodeContext.NodeName to retrieve the node name.

The ServiceContext has a lot of oher properties as well that can be useful for logging purposes.

For a complete example of getting node and service details see this repo.

like image 112
Peter Bons Avatar answered Nov 14 '22 22:11

Peter Bons


FabricRuntime.GetNodeContext().NodeName
like image 43
Zizou developer Avatar answered Nov 14 '22 22:11

Zizou developer