diff --git a/azurerm/internal/services/databricks/resource_arm_databricks_workspace.go b/azurerm/internal/services/databricks/resource_arm_databricks_workspace.go index b6d09af63e9b..7de33602cb57 100644 --- a/azurerm/internal/services/databricks/resource_arm_databricks_workspace.go +++ b/azurerm/internal/services/databricks/resource_arm_databricks_workspace.go @@ -346,10 +346,10 @@ func ValidateDatabricksWorkspaceName(i interface{}, k string) (warnings []string // First, second, and last characters must be a letter or number with a total length between 3 to 64 characters // NOTE: Restricted name to 30 characters because that is the restriction in Azure Portal even though the API supports 64 characters - if !regexp.MustCompile("^[a-zA-Z0-9]{2}[-a-zA-Z0-9]{0,27}[a-zA-Z0-9]{1}$").MatchString(v) { + if !regexp.MustCompile("^[a-zA-Z0-9]{2}[-_a-zA-Z0-9]{0,27}[a-zA-Z0-9]{1}$").MatchString(v) { errors = append(errors, fmt.Errorf("%q must be 3 - 30 characters in length", k)) errors = append(errors, fmt.Errorf("%q first, second, and last characters must be a letter or number", k)) - errors = append(errors, fmt.Errorf("%q can only contain letters, numbers, and hyphens", k)) + errors = append(errors, fmt.Errorf("%q can only contain letters, numbers, underscores, and hyphens", k)) } // No consecutive hyphens diff --git a/azurerm/internal/services/databricks/tests/resource_arm_databricks_workspace_test.go b/azurerm/internal/services/databricks/tests/resource_arm_databricks_workspace_test.go index 8f1af330c69b..01af15f97078 100644 --- a/azurerm/internal/services/databricks/tests/resource_arm_databricks_workspace_test.go +++ b/azurerm/internal/services/databricks/tests/resource_arm_databricks_workspace_test.go @@ -30,6 +30,10 @@ func TestAzureRMDatabrickWorkspaceName(t *testing.T) { Value: "hello-1-2-3-there", ShouldError: false, }, + { + Value: "hello_1_2_3_there", + ShouldError: false, + }, { Value: "hello-1-2-3-", ShouldError: true, @@ -38,6 +42,14 @@ func TestAzureRMDatabrickWorkspaceName(t *testing.T) { Value: "-hello-1-2-3", ShouldError: true, }, + { + Value: "hello_1_2_3_", + ShouldError: true, + }, + { + Value: "_hello_1_2_3", + ShouldError: true, + }, { Value: "hello!there", ShouldError: true,