Skip to content

Commit

Permalink
data_factory_linked_service_sql_server_resource supports userName (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqingzhang authored Apr 21, 2022
1 parent ab12bd0 commit bdf4fae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ func resourceDataFactoryLinkedServiceSQLServer() *pluginsdk.Resource {
ValidateFunc: validation.StringIsNotEmpty,
},
},
"user_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
},
}
}
Expand Down Expand Up @@ -182,6 +187,10 @@ func resourceDataFactoryLinkedServiceSQLServerCreateUpdate(d *pluginsdk.Resource
sqlServerLinkedService.SQLServerLinkedServiceTypeProperties.ConnectionString = v.(string)
}

if v, ok := d.GetOk("user_name"); ok {
sqlServerLinkedService.SQLServerLinkedServiceTypeProperties.UserName = v.(string)
}

if v, ok := d.GetOk("key_vault_connection_string"); ok {
sqlServerLinkedService.SQLServerLinkedServiceTypeProperties.ConnectionString = expandAzureKeyVaultSecretReference(v.([]interface{}))
}
Expand Down Expand Up @@ -266,6 +275,7 @@ func resourceDataFactoryLinkedServiceSQLServerRead(d *pluginsdk.ResourceData, me
}

if properties := sqlServer.SQLServerLinkedServiceTypeProperties; properties != nil {
d.Set("user_name", properties.UserName)
if properties.ConnectionString != nil {
if val, ok := properties.ConnectionString.(map[string]interface{}); ok {
if err := d.Set("key_vault_connection_string", flattenAzureKeyVaultConnectionString(val)); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ provider "azurerm" {
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
name = "acctestRG-df-%[1]d"
location = "%[2]s"
}
resource "azurerm_data_factory" "test" {
name = "acctestdf%d"
name = "acctestdf%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_data_factory_linked_service_sql_server" "test" {
name = "acctestlssql%d"
name = "acctestlssql%[1]d"
data_factory_id = azurerm_data_factory.test.id
connection_string = "Integrated Security=False;Data Source=test;Initial Catalog=test;User ID=test;Password=test"
annotations = ["test1", "test2", "test3"]
Expand All @@ -131,7 +131,7 @@ resource "azurerm_data_factory_linked_service_sql_server" "test" {
bar = "test2"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary)
}

func (LinkedServiceSQLServerResource) update(data acceptance.TestData) string {
Expand Down Expand Up @@ -180,20 +180,20 @@ provider "azurerm" {
data "azurerm_client_config" "current" {}
resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
name = "acctestRG-df-%[1]d"
location = "%[2]s"
}
resource "azurerm_key_vault" "test" {
name = "acctkv%d"
name = "acctkv%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
}
resource "azurerm_data_factory" "test" {
name = "acctestdf%d"
name = "acctestdf%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
Expand All @@ -209,12 +209,13 @@ resource "azurerm_data_factory_linked_service_sql_server" "test" {
data_factory_id = azurerm_data_factory.test.id
connection_string = "Integrated Security=False;Data Source=test;Initial Catalog=test;User ID=test;"
user_name = "testuserName"
key_vault_password {
linked_service_name = azurerm_data_factory_linked_service_key_vault.test.name
secret_name = "secret"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary)
}

func (LinkedServiceSQLServerResource) connection_string_key_vault_reference(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The following arguments are supported:

* `key_vault_password` - (Optional) A `key_vault_password` block as defined below. Use this argument to store SQL Server password in an existing Key Vault. It needs an existing Key Vault Data Factory Linked Service.

* `user_name` - (Optional) The on-premises Windows authentication user name.

---

A `key_vault_connection_string` block supports the following:
Expand Down

0 comments on commit bdf4fae

Please sign in to comment.