azure-sdk-for-go: VMSS Flex VM instances cannot be deleted

Bug Report

Imports:

	github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
	github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0

Package in question: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0

Go version: 1.19.1

  • What happened? I am trying to delete a VMSS Flex VM instance, but the SDK APIs dont seem functional.

  • What did you expect or want to happen? VM instance deletion process should start and API should succeed.

  • How can we reproduce it? Create VMSS Flex, create instances and try deleting using SDK.

  • Environment

  1. Current code being tested:
force := true
	r, err := vmsClient.BeginDelete(ctx, rgname, vm, &armcompute.VirtualMachinesClientBeginDeleteOptions{
		ForceDeletion: &force,
	})
	if err != nil {
		fmt.Println(err)
		return
	}

I am using the vm client instead of the vmss client api since VMSS API dont seem to support deletion of Flex instances. The VMSS API requires instance IDs that are integers in the backend and those dont exist for the VM Flex instances:

vmssclient.BeginDeleteInstances(ctx, rgname, cpuVmssName, armcompute.VirtualMachineScaleSetVMInstanceRequiredIDs{
		InstanceIDs: <REQUIRED; The virtual machine scale set instance ids.>,
	}

Response from 1:

Deleting VM: az-cpu-test-wus3-flex-1_3166bfac
DELETE https://management.azure.com/subscriptions/.../providers/Microsoft.Compute/virtualMachines/az-cpu-test-wus3-flex-1_3166bfac

--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE UNAVAILABLE
--------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Ok i see it happening, in this case the name is the instance IDs. Thank you, you may close this issue.

Ok it looks like that character was getting appended in the go code. It seems to be working now.

[Nov 17 14:12:15.017928] Response: ==> REQUEST/RESPONSE (Try=1/475.825333ms, OpTime=475.996333ms) -- RESPONSE RECEIVED
   DELETE https://management.azure.com/subscriptions/3358be8c-ffc1-4165-965c-5a07f7a420a8/resourceGroups/rg-ecp-hydra-prod-1-wus3-1/providers/Microsoft.Compute/virtualMachines/az-cpu-test-wus3-flex-1_3166bfac?api-version=2022-03-01&forceDeletion=REDACTED
   Accept: application/json
   Authorization: REDACTED
   User-Agent: azsdk-go-armcompute/v1.0.0 (go1.19.1; darwin)
   --------------------------------------------------------------------------------
   RESPONSE Status: 202 Accepted
   Azure-Asyncnotification: REDACTED
   Azure-Asyncoperation: REDACTED
   Cache-Control: no-cache
   Content-Length: 0
   Date: Thu, 17 Nov 2022 22:12:14 GMT
   Expires: -1
   Location: REDACTED
   Pragma: no-cache
   Retry-After: 10
   Server: Microsoft-HTTPAPI/2.0
   Strict-Transport-Security: REDACTED
   X-Content-Type-Options: REDACTED
   X-Ms-Correlation-Request-Id: REDACTED
   X-Ms-Ratelimit-Remaining-Resource: REDACTED
   X-Ms-Ratelimit-Remaining-Subscription-Deletes: REDACTED
   X-Ms-Request-Id: 3744f871-dc05-43ec-bcf7-8aa59f765ab4
   X-Ms-Routing-Request-Id: REDACTED

I can see some character appended, let me try to fix it and check