Skip to content

[BUG] batchAccount - storageAccountId property cannot be removed through update method in go-azure-sdk #40325

@v-yhyeo0202

Description

@v-yhyeo0202

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/batch/resource-manager/Microsoft.Batch/Batch/stable/2024-07-01/openapi.json?plain=1#L3590

API Spec version

2024-07-01

Describe the bug

The storageAccountId property of batchAccount resource is marked as required. When using patch method to update the batchAccount with auto-generated SDK such as go-azure-sdk, it is unable to remove storageAccountId as an empty string will be assigned to the property. This causes issue as that in hashicorp/terraform-provider-azurerm#31615. To solve the issue, I guess the any of the following two solutions can be applied.

  1. Do not mark storageAccountId as required
  2. Define put method for batchAccount

Expected behavior

By using put method with Azure CLI az rest command, it is possible to remove existing storageAccountId with the following request body.

Request body

{
  "identity": {
    "type": "None",
    "userAssignedIdentities": null
  },
  "properties": {
    "autoStorage": {},
    "encryption": {
      "keySource": "Microsoft.Batch"
    }
  },
}

Actual behavior

When using go-azure-sdk update method generated from azure-rest-api-specs with terraform-provider-azurerm, even if storageAccountId is not specified, an empty string will be assigned as shown in the request body below due to the required behavior. This causes error as listed below.

Request body

{
  "identity": {
    "type": "None",
    "userAssignedIdentities": null
  },
  "properties": {
    "autoStorage": {
      "storageAccountId": ""
    },
    "encryption": {
      "keySource": "Microsoft.Batch"
    }
  },
}

Error

LinkedInvalidPropertyId: Property id '' at path 'properties.autoStorage.storageAccountId' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.

Reproduction Steps

The issue can be reproduced by using go-azure-sdk update method with the request body as mentioned in actual behavior section above.

Environment

  • uname -a
6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
  • cat /etc/os-release
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble
  • Azure CLI v2.77.0
  • Terraform v1.14.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions