Skip to content

Commit cd1e14e

Browse files
committed
Azure data Factory
1 parent a3ed88b commit cd1e14e

8 files changed

Lines changed: 259 additions & 0 deletions

File tree

5_analytics-bigdata/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Last updated: 2026-02-09
1212
> [!IMPORTANT]
1313
> This folder contains sample Terraform templates for Azure analytics and big data services. These templates are starting points and should be customized based on your application needs.
1414
15+
## Templates available
16+
17+
- [Azure Data Factory](./data-factory)
18+
1519
<!-- START BADGE -->
1620
<div align="center">
1721
<img src="https://img.shields.io/badge/Total%20views-1706-limegreen" alt="Total views">
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Terraform Template - Azure Data Factory
2+
3+
Costa Rica
4+
5+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
6+
[brown9804](https://github.com/brown9804)
7+
8+
Last updated: 2026-02-11
9+
10+
------------------------------------------
11+
12+
> This template contains Terraform configurations to create an Azure Data Factory instance with a system-assigned managed identity.
13+
14+
## File Descriptions
15+
16+
- **main.tf**: Creates the Resource Group and Azure Data Factory.
17+
- **variables.tf**: Defines the input variables used in the Terraform configuration.
18+
- **provider.tf**: Configures the Azure provider to interact with Azure resources.
19+
- **terraform.tfvars**: Provides example values for the variables defined in `variables.tf`.
20+
- **outputs.tf**: Defines outputs such as the Data Factory ID and managed identity principal ID.
21+
22+
## Variables
23+
24+
| Variable Name | Description | Type | Example Value |
25+
| --- | --- | --- | --- |
26+
| `resource_group_name` | Resource Group name to create/deploy into. | string | `"rg-analytics-dev"` |
27+
| `location` | Azure region for the deployment. | string | `"eastus"` |
28+
| `data_factory_name` | Base Azure Data Factory name. If random suffix is enabled, final name is `<base>-<suffix>`. | string | `"adf-analytics-dev"` |
29+
| `append_random_suffix` | Append a random suffix to avoid global name collisions. | bool | `true` |
30+
| `random_suffix_length` | Length of the random suffix when enabled. | number | `6` |
31+
| `public_network_enabled` | Enable/disable public network access for Data Factory. | bool | `true` |
32+
| `tags` | Tags applied to resources. | map(string) | `{ "env": "dev" }` |
33+
34+
## Usage
35+
36+
1. Authenticate:
37+
38+
```sh
39+
az login
40+
````
41+
42+
```sh
43+
az account show
44+
# If needed:
45+
az account set --subscription "<subscription-id-or-name>"
46+
```
47+
48+
3. Initialize:
49+
50+
```sh
51+
terraform init -upgrade
52+
```
53+
54+
4. Validate and plan:
55+
56+
```sh
57+
terraform validate
58+
terraform plan
59+
```
60+
61+
5. Apply:
62+
63+
```sh
64+
terraform apply -auto-approve
65+
```
66+
67+
> [!NOTE]
68+
> This template creates the Resource Group for you.
69+
70+
> [!NOTE]
71+
> Azure Data Factory names are globally unique. If you disable `append_random_suffix`, you may hit `DataFactoryNameInUse` and need to change `data_factory_name`.
72+
73+
<!-- START BADGE -->
74+
<div align="center">
75+
<img src="https://img.shields.io/badge/Total%20views-1706-limegreen" alt="Total views">
76+
<p>Refresh Date: 2026-02-11</p>
77+
</div>
78+
<!-- END BADGE -->
79+
80+
````
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# main.tf
2+
# This file contains the main configuration for creating an Azure Data Factory.
3+
# It creates a Resource Group and an Azure Data Factory with a system-assigned managed identity.
4+
5+
resource "azurerm_resource_group" "example" {
6+
name = var.resource_group_name
7+
location = var.location
8+
9+
tags = var.tags
10+
}
11+
12+
resource "random_string" "suffix" {
13+
length = var.random_suffix_length
14+
upper = false
15+
special = false
16+
numeric = true
17+
18+
keepers = {
19+
resource_group_name = var.resource_group_name
20+
location = var.location
21+
base_name = var.data_factory_name
22+
}
23+
}
24+
25+
locals {
26+
data_factory_name_final = var.append_random_suffix ? "${var.data_factory_name}-${random_string.suffix.result}" : var.data_factory_name
27+
}
28+
29+
resource "azurerm_data_factory" "example" {
30+
name = local.data_factory_name_final
31+
location = azurerm_resource_group.example.location
32+
resource_group_name = azurerm_resource_group.example.name
33+
34+
public_network_enabled = var.public_network_enabled
35+
36+
identity {
37+
type = "SystemAssigned"
38+
}
39+
40+
tags = var.tags
41+
42+
depends_on = [
43+
azurerm_resource_group.example
44+
]
45+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# outputs.tf
2+
3+
output "resource_group_id" {
4+
description = "The ID of the resource group."
5+
value = azurerm_resource_group.example.id
6+
}
7+
8+
output "data_factory_id" {
9+
description = "The resource ID of the Azure Data Factory."
10+
value = azurerm_data_factory.example.id
11+
}
12+
13+
output "data_factory_name" {
14+
description = "The name of the Azure Data Factory."
15+
value = azurerm_data_factory.example.name
16+
}
17+
18+
output "data_factory_principal_id" {
19+
description = "The system-assigned managed identity principalId for the Data Factory."
20+
value = azurerm_data_factory.example.identity[0].principal_id
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# provider.tf
2+
# This file configures the Azure provider to interact with Azure resources.
3+
# It specifies the required provider and its version, along with provider-specific configurations.
4+
5+
terraform {
6+
required_version = ">= 1.8, < 2.0"
7+
8+
required_providers {
9+
azurerm = {
10+
source = "hashicorp/azurerm"
11+
version = "~> 3.116"
12+
}
13+
14+
random = {
15+
source = "hashicorp/random"
16+
version = "~> 3.6"
17+
}
18+
}
19+
}
20+
21+
provider "azurerm" {
22+
features {
23+
resource_group {
24+
prevent_deletion_if_contains_resources = false
25+
}
26+
}
27+
28+
# Uses the current Azure CLI context (az login + az account set)
29+
skip_provider_registration = false
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource_group_name = "rg-analytics-dev"
2+
location = "eastus"
3+
4+
# Data Factory name must be globally unique.
5+
# This template appends a random suffix by default to reduce collisions.
6+
data_factory_name = "adf-analytics-dev"
7+
8+
append_random_suffix = true
9+
random_suffix_length = 6
10+
11+
public_network_enabled = true
12+
13+
tags = {
14+
env = "dev"
15+
area = "analytics-bigdata"
16+
iac = "terraform"
17+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# variables.tf
2+
# This file defines the input variables used in the Terraform configuration.
3+
4+
variable "resource_group_name" {
5+
description = "The name of the Azure Resource Group to create and deploy the Data Factory into."
6+
type = string
7+
8+
validation {
9+
condition = length(trimspace(var.resource_group_name)) > 0
10+
error_message = "resource_group_name must not be empty."
11+
}
12+
}
13+
14+
variable "location" {
15+
description = "The Azure region where the Resource Group and Data Factory will be created."
16+
type = string
17+
18+
validation {
19+
condition = length(trimspace(var.location)) > 0
20+
error_message = "location must not be empty."
21+
}
22+
}
23+
24+
variable "data_factory_name" {
25+
description = "The base name of the Azure Data Factory instance. If append_random_suffix is true, the final name will be '<base>-<suffix>'."
26+
type = string
27+
28+
validation {
29+
condition = length(trimspace(var.data_factory_name)) > 0
30+
error_message = "data_factory_name must not be empty."
31+
}
32+
}
33+
34+
variable "append_random_suffix" {
35+
description = "Whether to append a random suffix to the Data Factory name to avoid global name collisions."
36+
type = bool
37+
default = true
38+
}
39+
40+
variable "random_suffix_length" {
41+
description = "Length of the random suffix appended to the Data Factory name when append_random_suffix is true."
42+
type = number
43+
default = 6
44+
45+
validation {
46+
condition = var.random_suffix_length >= 4 && var.random_suffix_length <= 16
47+
error_message = "random_suffix_length must be between 4 and 16."
48+
}
49+
}
50+
51+
variable "public_network_enabled" {
52+
description = "Whether public network access is enabled for the Data Factory."
53+
type = bool
54+
default = true
55+
}
56+
57+
variable "tags" {
58+
description = "A map of tags to assign to the resources."
59+
type = map(string)
60+
default = {}
61+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Last updated: 2026-02-11
105105
<summary><b> Analytics and Big Data </b> (Click to expand) </summary>
106106

107107
- [Analytics and Big Data](./5_analytics-bigdata)
108+
- [Azure Data Factory](./5_analytics-bigdata/data-factory)
108109

109110
</details>
110111

0 commit comments

Comments
 (0)