2020-11-22 00:15

KeyVault: CheckNameAvailability for KeyVault returns a value different from the enum defined for KeyVault

Bug Report

  • import path of package in question: "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
  • SDK version: master
  • output of go version: go version go1.13.7 darwin/amd64
  • What happened? I am using the above SDK to check the validity for a KeyVault name using the below snippet. KeyVault SDK has an enum defined as "keyvault.AccountNameInvalid" that is one of the possible values. However, the API actually returns "Invalid" and so I cannot just compare to the keyvault enum.
// Check if keyvault name is valid
    vaultNameCheck := keyvault.VaultCheckNameAvailabilityParameters{
        Name: to.StringPtr(vaultName),
        Type: to.StringPtr("Microsoft.KeyVault/vaults"),
    result, err := vaultsClient.CheckNameAvailability(ctx, vaultNameCheck)
    if err != nil {
        return keyvault.Vault{}, err
    if result.Reason == keyvault.Reason("Invalid") || result.Reason == keyvault.AccountNameInvalid {
        return keyvault.Vault{}, fmt.Errorf("AccountNameInvalid")
    } else if result.Reason == keyvault.AlreadyExists {
        return keyvault.Vault{}, fmt.Errorf("AlreadyExists")
  • What did you expect or want to happen?

We should either change the enum or change what we return to the string that the enum defines. I expect that return values to be one of the defined enums.

  • How can we reproduce it? Use the above code snippet with an invalid vault name


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享