This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Infrastructure as Code (IaC) tools like Terraform have revolutionized the way developers and organizations deploy and manage infrastructure. With its declarative language and ability to automate provisioning, Terraform reduces human error, ensures consistency, and speeds up deployment across cloud and on-premises environments. In this document, we’ll explore how you can create SQL databases workloads in Microsoft Fabric using Terraform.
Select your user account and subscription number from the list displayed.
File - variables.tf
variable "fabric_workspace_name" {
description = "Name for the Workspace to be created or already exists."
type = string
}
variable "fabric_sql_database_name" {
description = "Name for the SQL database to be created."
type = string
}
variable "fabric_capacity_name" {
description = "Fabric capacity where workspace/SQL database need to be created."
type = string
}
File - terraform.tfvars
fabric_workspace_name = "<Enter workspace Name>"
fabric_sql_database_name = "<Enter SQL database Name"
fabric_capacity_name = "<Enter capacity Name>"
File - workspace.tf:
data "fabric_capacity" "capacity" {
display_name = var.fabric_capacity_name
}
resource "fabric_workspace" "example_workspace" {
display_name = var.fabric_workspace_name
description = "Getting started workspace"
capacity_id = data.fabric_capacity.capacity.id
}
File - providers.tf
terraform {
required_version = ">= 1.8, < 2.0"
required_providers {
fabric = {
source = "microsoft/fabric"
version = "1.2.0"
}
}
}
provider "fabric" {
preview = true
}
File - sqldatabase.tf
resource "fabric_sql_database" "example_sql" {
workspace_id = fabric_workspace.example_workspace.id
display_name = var.fabric_sql_database_name
File - outputs.tf
output "capacity_id" {
value = data.fabric_capacity.capacity.id
}
output "sql_database_id" {
value = fabric_sql_database.example_sql.id
}
output "sql_connection_string"{
value = fabric_sql_database.example_sql.properties.connection_string
}
..\terraform init
..\Terraform plan -out main.tfplan
..\terraform apply main.tfplan
..\terraform plan -destroy -out main.destroy.tfplan
..\terraform apply main.destroy.tfplan
Start your journey with Terraform today and experience the efficiency and reliability it brings to infrastructure management as well as Dev ops.
Terraform Resources for SQL database - fabric_sql_database | Resources | microsoft/fabric | Terraform | Terraform Registry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.