Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: Azure cloud provider gets the availability zone from IMDS directly and the zone is usually in lower cases in most regions. But there're chances this is not true in some regions, hence customer's workloads depend on availability zone may not work. What you expected to happen: The availability zone is always in lower cases. How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others: /kind bug /sig cloud-provider /area provider/azure
/assign
Fixed by .

Discussion:
} zone := cloudprovider.Zone{ <del> FailureDomain: failureDomain, Region:        to.String(vm.Location), </del> <ins> FailureDomain: strings.ToLower(failureDomain), Region:        strings.ToLower(to.String(vm.Location)), </ins> } return zone, nil }

} return cloudprovider.Zone{ <del> FailureDomain: failureDomain, Region:        to.String(vm.Location), </del> <ins> FailureDomain: strings.ToLower(failureDomain), Region:        strings.ToLower(to.String(vm.Location)), </ins> }, nil }

import ( "fmt" <ins> "strings" </ins> "testing" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"

scaleSet    string vmList      []string nodeName    string <ins> location    string </ins> zone        string faultDomain int32 expected    string

expected:    "westus-2", }, { <ins> description: "scaleSet should get availability zone in lower cases", scaleSet:    "ss", vmList:      []string{"vmssee6c2000000", "vmssee6c2000001"}, nodeName:    "vmssee6c2000000", location:    "WestUS", zone:        "2", faultDomain: 3, expected:    "westus-2", }, { </ins> description: "scaleSet should return error for non-exist nodes", scaleSet:    "ss", faultDomain: 3,

} for _, test := range testCases { <del> ss, err := newTestScaleSet(ctrl, test.scaleSet, test.zone, test.faultDomain, test.vmList) </del> <ins> cloud := GetTestCloud(ctrl) if test.location != "" { cloud.Location = test.location } setTestVirtualMachineCloud(cloud, test.scaleSet, test.zone, test.faultDomain, test.vmList, "Running") scaleset, err := newScaleSet(cloud) </ins> assert.NoError(t, err, test.description) <ins> ss := scaleset.(*scaleSet) </ins> real, err := ss.GetZoneByNodeName(test.nodeName) if test.expectError {

assert.NoError(t, err, test.description) assert.Equal(t, test.expected, real.FailureDomain, test.description) <ins> assert.Equal(t, strings.ToLower(cloud.Location), real.Region, test.description) </ins> } }

} return cloudprovider.Zone{ <del> FailureDomain: zone, Region:        location, </del> <ins> FailureDomain: strings.ToLower(zone), Region:        strings.ToLower(location), </ins> }, nil } // if UseInstanceMetadata is false, get Zone name by calling ARM

testcases := []struct { name        string zone        string <ins> location    string </ins> faultDomain string expected    string }{ { name:     "GetZone should get real zone if only node's zone is set", zone:     "1", <ins> location: "eastus", </ins> expected: "eastus-1", }, { name:        "GetZone should get real zone if both node's zone and FD are set", zone:        "1", <ins> location:    "eastus", </ins> faultDomain: "99", expected:    "eastus-1", }, { name:        "GetZone should get faultDomain if node's zone isn't set", <ins> location:    "eastus", </ins> faultDomain: "99", expected:    "99", }, <ins> { name:     "GetZone should get availability zone in lower cases", location: "EastUS", zone:     "1", expected: "eastus-1", }, </ins> } for _, test := range testcases {

mux := http.NewServeMux() mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { <del> fmt.Fprint(w, fmt.Sprintf(`{"compute":{"zone":"%s", "platformFaultDomain":"%s", "location":"eastus"}}`, test.zone, test.faultDomain)) </del> <ins> fmt.Fprint(w, fmt.Sprintf(`{"compute":{"zone":"%s", "platformFaultDomain":"%s", "location":"%s"}}`, test.zone, test.faultDomain, test.location)) </ins> })) go func() { http.Serve(listener, mux)