Batch Account unexpected status 400 with error: InvalidKeyVaultReference: The specified Key Vault reference is invalid

Batch Account Name: “xxxxxxxx”): performing Create: unexpected status 400 with error: InvalidKeyVaultReference: The specified Key Vault reference is invalid.

Hi I got this error when trying to crate a batch account using UserSubscription pool allocation mode. Bellow is my code. Any idea why says “InvalidKeyVaultReference: The specified Key Vault reference is invalid.”? Vault is properly created. Thanks.

resource “azurerm_key_vault” “keyvault” {
name = var.keyvault_name
location = var.location
resource_group_name = var.resource_group
enabled_for_disk_encryption = true
tenant_id = var.tenant_id
soft_delete_retention_days = 7
purge_protection_enabled = false
enabled_for_template_deployment = true
sku_name = “premium”
}

output “key_vault_reference” {
value = azurerm_key_vault.keyvault.id
}

resource “azurerm_batch_account” “bio_batch_account” {
depends_on = [ azurerm_storage_account.bio_storage_account ]
name = “{var.batch_account_name}{random_string.resource_code.result}”
resource_group_name = var.resource_group
location = var.location
pool_allocation_mode = “UserSubscription”
storage_account_id = azurerm_storage_account.bio_storage_account.id
storage_account_authentication_mode = “StorageKeys”
key_vault_reference {
id = azurerm_key_vault.keyvault.id
url = azurerm_key_vault.keyvault.vault_uri
}
allowed_authentication_modes = [“AAD”]
public_network_access_enabled = “false”
tags = {
Environment = var.environment_name
Title = var.title_number
}
}