Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get instance view for VMSS flex VMs #19707

Closed
erika-boren opened this issue Dec 15, 2022 · 14 comments
Closed

Unable to get instance view for VMSS flex VMs #19707

erika-boren opened this issue Dec 15, 2022 · 14 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute - VMSS customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library.

Comments

@erika-boren
Copy link

Bug Report

  • import path: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4
  • version: v4.0.0
  • go version: go1.19.1 darwin/amd64

Unable to get the instance view for VMSS flex VMs. The GetInstanceView requires the VM id, which doesn't exist for a flex VM. However, I see in the doc below it says to use the vm name in place of the ID. I tried using the name but get a 400 invalid parameter.
https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-instance-ids

resp, err := client.GetInstanceView(ctx,"rg-name", "vm-flex-test", "vm-flex-test_032c7bb7", nil)

GET https://management.azure.com/subscriptions/redacted-subid/resourceGroups/rg-name/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-flex-test/virtualMachines/vm-flex-test_032c7bb7/instanceView
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: InvalidParameter
--------------------------------------------------------------------------------
{
  "error": {
    "code": "InvalidParameter",
    "message": "Virtual Machine Scale Set VM instanceId must be a number.",
    "target": "instanceId"
  }
}
--------------------------------------------------------------------------------
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 15, 2022
@ghost
Copy link

ghost commented Dec 15, 2022

Hi @erikasboren. Thank you for your feedback and we will look into it soon. Meanwhile, feel free to share your experience using the Azure SDK in this survey.

@lirenhe lirenhe added the Mgmt This issue is related to a management-plane library. label Dec 15, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 15, 2022
@lirenhe lirenhe added Compute - VMSS needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Dec 15, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 15, 2022
@tadelesh tadelesh assigned tadelesh and unassigned ArcturusZhang Dec 26, 2022
@tadelesh
Copy link
Member

According to this issue replied with service team, you may use instanceIDs as parameter.

@tadelesh tadelesh added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Dec 26, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Jan 2, 2023
@ghost
Copy link

ghost commented Jan 2, 2023

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@erika-boren
Copy link
Author

Flex instances don't have instanceIDs and that issue says to use the instance name instead, which is what I tried and posted above.

@ghost ghost added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. labels Jan 3, 2023
@ghost
Copy link

ghost commented Jan 4, 2023

Thank you for your feedback. This has been routed to the support team for assistance.

@navba-MSFT navba-MSFT self-assigned this Jan 5, 2023
@navba-MSFT
Copy link

@erika-boren Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

@navba-MSFT
Copy link

navba-MSFT commented Jan 5, 2023

@erika-boren Could you please check if the below sample helps ? sample code here.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
)

var (
	subscriptionID    = "XXXX-XXXX-XXX-XXXX"
	resourceGroupName = "MY-RESOURCES"
	vmName            = "MySampleVMName"
)

func main() {

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	// Create an Azure Compute VM client
	client, err := armcompute.NewVirtualMachinesClient(subscriptionID, cred, nil)

	// Retrieve the instance view of the Virtual Machine

	instanceView, err := client.InstanceView(ctx, resourceGroupName, vmName, nil)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Print the instance view
	fmt.Println(instanceView)

}

InstanceView - Retrieves information about the run-time state of a virtual machine. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2022-03-01
resourceGroupName - The name of the resource group.
vmName - The name of the virtual machine.
options - VirtualMachinesClientInstanceViewOptions contains the optional parameters for the VirtualMachinesClient.InstanceView method.

More info here.

@erika-boren
Copy link
Author

erika-boren commented Jan 5, 2023

I'm not able to get the instance view for flex instances within a VMSS using the VirtualMachinesClient. It says the resource is not found.

client, err := armcompute.NewVirtualMachineScaleSetVMsClient(sub, creds, nil)
resp, err := client.InstanceView(ctx, rgName, *vm.Name, nil)

GET https://management.azure.com/subscriptions/subscription-redacted/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachines/az-vm-dev-wus3-flex-test_01234567/instanceView
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: ResourceNotFound
--------------------------------------------------------------------------------
{
  "error": {
    "code": "ResourceNotFound",
    "message": "The Resource 'Microsoft.Compute/virtualMachines/az-vm-dev-wus3-flex-test_01234567' under resource group 'resource-group-name' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
  }
}

@navba-MSFT
Copy link

@erika-boren Thanks for getting back and clarifying the ask. I was able to get the sample working with just VMSS Uniform orchestration mode. However with the Flexible orchestration Mode, I faced the same below error:

--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: InvalidParameter
--------------------------------------------------------------------------------
{
  "error": {
    "code": "InvalidParameter",
    "message": "Virtual Machine Scale Set VM instanceId must be a number.",
    "target": "instanceId"
  }
}
--------------------------------------------------------------------------------

Flexible orchestration Mode: {scale-set-name}{8-char-guid}
Uniform orchestration mode: {scale-set-name}
{instance-id}

Though our article mentions this, For Virtual Machine Scale Sets in Flexible Orchestration mode, the instance ID is simply the name of the virtual machine. I tried with both {8-char-guid} and {scale-set-name}_{8-char-guid}. But both failed.

I am checking this with the Product Owners further and I will update this thread.

@navba-MSFT navba-MSFT added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 9, 2023
@navba-MSFT
Copy link

navba-MSFT commented Jan 10, 2023

@erika-boren Apologies for the late reply. VMSS Flex does not support instance view, as there is not currently a way to get full instance view of Azure VMs. VMSS Uniforms had some internal simplifications that made it possible, but it was not possible to port that to VMSS Flex. The long term plan is to support getting instance view information at scale via Azure Resource Graph. We are hoping that lands in Q2CY2023.

In the meantime, options are:
1. Use List All VM API with statusonly=true and VMSS filter. That will get your powerState, provisioningState, and platformFaultDomain for all instances within the VMSS Flex.

2. Use Get VM Instance View API on each individual VM instance. Watch retry headers so that you don't run into throttling.

Hope this helps.

@navba-MSFT navba-MSFT added issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jan 10, 2023
@ghost
Copy link

ghost commented Jan 10, 2023

Hi @erika-boren. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@erika-boren
Copy link
Author

How do we get the IP of a Flex VM using the SDK?

@navba-MSFT
Copy link

navba-MSFT commented Jan 12, 2023

@erika-boren The above option 1 mentioned above you will get the ipConfigurations property in the response. That should help you get the required details.

@navba-MSFT
Copy link

@erika-boren If you need any further assistance on this issue in future, please feel free to reopen this thread. We would be happy to help.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute - VMSS customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

No branches or pull requests

5 participants