Share via


Microsoft.Kusto clusters/databases/scripts 2021-01-01

Bicep resource definition

The clusters/databases/scripts resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Kusto/clusters/databases/scripts resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Kusto/clusters/databases/scripts@2021-01-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    continueOnErrors: bool
    forceUpdateTag: 'string'
    scriptUrl: 'string'
    scriptUrlSasToken: 'string'
  }
}

Property Values

Microsoft.Kusto/clusters/databases/scripts

Name Description Value
name The resource name string (required)
parent In Bicep, you can specify the parent resource for a child resource. You only need to add this property when the child resource is declared outside of the parent resource.

For more information, see Child resource outside parent resource.
Symbolic name for resource of type: clusters/databases
properties The database script. ScriptProperties

ScriptProperties

Name Description Value
continueOnErrors Flag that indicates whether to continue if one of the command fails. bool
forceUpdateTag A unique string. If changed the script will be applied again. string
scriptUrl The url to the KQL script blob file. string (required)
scriptUrlSasToken The SaS token. string

Constraints:
Sensitive value. Pass in as a secure parameter. (required)

Usage Examples

Azure Quickstart Samples

The following Azure Quickstart templates contain Bicep samples for deploying this resource type.

Bicep File Description
Deploy Azure Data Explorer DB with Cosmos DB connection Deploy Azure Data Explorer DB with Cosmos DB connection.
Deploy Azure Data Explorer db with Event Grid connection Deploy Azure Data Explorer db with Event Grid connection.
Deploy Azure Data Explorer db with Event Hub connection Deploy Azure Data Explorer db with Event Hub connection.
FinOps hub This template creates a new FinOps hub instance, including Data Explorer, Data Lake storage, and Data Factory.

ARM template resource definition

The clusters/databases/scripts resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Kusto/clusters/databases/scripts resource, add the following JSON to your template.

{
  "type": "Microsoft.Kusto/clusters/databases/scripts",
  "apiVersion": "2021-01-01",
  "name": "string",
  "properties": {
    "continueOnErrors": "bool",
    "forceUpdateTag": "string",
    "scriptUrl": "string",
    "scriptUrlSasToken": "string"
  }
}

Property Values

Microsoft.Kusto/clusters/databases/scripts

Name Description Value
apiVersion The api version '2021-01-01'
name The resource name string (required)
properties The database script. ScriptProperties
type The resource type 'Microsoft.Kusto/clusters/databases/scripts'

ScriptProperties

Name Description Value
continueOnErrors Flag that indicates whether to continue if one of the command fails. bool
forceUpdateTag A unique string. If changed the script will be applied again. string
scriptUrl The url to the KQL script blob file. string (required)
scriptUrlSasToken The SaS token. string

Constraints:
Sensitive value. Pass in as a secure parameter. (required)

Usage Examples

Azure Quickstart Templates

The following Azure Quickstart templates deploy this resource type.

Template Description
Deploy Azure Data Explorer DB with Cosmos DB connection

Deploy to Azure
Deploy Azure Data Explorer DB with Cosmos DB connection.
Deploy Azure Data Explorer db with Event Grid connection

Deploy to Azure
Deploy Azure Data Explorer db with Event Grid connection.
Deploy Azure Data Explorer db with Event Hub connection

Deploy to Azure
Deploy Azure Data Explorer db with Event Hub connection.
FinOps hub

Deploy to Azure
This template creates a new FinOps hub instance, including Data Explorer, Data Lake storage, and Data Factory.

Terraform (AzAPI provider) resource definition

The clusters/databases/scripts resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Kusto/clusters/databases/scripts resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Kusto/clusters/databases/scripts@2021-01-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      continueOnErrors = bool
      forceUpdateTag = "string"
      scriptUrl = "string"
      scriptUrlSasToken = "string"
    }
  }
}

Property Values

Microsoft.Kusto/clusters/databases/scripts

Name Description Value
name The resource name string (required)
parent_id The ID of the resource that is the parent for this resource. ID for resource of type: clusters/databases
properties The database script. ScriptProperties
type The resource type "Microsoft.Kusto/clusters/databases/scripts@2021-01-01"

ScriptProperties

Name Description Value
continueOnErrors Flag that indicates whether to continue if one of the command fails. bool
forceUpdateTag A unique string. If changed the script will be applied again. string
scriptUrl The url to the KQL script blob file. string (required)
scriptUrlSasToken The SaS token. string

