https://pulumi.com logo
Title
n

numerous-action-56322

08/31/2021, 7:03 PM
Hi Team, I'm running into the following error when trying to update the image reference of a VM: error: autorest/azure: Service returned an error. Status=<nil> Code="PropertyChangeNotAllowed" Message="Changing property 'imageReference.id' is not allowed." Target="imageReference.id". Anyone facing similar issue ?
b

billowy-army-68599

08/31/2021, 7:26 PM
did you make a code change?
n

numerous-action-56322

08/31/2021, 7:31 PM
Yes I did introduce several changes.
b

billowy-army-68599

08/31/2021, 7:34 PM
can you share your code and wht you changed? some options/parameters are immutable
n

numerous-action-56322

08/31/2021, 7:37 PM
Unfortunately I did not track what was changed, this is PoC. I'm going to start again with a blank slate and see if I can reproduce the issue just by changing the value of the image reference.
So I did restart from scratch, using the image reference as a string in the configuration and got the very same error message after changing its value in the configuration:
var dataDisk = new AzureNative.Compute.Disk($"{orgname}-{gridname}-n{i+1}-datadisk", new AzureNative.Compute.DiskArgs{
                
CreationData = new AzureNative.Compute.Inputs.CreationDataArgs
                
{
                    
CreateOption = "Empty",
                
},
                
DiskSizeGB = 100,
                
ResourceGroupName = org.ResourceGroupName
            
});
            
var vm = new  AzureNative.Compute.VirtualMachine($"{orgname}-{gridname}-n{i+1}",
                
new AzureNative.Compute.VirtualMachineArgs
                
{
                    
ResourceGroupName = org.ResourceGroupName,
                    
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
                    
{
                        
VmSize = "Standard_A1_v2",
                    
},
                    
Location = regionname,
                    
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
                    
{
                        
NetworkInterfaces = new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
                        
{
                            
Id =  networkInterface.Id,
                            
Primary = true,
                        
},
                    
},
                    
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
                    
{
                        
AdminPassword = "xxxxxxxxxxxx",
                        
AdminUsername = "xxxxxxxxxxxx",
                        
ComputerName = $"{orgname}-{gridname}-n{i+1}",
                        
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
                        
{
                            
EnableAutomaticUpdates = true,
                            
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
                            
{
                                
AssessmentMode = "ImageDefault",
                            
},
                            
ProvisionVMAgent = true,
                        
},
                    
},
                    
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
                    
{
                        
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
                        
{
                            
Id = imageId,
                        
},
                        
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
                        
{
                            
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
                            
CreateOption = AzureNative.Compute.DiskCreateOptionTypes.FromImage,
                            
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
                            
{
                                
StorageAccountType = "Standard_LRS",
                            
},
_//Name = $"{orgname}-{gridname}-n{i+1}-osdisk",_
                        
},
                        
DataDisks = new AzureNative.Compute.Inputs.DataDiskArgs
                        
{
                            
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
                            
CreateOption = AzureNative.Compute.DiskCreateOptionTypes.Attach,
                            
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
                            
{
                                
StorageAccountType = "Standard_LRS",
                                
Id = dataDisk.Id
                            
},
                            
DiskSizeGB = 100,
                            
Lun = 1,
                        
}
                    
},
                
});
b

billowy-army-68599

08/31/2021, 8:44 PM
that's kinda hard to read sorry, can you wrap the code in 3 backticks each side
```
```
n

numerous-action-56322

08/31/2021, 8:46 PM
My bad
var dataDisk = new AzureNative.Compute.Disk($"{orgname}-{gridname}-n{i+1}-datadisk", new AzureNative.Compute.DiskArgs{
                CreationData = new AzureNative.Compute.Inputs.CreationDataArgs
                {
                    CreateOption = "Empty",
                },
                DiskSizeGB = 100,
                ResourceGroupName = org.ResourceGroupName
            });
            
            var vm = new  AzureNative.Compute.VirtualMachine($"{orgname}-{gridname}-n{i+1}",
                new AzureNative.Compute.VirtualMachineArgs
                {
                    ResourceGroupName = org.ResourceGroupName,
                    HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
                    {
                        VmSize = "Standard_A1_v2",
                    },
                    Location = regionname,
                    NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
                    {
                        
                        NetworkInterfaces = new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
                        {
                            Id =  networkInterface.Id,
                            Primary = true,
                        },
                    },
                    OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
                    {
                        AdminPassword = "xxxxxxxxxxxx",
                        AdminUsername = "xxxxxxxxxxxx",
                        ComputerName = $"{orgname}-{gridname}-n{i+1}",
                        WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
                        {
                            EnableAutomaticUpdates = true,
                            PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
                            {
                                AssessmentMode = "ImageDefault",
                            },
                            ProvisionVMAgent = true,
                        },
                    },
                    StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
                    {
                        ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
                        {
                            Id = imageId,
                        },
                        OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
                        {
                            Caching = AzureNative.Compute.CachingTypes.ReadWrite,
                            CreateOption = AzureNative.Compute.DiskCreateOptionTypes.FromImage,
                            ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
                            {
                                StorageAccountType = "Standard_LRS",
                            },
                            //Name = $"{orgname}-{gridname}-n{i+1}-osdisk",
                        },
                        DataDisks = new AzureNative.Compute.Inputs.DataDiskArgs
                        {
                            Caching = AzureNative.Compute.CachingTypes.ReadWrite,
                            CreateOption = AzureNative.Compute.DiskCreateOptionTypes.Attach,
                            ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
                            {
                                StorageAccountType = "Standard_LRS",
                                Id = dataDisk.Id
                            },
                            DiskSizeGB = 100,
                            Lun = 1,
                        }
                    },
                });
