I'm using the Graph visual in Azure Monitor Workbooks. The problem is that with every refresh the layout looks randomly differently.
Is there anyway to programmatically fix the layout (i.e. the positioning of the nodes)?
1)
Unfortunately, there's no way to guarantee it. The portal's graph control is relatively limited in this regard.
One thing you can possibly do is to make sure that your query has a predictable order to the rows, so that the rows always are in the same order. If the nodes are in the same order and edges are in the same order in the results, hypothetically it should lay out the same every time.