Looks like you are close. My suggestion is to make reproducible snippets that anyone can paste into a freshly started Slicer instance and reproduce your question. Disconnected lines of code are really impossible to debug, but I can tell they aren’t part of a real program because of syntax errors like setFileName instead of SetFileName. Formulating such concise and reproducible examples can often help you find the issues yourself. We often point to this page for guidance: http://sscce.org/
I found the problem: In method 1, I needed to add the storageNode to the scene… otherwise the storageNode.GetID() is not available to the rest of nodes, and it cannot be “AddedAndObserved”.
This now works:
import numpy as np
data = np.random.rand( 50, 50, 50 );
volumeNode1 = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode');
slicer.util.updateVolumeFromArray(volumeNode1, data );
storageNode1 = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLVolumeArchetypeStorageNode') # this creates storageNode and adds it to the scene
storageNode1.SetFileName( "C:/users/marc/data.czi" )
volumeNode1.AddAndObserveStorageNodeID( storageNode1.GetID() )
print( "Method 1", volumeNode1.GetStorageNode() )