Skip to content

Commit 6634f4f

Browse files
committed
Add adf and fix AF to use id
1 parent 227556b commit 6634f4f

File tree

12 files changed

+57
-121
lines changed

12 files changed

+57
-121
lines changed

infra/modules/providers/azure/data-factory/README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ An instance of the `data-factory` module deploys the _**Data Factory**_ in order
1717
- Ability to provision a single Data Factory instance
1818
- Ability to provision a configurable Pipeline
1919
- Ability to configure Trigger
20-
- Ability to configure SQL server Dataset
21-
- Ability to configure SQL server Linked Service
20+
2221

2322
## Out Of Scope
2423

2524
The following are not support in the time being
2625

2726
- Creating Multiple pipelines
28-
- Only SQL server Dataset/Linked Service are implemented.
2927

3028
## Definition
3129

@@ -35,8 +33,6 @@ Terraform resources used to define the `data-factory` module include the followi
3533
- [azurerm_data_factory_integration_runtime_managed](https://www.terraform.io/docs/providers/azurerm/r/data_factory_integration_runtime_managed.html)
3634
- [azurerm_data_factory_pipeline](https://www.terraform.io/docs/providers/azurerm/r/data_factory_pipeline.html)
3735
- [azurerm_data_factory_trigger_schedule](https://www.terraform.io/docs/providers/azurerm/r/data_factory_trigger_schedule.html)
38-
- [azurerm_data_factory_dataset_sql_server](https://www.terraform.io/docs/providers/azurerm/r/data_factory_dataset_sql_server_table.html)
39-
- [azurerm_data_factory_linked_service_sql_server](https://www.terraform.io/docs/providers/azurerm/r/data_factory_linked_service_sql_server.html)
4036

4137
## Usage
4238

@@ -60,11 +56,6 @@ module "data_factory" {
6056
data_factory_trigger_name = "adftrigger"
6157
data_factory_trigger_interval = 1
6258
data_factory_trigger_frequency = "Minute"
63-
data_factory_dataset_sql_name = "adfsqldataset"
64-
data_factory_dataset_sql_table_name = "adfsqldatasettable"
65-
data_factory_dataset_sql_folder = ""
66-
data_factory_linked_sql_name = "adfsqllinked"
67-
data_factory_linked_sql_connection_string = "Server=tcp:adfsql..."
6859
}
6960
```
7061

infra/modules/providers/azure/data-factory/datasets.tf

-8
This file was deleted.

infra/modules/providers/azure/data-factory/linkedservices.tf

-8
This file was deleted.

infra/modules/providers/azure/data-factory/output.tf

-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ output "trigger_interval" {
2828
value = azurerm_data_factory_trigger_schedule.main.interval
2929
}
3030

31-
output "sql_dataset_id" {
32-
description = "The ID of the SQL server dataset created"
33-
value = azurerm_data_factory_dataset_sql_server_table.main.id
34-
}
35-
36-
output "sql_linked_service_id" {
37-
description = "The ID of the SQL server Linked service created"
38-
value = azurerm_data_factory_linked_service_sql_server.main.id
39-
}
40-
4131
output "adf_identity_principal_id" {
4232
description = "The ID of the principal(client) in Azure active directory"
4333
value = azurerm_data_factory.main.identity[0].principal_id

infra/modules/providers/azure/data-factory/terraform.tfvars.template

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ resource_group_name = ""
22
data_factory_name = ""
33
data_factory_runtime_name = ""
44
data_factory_pipeline_name = ""
5-
data_factory_dataset_sql_name = ""
6-
data_factory_dataset_sql_table_name = ""
7-
data_factory_linked_sql_name = ""
8-
data_factory_linked_sql_connection_string = ""
5+
data_factory_trigger_name = ""
96
vnet_integration = {
107
vnet_id = ""
118
subnet_name = ""

infra/modules/providers/azure/data-factory/tests/integration/data_factory_integration_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ func TestDataFactory(t *testing.T) {
2525
"data_factory_name",
2626
"pipeline_name",
2727
),
28-
VerifyCreatedDataset(subscription,
29-
"resource_group_name",
30-
"data_factory_name",
31-
"sql_dataset_id",
32-
),
33-
VerifyCreatedLinkedService(subscription,
34-
"resource_group_name",
35-
"data_factory_name",
36-
"sql_linked_service_id",
37-
),
3828
},
3929
}
4030
integration.RunIntegrationTests(&testFixture)
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
resource_group_name = "adftest"
2-
data_factory_name = "adftest"
3-
data_factory_runtime_name = "adfrttest"
4-
data_factory_pipeline_name = "testpipeline"
5-
data_factory_trigger_name = "testtrigger"
6-
data_factory_dataset_sql_name = "testsql"
7-
data_factory_dataset_sql_table_name = "adfsqltableheba"
8-
data_factory_linked_sql_name = "testlinkedsql"
9-
data_factory_linked_sql_connection_string = "connectionstring"
1+
resource_group_name = ""
2+
data_factory_name = ""
3+
data_factory_runtime_name = ""
4+
data_factory_pipeline_name = ""
5+
data_factory_trigger_name = ""
106
vnet_integration = {
11-
vnet_id = "/subscriptions/resourceGroups/providers/Microsoft.Network/virtualNetworks/testvnet"
12-
subnet_name = "default"
7+
vnet_id = ""
8+
subnet_name = ""
139
}

infra/modules/providers/azure/data-factory/tests/unit/data_factory_unit_test.go

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
package unit
22

33
import (
4-
"encoding/json"
5-
"strings"
64
"testing"
7-
8-
"github.com/gruntwork-io/terratest/modules/random"
95
tests "github.com/microsoft/cobalt/infra/modules/providers/azure/data-factory/tests"
106
"github.com/microsoft/terratest-abstraction/unit"
117
)
128

13-
// helper function to parse blocks of JSON into a generic Go map
14-
func asMap(t *testing.T, jsonString string) map[string]interface{} {
15-
var theMap map[string]interface{}
16-
if err := json.Unmarshal([]byte(jsonString), &theMap); err != nil {
17-
t.Fatal(err)
18-
}
19-
return theMap
20-
}
21-
229
func TestTemplate(t *testing.T) {
2310

2411
expectedDataFactory := map[string]interface{}{
@@ -53,27 +40,16 @@ func TestTemplate(t *testing.T) {
5340
"frequency": "Minute",
5441
}
5542

56-
expectedDatasetSQL := map[string]interface{}{
57-
"name": "testsql",
58-
}
59-
60-
expectedLinkedSQL := map[string]interface{}{
61-
"name": "testlinkedsql",
62-
"connection_string": "connectionstring",
63-
}
64-
6543
testFixture := unit.UnitTestFixture{
6644
GoTest: t,
6745
TfOptions: tests.DataFactoryTFOptions,
6846
PlanAssertions: nil,
69-
ExpectedResourceCount: 6,
47+
ExpectedResourceCount: 4,
7048
ExpectedResourceAttributeValues: unit.ResourceDescription{
7149
"azurerm_data_factory.main": expectedDataFactory,
7250
"azurerm_data_factory_integration_runtime_managed.main": expectedDFIntRunTime,
7351
"azurerm_data_factory_pipeline.main": expectedPipeline,
7452
"azurerm_data_factory_trigger_schedule.main": expectedTrigger,
75-
"azurerm_data_factory_dataset_sql_server_table.main": expectedDatasetSQL,
76-
"azurerm_data_factory_linked_service_sql_server.main": expectedLinkedSQL,
7753
},
7854
}
7955

infra/modules/providers/azure/data-factory/variables.tf

-30
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,4 @@ variable "data_factory_trigger_frequency" {
6868
description = "The trigger freqency. Valid values include Minute, Hour, Day, Week, Month. Defaults to Minute."
6969
type = string
7070
default = "Minute"
71-
}
72-
73-
variable "data_factory_dataset_sql_name" {
74-
description = "Specifies the name of the Data Factory Dataset SQL Server Table. Only letters, numbers and '_' are allowed."
75-
type = string
76-
default = ""
77-
}
78-
79-
variable "data_factory_dataset_sql_table_name" {
80-
description = "The table name of the Data Factory Dataset SQL Server Table."
81-
type = string
82-
default = ""
83-
}
84-
85-
variable "data_factory_dataset_sql_folder" {
86-
description = "The folder that this Dataset is in. If not specified, the Dataset will appear at the root level."
87-
type = string
88-
default = ""
89-
}
90-
91-
variable "data_factory_linked_sql_name" {
92-
description = "Specifies the name of the Data Factory Linked Service SQL Server. Changing this forces a new resource to be created."
93-
type = string
94-
default = ""
95-
}
96-
97-
variable "data_factory_linked_sql_connection_string" {
98-
description = "The connection string in which to authenticate with the SQL Server."
99-
type = string
100-
default = ""
10171
}

infra/templates/az-svc-data-integration-mlw/app.tf

+17-5
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,29 @@ module "function_app" {
9898
source = "../../modules/providers/azure/function-app"
9999
fn_name_prefix = local.func_app_name_prefix
100100
resource_group_name = azurerm_resource_group.app_rg.name
101-
service_plan_name = module.func_app_service_plan.service_plan_name
101+
service_plan_id = module.func_app_service_plan.app_service_plan_id
102102
storage_account_resource_group_name = module.sys_storage_account.resource_group_name
103103
storage_account_name = module.sys_storage_account.name
104104
vnet_subnet_id = module.network.subnet_ids[0]
105105
fn_app_settings = local.func_app_settings
106106
fn_app_config = var.fn_app_config
107107
}
108108

109-
module "data-factory" {
110-
source = "../../modules/providers/azure/data-factory"
111-
data_factory_name = local.data_factory_name
112-
resource_group_name = azurerm_resource_group.app_rg.name
109+
110+
module "data_factory" {
111+
source = "../../modules/providers/azure/data-factory"
112+
data_factory_name = local.data_factory_name
113+
resource_group_name = azurerm_resource_group.app_rg.name
114+
data_factory_runtime_name = local.data_factory_runtime_name
115+
number_of_nodes = var.adf_number_of_nodes
116+
max_parallel_executions_per_node = var.adf_max_parallel_executions_per_node
117+
vnet_integration = {
118+
vnet_id = module.network.subnet_ids[0]
119+
subnet_name = local.subnet_name
120+
}
121+
data_factory_pipeline_name = local.data_factory_pipeline_name
122+
data_factory_trigger_name = local.data_factory_trigger_name
123+
data_factory_trigger_interval = var.adf_trigger_interval
124+
data_factory_trigger_frequency = var.adf_trigger_frequency
113125
}
114126

infra/templates/az-svc-data-integration-mlw/commons.tf

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ locals {
6666
auth_svc_name_prefix = "${local.base_name_21}-au"
6767
smpl_app_postfix = "app"
6868
data_factory_name = "adf-cares-${local.base_name_46}"
69+
data_factory_runtime_name = "adf-rt-cares-${local.base_name_46}"
70+
data_factory_pipeline_name = "adf-pipeline-cares-${local.base_name_83}"
71+
data_factory_trigger_name = "adf-trigger-cares-${local.base_name_83}"
6972
func_app_name_prefix = "func-cares-${local.base_name_46}" // Function app name (Max 60 chars)
7073
cosmos_account_name = "cosmos-cares-${local.base_name_21}" // Cosmos databse account name (max 44 chars)
7174
cosmos_db_name = "cosmos-cares-db-${local.base_name_21}" // Cosmos databse account name (max 44 chars)

infra/templates/az-svc-data-integration-mlw/variables.tf

+27
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,33 @@ variable "fn_app_config" {
252252
default = {}
253253
}
254254

255+
// ---- Azure Data Factory Configuration ----
256+
257+
variable "adf_number_of_nodes" {
258+
description = "Number of nodes for the Managed Integration Runtime. Max is 10. Defaults to 1."
259+
type = number
260+
default = 1
261+
}
262+
263+
variable "adf_max_parallel_executions_per_node" {
264+
description = " Defines the maximum parallel executions per node. Defaults to 1. Max is 16."
265+
type = number
266+
default = 1
267+
}
268+
269+
variable "adf_trigger_interval" {
270+
description = "The interval for how often the trigger occurs. This defaults to 1."
271+
type = number
272+
default = 1
273+
}
274+
275+
variable "adf_trigger_frequency" {
276+
description = "The trigger freqency. Valid values include Minute, Hour, Day, Week, Month. Defaults to Minute."
277+
type = string
278+
default = "Minute"
279+
}
280+
281+
255282
// ---- Cosmos Database Configuration ----
256283
variable "primary_replica_location" {
257284
description = "The primary replica location for the cosmos database"

0 commit comments

Comments
 (0)