Skip to content

Commit 327f6a5

Browse files
authored
Updated code example to get the most recently created node
Per the text above this example, the most recently created node is the one with the greatest `NodeInstanceId` property, so you can get it by just sort descending on this property and grabbing the first one. The code that was provided split the name of the node to find the node with the highest number in its name, but this didn't work if you had more than 10 nodes because _node1_10 (for example) was treated as if it was numbered 1.
1 parent 94af94f commit 327f6a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

articles/service-fabric/service-fabric-cluster-scale-up-down.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The steps for manually removing node state apply only to node types with a *Bron
108108
To keep the nodes of the cluster evenly distributed across upgrade and fault domains, and hence enable their even utilization, the most recently created node should be removed first. In other words, the nodes should be removed in the reverse order of their creation. The most recently created node is the one with the greatest `virtual machine scale set InstanceId` property value. The code examples below return the most recently created node.
109109

110110
```powershell
111-
Get-ServiceFabricNode | Sort-Object { $_.NodeName.Substring($_.NodeName.LastIndexOf('_') + 1) } -Descending | Select-Object -First 1
111+
Get-ServiceFabricNode | Sort NodeInstanceId -Descending | Select -First 1
112112
```
113113

114114
```azurecli

0 commit comments

Comments
 (0)