Skip to content

azurermKustoScript

Manages a Kusto Script.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
  features: [{}],
});
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_2",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageContainerExample =
  new azurerm.storageContainer.StorageContainer(this, "example_3", {
    container_access_type: "private",
    name: "setup-files",
    storage_account_name: azurermStorageAccountExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageContainerExample.overrideLogicalId("example");
const dataAzurermStorageAccountBlobContainerSasExample =
  new azurerm.dataAzurermStorageAccountBlobContainerSas.DataAzurermStorageAccountBlobContainerSas(
    this,
    "example_4",
    {
      connection_string: azurermStorageAccountExample.primaryConnectionString,
      container_name: azurermStorageContainerExample.name,
      expiry: "2022-03-21",
      https_only: true,
      permissions: [
        {
          add: false,
          create: false,
          delete: false,
          list: true,
          read: true,
          write: true,
        },
      ],
      start: "2017-03-21",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermStorageAccountBlobContainerSasExample.overrideLogicalId("example");
const azurermKustoClusterExample = new azurerm.kustoCluster.KustoCluster(
  this,
  "example_5",
  {
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
    sku: [
      {
        capacity: 1,
        name: "Dev(No SLA)_Standard_D11_v2",
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoClusterExample.overrideLogicalId("example");
const azurermKustoDatabaseExample = new azurerm.kustoDatabase.KustoDatabase(
  this,
  "example_6",
  {
    cluster_name: azurermKustoClusterExample.name,
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoDatabaseExample.overrideLogicalId("example");
const azurermStorageBlobExample = new azurerm.storageBlob.StorageBlob(
  this,
  "example_7",
  {
    name: "script.txt",
    source_content:
      ".create table MyTable (Level:string, Timestamp:datetime, UserId:string, TraceId:string, Message:string, ProcessId:int32)",
    storage_account_name: azurermStorageAccountExample.name,
    storage_container_name: azurermStorageContainerExample.name,
    type: "Block",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageBlobExample.overrideLogicalId("example");
const azurermKustoScriptExample = new azurerm.kustoScript.KustoScript(
  this,
  "example_8",
  {
    continue_on_errors_enabled: true,
    database_id: azurermKustoDatabaseExample.id,
    force_an_update_when_value_changed: "first",
    name: "example",
    sas_token: dataAzurermStorageAccountBlobContainerSasExample.sas,
    url: azurermStorageBlobExample.id,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoScriptExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this Kusto Script. Changing this forces a new Kusto Script to be created.

  • databaseId - (Required) The ID of the Kusto Database. Changing this forces a new Kusto Script to be created.


  • continueOnErrorsEnabled - (Optional) Flag that indicates whether to continue if one of the command fails.

  • forceAnUpdateWhenValueChanged - (Optional) A unique string. If changed the script will be applied again.

  • scriptContent - (Optional) The script content. This property should be used when the script is provide inline and not through file in a SA. Must not be used together with url and sasToken properties. Changing this forces a new resource to be created.

  • sasToken - (Optional) The SAS token used to access the script. Must be provided when using scriptUrl property. Changing this forces a new resource to be created.

  • url - (Optional) The url to the KQL script blob file. Must not be used together with scriptContent property. Please reference this documentation that describes the commands that are allowed in the script.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Kusto Script.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Kusto Script.
  • read - (Defaults to 5 minutes) Used when retrieving the Kusto Script.
  • update - (Defaults to 30 minutes) Used when updating the Kusto Script.
  • delete - (Defaults to 30 minutes) Used when deleting the Kusto Script.

Import

Kusto Scripts can be imported using the resourceId, e.g.

terraform import azurerm_kusto_script.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Kusto/clusters/cluster1/databases/database1/scripts/script1