with
var imageId = new Pulumi.Config().Require("imageId");
b

billowy-army-68599

08/31/2021, 8:49 PM
are you using auto naming? it looks like that value is immutable
n

numerous-action-56322

08/31/2021, 8:51 PM
I do
This is probably a silly question, but how do I workaround that ? I mean how can I update a virtual machine when there is a new image that I want to push ?
b

billowy-army-68599

08/31/2021, 8:58 PM
can you show me the diff when you go to update? if you're using autonaming, it should replace the VM with a new VM using the new image ID
n

numerous-action-56322

08/31/2021, 9:01 PM
Type                                    Name                  Plan       Info
pulumi:pulumi:Stack                     snqacloud-csharp-dev
~   └─ azure-native:compute:VirtualMachine  org1-p1-n1            update     [diff: ~storageProfile]
I can definitely see the suffix for the virtual machine resource name in Azure portal.
b

billowy-army-68599

08/31/2021, 9:42 PM
yeah I'm thinking this might be a bug at this point, would you mind filing an issue in github.com/pulumi/azure-native
it should do a replace, not an update
n

numerous-action-56322

08/31/2021, 9:45 PM
Okay thank you ! Is there anything else I can do to confirm this is a bug and rule out that I'm doing soething wrong ?
b

billowy-army-68599

08/31/2021, 10:23 PM
which version of the provider are you using?
@numerous-action-56322 I think it's this property:
ComputerName = $"{orgname}-{gridname}-n{i+1}",
can you try removing it?
n

numerous-action-56322

08/31/2021, 11:15 PM
Thanks for the thorough follow up. I’ll do it as soon as I get a chance and keep you informed on the outcome.
I'm afraid I cannot remove it, it is a required ppty.
error: Code="InvalidParameter" Message="Required parameter 'computerName' is missing (null)." Target="computerName"
b

billowy-army-68599

09/01/2021, 3:01 AM
Definitely a bug, please file an issue
n

numerous-action-56322

09/01/2021, 1:09 PM
Will do. Thanks
b

billowy-army-68599

09/01/2021, 3:01 PM
hey @numerous-action-56322 did you manage to get an issue opened here?
n

numerous-action-56322

09/01/2021, 3:06 PM
b

billowy-army-68599

09/01/2021, 3:24 PM
@numerous-action-56322 I discussed privately with Mikhail, to get you unblocked you can use `replaceOnChanges`: https://www.pulumi.com/docs/intro/concepts/resources/#replaceonchanges
n

numerous-action-56322

09/01/2021, 3:26 PM
@billowy-army-68599 Thanks again.
@billowy-army-68599 I've been trying to implement the provided workaround, however updates are still failing with the very same error message, as if the additional CustomResourceOptions passed as a third argument were ineffective
new CustomResourceOptions{
                    ReplaceOnChanges =new List<string>(new string[] {"imageReference.id"} ),
                }
I even tried to relax the property path by using just "imageReference" and the the joker "*" . Any idea ? Btw, I could not reuse the C# sample from the documentation since I don't know what the var
pulumi
stands for. Could this be the reason why my updates are still not working ? For your convenience, here's the sample provided in the documentation , the var `pulumi`appears on the last line only.
var widget = new Pulumi.Kubernetes.ApiExtensions.CustomResource("widget", new WidgetArgs
{
    Spec = new WidgetSpecArgs
    {
        Input = "something",
    }
}, pulumi.ReplaceOnChanges([]string{"spec.input"}));