Constraints:
Sensitive value. Pass in as a secure parameter. (required)

Usage Examples

Terraform Samples

A basic example of deploying Kusto Script.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "cluster" {
  type      = "Microsoft.Kusto/clusters@2023-05-02"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  identity {
    type         = "SystemAssigned"
    identity_ids = []
  }
  body = {
    properties = {
      enableAutoStop                = true
      enableDiskEncryption          = false
      enableDoubleEncryption        = false
      enablePurge                   = false
      enableStreamingIngest         = false
      engineType                    = "V2"
      publicIPType                  = "IPv4"
      publicNetworkAccess           = "Enabled"
      restrictOutboundNetworkAccess = "Disabled"
      trustedExternalTenants = [
      ]
    }
    sku = {
      capacity = 1
      name     = "Dev(No SLA)_Standard_D11_v2"
      tier     = "Basic"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "database" {
  type      = "Microsoft.Kusto/clusters/databases@2023-05-02"
  parent_id = azapi_resource.cluster.id
  name      = var.resource_name
  location  = var.location
  body = {
    kind = "ReadWrite"
    properties = {
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "script" {
  type      = "Microsoft.Kusto/clusters/databases/scripts@2023-05-02"
  parent_id = azapi_resource.database.id
  name      = "create-table-script"
  body = {
    properties = {
      continueOnErrors = false
      forceUpdateTag   = "9e2e7874-aa37-7041-81b7-06397f03a37d"
      scriptContent    = ".create table TestTable(Id:string, Name:string, _ts:long, _timestamp:datetime)\n.create table TestTable ingestion json mapping \"TestMapping\"\n'['\n'    {\"column\":\"Id\",\"path\":\"$.id\"},'\n'    {\"column\":\"Name\",\"path\":\"$.name\"},'\n'    {\"column\":\"_ts\",\"path\":\"$._ts\"},'\n'    {\"column\":\"_timestamp\",\"path\":\"$._ts\", \"transform\":\"DateTimeFromUnixSeconds\"}'\n']'\n.alter table TestTable policy ingestionbatching \"{'MaximumBatchingTimeSpan': '0:0:10', 'MaximumNumberOfItems': 10000}\"\n"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

A basic example of deploying Kusto Script.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "cluster" {
  type      = "Microsoft.Kusto/clusters@2023-05-02"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  identity {
    type         = "SystemAssigned"
    identity_ids = []
  }
  body = {
    properties = {
      enableAutoStop                = true
      enableDiskEncryption          = false
      enableDoubleEncryption        = false
      enablePurge                   = false
      enableStreamingIngest         = false
      engineType                    = "V2"
      publicIPType                  = "IPv4"
      publicNetworkAccess           = "Enabled"
      restrictOutboundNetworkAccess = "Disabled"
      trustedExternalTenants = [
      ]
    }
    sku = {
      capacity = 1
      name     = "Dev(No SLA)_Standard_D11_v2"
      tier     = "Basic"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "database" {
  type      = "Microsoft.Kusto/clusters/databases@2023-05-02"
  parent_id = azapi_resource.cluster.id
  name      = var.resource_name
  location  = var.location
  body = {
    kind = "ReadWrite"
    properties = {
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "script" {
  type      = "Microsoft.Kusto/clusters/databases/scripts@2023-05-02"
  parent_id = azapi_resource.database.id
  name      = "create-table-script"
  body = {
    properties = {
      continueOnErrors = false
      forceUpdateTag   = "9e2e7874-aa37-7041-81b7-06397f03a37d"
      scriptContent    = ".create table TestTable(Id:string, Name:string, _ts:long, _timestamp:datetime)\n.create table TestTable ingestion json mapping \"TestMapping\"\n'['\n'    {\"column\":\"Id\",\"path\":\"$.id\"},'\n'    {\"column\":\"Name\",\"path\":\"$.name\"},'\n'    {\"column\":\"_ts\",\"path\":\"$._ts\"},'\n'    {\"column\":\"_timestamp\",\"path\":\"$._ts\", \"transform\":\"DateTimeFromUnixSeconds\"}'\n']'\n.alter table TestTable policy ingestionbatching \"{'MaximumBatchingTimeSpan': '0:0:10', 'MaximumNumberOfItems': 10000}\"\n"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}