kubernetes/kops · error

error parsing providerID: %v

Error message

error parsing providerID: %v

What it means

Once the azure:// prefix is confirmed, the remainder of the providerID is parsed with arm.ParseResourceID (Azure SDK). If the string is not a valid fully-qualified ARM resource ID, this wrapped error is returned with the SDK's parse detail. The providerID must look like azure:///subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Compute/.../vmName.

Source

Thrown at pkg/nodeidentity/azure/identify.go:161

	}

	return info, nil
}

// stringKeyFunc is a string as cache key function
func stringKeyFunc(obj interface{}) (string, error) {
	key := obj.(*nodeidentity.Info).InstanceID
	return key, nil
}

func getVMNameFromProviderID(providerID string) (string, error) {
	if !strings.HasPrefix(providerID, "azure://") {
		return "", fmt.Errorf("providerID %q not recognized", providerID)
	}

	res, err := arm.ParseResourceID(strings.TrimPrefix(providerID, "azure://"))
	if err != nil {
		return "", fmt.Errorf("error parsing providerID: %v", err)
	}

	switch res.ResourceType.String() {
	case "Microsoft.Compute/virtualMachines":
		return res.Name, nil
	case "Microsoft.Compute/virtualMachineScaleSets/virtualMachines":
		return res.Parent.Name + "_" + res.Name, nil
	default:
		return "", fmt.Errorf("unsupported resource type %q for providerID %q", res.ResourceType, providerID)
	}
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Print node.Spec.ProviderID and validate it against the ARM ID format for a VM or VMSS VM.
  2. Re-stamp the providerID by restarting kubelet with the Azure cloud provider so it regenerates the canonical ID.
  3. Upgrade the Azure SDK (sigs.k8s.io/cloud-provider-azure / azure-sdk-for-go) and kOps to versions whose formats match.
  4. If the ID contains special characters, check resource/VM naming rules in Azure and rename or re-provision.

Example fix

// before (hand-written providerID in cloud-config)
providerID: azure://myvm

// after (canonical ARM form)
providerID: azure:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myrg/providers/Microsoft.Compute/virtualMachines/myvm
Defensive patterns

Strategy: validation

Validate before calling

rest := strings.TrimPrefix(pid, "azure://")
if _, err := arm.ParseResourceID(rest); err != nil {
    return fmt.Errorf("providerID %q is not a valid ARM resource ID: %v", pid, err)
}

Try / catch

name, err := getVMNameFromProviderID(pid)
if err != nil && strings.Contains(err.Error(), "error parsing providerID") {
    return fmt.Errorf("providerID %q malformed; re-stamp via kubelet azure cloud provider", pid)
}

Prevention

When it happens

Trigger: providerID has the azure:// scheme but a malformed body: missing subscription ID, wrong path segments (e.g. "azure://vmname"), URL-encoded or truncated IDs, or providerIDs produced by non-standard controllers.

Common situations: Clusters built with older/patched kubelet scripts that hand-wrote providerIDs; VM names or resource group names containing characters the SDK parser rejects; copying providerIDs from logs and losing segments; using an Azure SDK Go version where ParseResourceID is stricter.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/a856cf5f18a652e6. Report an issue: GitHub.