Skip to content

azurermCosmosdbSqlFunction

Manages an SQL User Defined Function.

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.*/
const dataAzurermCosmosdbAccountExample =
  new azurerm.dataAzurermCosmosdbAccount.DataAzurermCosmosdbAccount(
    this,
    "example",
    {
      name: "tfex-cosmosdb-account",
      resource_group_name: "tfex-cosmosdb-account-rg",
    }
  );
const azurermCosmosdbSqlDatabaseExample =
  new azurerm.cosmosdbSqlDatabase.CosmosdbSqlDatabase(this, "example_1", {
    account_name: dataAzurermCosmosdbAccountExample.name,
    name: "tfex-cosmos-db",
    resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
    throughput: 400,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlDatabaseExample.overrideLogicalId("example");
const azurermCosmosdbSqlContainerExample =
  new azurerm.cosmosdbSqlContainer.CosmosdbSqlContainer(this, "example_2", {
    account_name: dataAzurermCosmosdbAccountExample.name,
    database_name: azurermCosmosdbSqlDatabaseExample.name,
    name: "example-container",
    partition_key_path: "/id",
    resource_group_name: dataAzurermCosmosdbAccountExample.resourceGroupName,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlContainerExample.overrideLogicalId("example");
const azurermCosmosdbSqlFunctionExample =
  new azurerm.cosmosdbSqlFunction.CosmosdbSqlFunction(this, "example_3", {
    body: "function trigger(){}",
    container_id: azurermCosmosdbSqlContainerExample.id,
    name: "test-function",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlFunctionExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

  • containerId - (Required) The id of the Cosmos DB SQL Container to create the SQL User Defined Function within. Changing this forces a new SQL User Defined Function to be created.

  • body - (Required) Body of the User Defined Function.

Attributes Reference

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

  • id - The ID of the SQL User Defined Function.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the SQL User Defined Function.
  • read - (Defaults to 5 minutes) Used when retrieving the SQL User Defined Function.
  • update - (Defaults to 30 minutes) Used when updating the SQL User Defined Function.
  • delete - (Defaults to 30 minutes) Used when deleting the SQL User Defined Function.

Import

SQL User Defined Functions can be imported using the resourceId, e.g.

terraform import azurerm_cosmosdb_sql_function.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1