diff --git a/azure/table_azure_compute_virtual_machine.go b/azure/table_azure_compute_virtual_machine.go index 052604e0..e1477a7c 100644 --- a/azure/table_azure_compute_virtual_machine.go +++ b/azure/table_azure_compute_virtual_machine.go @@ -47,6 +47,12 @@ func tableAzureComputeVirtualMachine(_ context.Context) *plugin.Table { Description: "The friendly name that identifies the virtual machine.", Type: proto.ColumnType_STRING, }, + { + Name: "virtual_machine_scale_set", + Description: "Scale set details for virtual machines managed in flexible orchestration mode.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("VirtualMachineProperties.VirtualMachineScaleSet"), + }, { Name: "power_state", Description: "Specifies the power state of the VM.", diff --git a/azure/table_azure_compute_virtual_machine_scale_set_vm.go b/azure/table_azure_compute_virtual_machine_scale_set_vm.go index b97b2fb6..036f3672 100644 --- a/azure/table_azure_compute_virtual_machine_scale_set_vm.go +++ b/azure/table_azure_compute_virtual_machine_scale_set_vm.go @@ -325,16 +325,22 @@ func getAzureComputeVirtualMachineScaleSetVmInstanceView(ctx context.Context, d session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { + plugin.Logger(ctx).Error("Error", "getAzureComputeVirtualMachineScaleSetVmInstanceView", err) return nil, err } subscriptionID := session.SubscriptionID + // When VMs are managed by scale sets in flexible orchestration mode, + // standard Azure VM APIs must be must be used. + // See https://learn.microsoft.com/en-us/answers/questions/1418158/rest-api-request-returns-badrequest-for-vmss + // and https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-orchestration-modes?WT.mc_id=modinfra-31635-pierrer#what-has-changed-with-flexible-orchestration-mode if h.ParentItem.(compute.VirtualMachineScaleSet).OrchestrationMode == compute.Flexible { client := compute.NewVirtualMachinesClientWithBaseURI(session.ResourceManagerEndpoint, subscriptionID) client.Authorizer = session.Authorizer op, err := client.InstanceView(ctx, resourceGroupName, *virtualMachine.Name) if err != nil { + plugin.Logger(ctx).Error("Error", "getAzureComputeVirtualMachineScaleSetVmInstanceView", err) return nil, err } return op, nil @@ -344,6 +350,7 @@ func getAzureComputeVirtualMachineScaleSetVmInstanceView(ctx context.Context, d op, err := client.GetInstanceView(ctx, resourceGroupName, virtualMachine.ScaleSetName, instanceId) if err != nil { + plugin.Logger(ctx).Error("Error", "getAzureComputeVirtualMachineScaleSetVmInstanceView", err) return nil, err } return op, nil