diff --git a/azurerm/internal/services/datafactory/data_factory_linked_service_odata_resource.go b/azurerm/internal/services/datafactory/data_factory_linked_service_odata_resource.go index d43f1a52e010b..b88fa16b0a562 100644 --- a/azurerm/internal/services/datafactory/data_factory_linked_service_odata_resource.go +++ b/azurerm/internal/services/datafactory/data_factory_linked_service_odata_resource.go @@ -141,14 +141,47 @@ func resourceArmDataFactoryLinkedServiceODataCreateUpdate(d *schema.ResourceData } } - description := d.Get("description").(string) - odataLinkedService := &datafactory.ODataLinkedService{ - Description: &description, - Type: datafactory.TypeOData, + Description: utils.String(d.Get("description").(string)), + Type: datafactory.TypeOData, + ODataLinkedServiceTypeProperties: authenticationProperties(d), + } + + if v, ok := d.GetOk("parameters"); ok { + odataLinkedService.Parameters = expandDataFactoryParameters(v.(map[string]interface{})) + } + + if v, ok := d.GetOk("integration_runtime_name"); ok { + odataLinkedService.ConnectVia = expandDataFactoryLinkedServiceIntegrationRuntime(v.(string)) + } + + if v, ok := d.GetOk("additional_properties"); ok { + odataLinkedService.AdditionalProperties = v.(map[string]interface{}) + } + + if v, ok := d.GetOk("annotations"); ok { + annotations := v.([]interface{}) + odataLinkedService.Annotations = &annotations } - odataLinkedService.ODataLinkedServiceTypeProperties = authenticationProperties(d) + linkedService := datafactory.LinkedServiceResource{ + Properties: odataLinkedService, + } + + if _, err := client.CreateOrUpdate(ctx, resourceGroup, dataFactoryName, name, linkedService, ""); err != nil { + return fmt.Errorf("Error creating/updating Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + resp, err := client.Get(ctx, resourceGroup, dataFactoryName, name, "") + if err != nil { + return fmt.Errorf("Error retrieving Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + if resp.ID == nil { + return fmt.Errorf("Cannot read Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + d.SetId(*resp.ID) return resourceArmDataFactoryLinkedServiceODataRead(d, meta) } @@ -241,23 +274,18 @@ func resourceArmDataFactoryLinkedServiceODataDelete(d *schema.ResourceData, meta } func authenticationProperties(d *schema.ResourceData) *datafactory.ODataLinkedServiceTypeProperties { - url := d.Get("url").(string) - basic_authentication := d.Get("basic_authentication").([]interface{}) if basic_authentication != nil { raw := basic_authentication[0].(map[string]interface{}) - username := raw["username"].(string) - password := raw["password"].(string) - passwordSecureString := datafactory.SecureString{ - Value: &password, - Type: datafactory.TypeSecureString, - } return &datafactory.ODataLinkedServiceTypeProperties{ AuthenticationType: datafactory.ODataAuthenticationType(datafactory.ODataAuthenticationTypeBasic), URL: utils.String(url), - UserName: username, - Password: &passwordSecureString, + UserName: raw["username"].(string), + Password: datafactory.SecureString{ + Value: utils.String(raw["password"].(string)), + Type: datafactory.TypeSecureString, + }, } } diff --git a/website/docs/r/data_factory_linked_service_odata.html.markdown b/website/docs/r/data_factory_linked_service_odata.html.markdown index 2c4feba0bf1b2..7a68122b667cd 100644 --- a/website/docs/r/data_factory_linked_service_odata.html.markdown +++ b/website/docs/r/data_factory_linked_service_odata.html.markdown @@ -49,8 +49,7 @@ resource "azurerm_data_factory_linked_service_odata" "basic_auth" { The following arguments are supported: -* `name` - (Required) Specifies the name of the Data Factory Linked Service OData. Changing this forces a new resource to be created. Must be unique within a data - factory. See the [Microsoft documentation](https://docs.microsoft.com/en-us/azure/data-factory/naming-rules) for all restrictions. +* `name` - (Required) Specifies the name of the Data Factory Linked Service OData. Changing this forces a new resource to be created. Must be unique within a data factory. See the [Microsoft documentation](https://docs.microsoft.com/en-us/azure/data-factory/naming-rules) for all restrictions. * `resource_group_name` - (Required) The name of the resource group in which to create the Data Factory Linked Service OData. Changing this forces a new resource