Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data_factory_linked_service_sql_server_resource supports user_name #16118

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -138,6 +138,11 @@ func resourceDataFactoryLinkedServiceSQLServer() *pluginsdk.Resource {
ValidateFunc: validation.StringIsNotEmpty,
},
},
"user_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
},
}
}
@@ -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{}))
}
@@ -266,6 +275,7 @@ func resourceDataFactoryLinkedServiceSQLServerRead(d *pluginsdk.ResourceData, me
}

if properties := sqlServer.SQLServerLinkedServiceTypeProperties; properties != nil {
d.Set("user_name", properties.UserName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be nil checked before setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tanks for this comment @catriona-mnil will be checked before setting in the Set function

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 {
Original file line number Diff line number Diff line change
@@ -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"]
@@ -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 {
@@ -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
}
@@ -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 {
Original file line number Diff line number Diff line change
@@ -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: