Hi Team, I'm running into the following error when...
# azure
n
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
did you make a code change?
n
Yes I did introduce several changes.
b
can you share your code and wht you changed? some options/parameters are immutable
n
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
that's kinda hard to read sorry, can you wrap the code in 3 backticks each side
```
```
n
My bad
Copy code
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
Copy code
var imageId = new Pulumi.Config().Require("imageId");
b
are you using auto naming? it looks like that value is immutable
n
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
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
Copy code
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
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
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
which version of the provider are you using?
@numerous-action-56322 I think it's this property:
Copy code
ComputerName = $"{orgname}-{gridname}-n{i+1}",
can you try removing it?
n
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
Definitely a bug, please file an issue
n
Will do. Thanks
b
hey @numerous-action-56322 did you manage to get an issue opened here?
n
b
@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
@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
Copy code
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.
Copy code
var widget = new Pulumi.Kubernetes.ApiExtensions.CustomResource("widget", new WidgetArgs
{
    Spec = new WidgetSpecArgs
    {
        Input = "something",
    }
}, pulumi.ReplaceOnChanges([]string{"spec.input"}));
637 Views