I have recently deployed windows VM using azure bicep. Today i have updated some NSG rules. tried to run .bicep file its shows below error.
{"code":"Deployment Failed","details":[{"code":"PropertyChangeNotAllowed","target":"osDisk.name","message":"Changing property ‘osDisk.name’ is not allowed."}]}
Note : iam using VM module
How to fix this issue in azure bicep
2
Answers
Have you made any changes on
osDisk.name
? This property is not allowed to change on deployed resource. Some properties can’t be modified on existing resources and re-deploy, but some can. you can refer the docs here to findPropertyChangeNotAllowed
error explanation.The error "Changing property ‘osDisk.name’ is not allowed" occurs because certain properties of a VM, like
osDisk.name
, are immutable once the VM is created. To resolve this issue, you need to ensure that you’re not attempting to change immutable properties during your update by followingPropertyChangeNotAllowed
explanation as wenbo suggested. As you mentioned you only changed the NSG rules during which you got the error.I tried the same VM deployment bicep and then changes the NSG rules later during which I took care not changing any properties related to OS-disk because of which I was able to achieve the requirement you’re looking for.
vmdep.bicep:
Now run the command
deployment succeeded:
Now I Tried to upgrade NSG rules alone as shown below without changing any parameters of OS-disk
nsgupgrade.bicep:
now run the deployment command
Deployment succeeded: