1. Packages
  2. Azure Classic
  3. API Docs
  4. cosmosdb
  5. SqlTrigger

We recommend using Azure Native.

Azure Classic v5.73.0 published on Monday, Apr 22, 2024 by Pulumi

azure.cosmosdb.SqlTrigger

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.73.0 published on Monday, Apr 22, 2024 by Pulumi

    Manages an SQL Trigger.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = azure.cosmosdb.getAccount({
        name: "tfex-cosmosdb-account",
        resourceGroupName: "tfex-cosmosdb-account-rg",
    });
    const exampleSqlDatabase = new azure.cosmosdb.SqlDatabase("example", {
        name: "tfex-cosmos-db",
        resourceGroupName: example.then(example => example.resourceGroupName),
        accountName: example.then(example => example.name),
        throughput: 400,
    });
    const exampleSqlContainer = new azure.cosmosdb.SqlContainer("example", {
        name: "example-container",
        resourceGroupName: example.then(example => example.resourceGroupName),
        accountName: example.then(example => example.name),
        databaseName: exampleSqlDatabase.name,
        partitionKeyPath: "/id",
    });
    const exampleSqlTrigger = new azure.cosmosdb.SqlTrigger("example", {
        name: "test-trigger",
        containerId: exampleSqlContainer.id,
        body: "function trigger(){}",
        operation: "Delete",
        type: "Post",
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.cosmosdb.get_account(name="tfex-cosmosdb-account",
        resource_group_name="tfex-cosmosdb-account-rg")
    example_sql_database = azure.cosmosdb.SqlDatabase("example",
        name="tfex-cosmos-db",
        resource_group_name=example.resource_group_name,
        account_name=example.name,
        throughput=400)
    example_sql_container = azure.cosmosdb.SqlContainer("example",
        name="example-container",
        resource_group_name=example.resource_group_name,
        account_name=example.name,
        database_name=example_sql_database.name,
        partition_key_path="/id")
    example_sql_trigger = azure.cosmosdb.SqlTrigger("example",
        name="test-trigger",
        container_id=example_sql_container.id,
        body="function trigger(){}",
        operation="Delete",
        type="Post")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/cosmosdb"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := cosmosdb.LookupAccount(ctx, &cosmosdb.LookupAccountArgs{
    			Name:              "tfex-cosmosdb-account",
    			ResourceGroupName: "tfex-cosmosdb-account-rg",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleSqlDatabase, err := cosmosdb.NewSqlDatabase(ctx, "example", &cosmosdb.SqlDatabaseArgs{
    			Name:              pulumi.String("tfex-cosmos-db"),
    			ResourceGroupName: pulumi.String(example.ResourceGroupName),
    			AccountName:       pulumi.String(example.Name),
    			Throughput:        pulumi.Int(400),
    		})
    		if err != nil {
    			return err
    		}
    		exampleSqlContainer, err := cosmosdb.NewSqlContainer(ctx, "example", &cosmosdb.SqlContainerArgs{
    			Name:              pulumi.String("example-container"),
    			ResourceGroupName: pulumi.String(example.ResourceGroupName),
    			AccountName:       pulumi.String(example.Name),
    			DatabaseName:      exampleSqlDatabase.Name,
    			PartitionKeyPath:  pulumi.String("/id"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cosmosdb.NewSqlTrigger(ctx, "example", &cosmosdb.SqlTriggerArgs{
    			Name:        pulumi.String("test-trigger"),
    			ContainerId: exampleSqlContainer.ID(),
    			Body:        pulumi.String("function trigger(){}"),
    			Operation:   pulumi.String("Delete"),
    			Type:        pulumi.String("Post"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Azure.CosmosDB.GetAccount.Invoke(new()
        {
            Name = "tfex-cosmosdb-account",
            ResourceGroupName = "tfex-cosmosdb-account-rg",
        });
    
        var exampleSqlDatabase = new Azure.CosmosDB.SqlDatabase("example", new()
        {
            Name = "tfex-cosmos-db",
            ResourceGroupName = example.Apply(getAccountResult => getAccountResult.ResourceGroupName),
            AccountName = example.Apply(getAccountResult => getAccountResult.Name),
            Throughput = 400,
        });
    
        var exampleSqlContainer = new Azure.CosmosDB.SqlContainer("example", new()
        {
            Name = "example-container",
            ResourceGroupName = example.Apply(getAccountResult => getAccountResult.ResourceGroupName),
            AccountName = example.Apply(getAccountResult => getAccountResult.Name),
            DatabaseName = exampleSqlDatabase.Name,
            PartitionKeyPath = "/id",
        });
    
        var exampleSqlTrigger = new Azure.CosmosDB.SqlTrigger("example", new()
        {
            Name = "test-trigger",
            ContainerId = exampleSqlContainer.Id,
            Body = "function trigger(){}",
            Operation = "Delete",
            Type = "Post",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.cosmosdb.CosmosdbFunctions;
    import com.pulumi.azure.cosmosdb.inputs.GetAccountArgs;
    import com.pulumi.azure.cosmosdb.SqlDatabase;
    import com.pulumi.azure.cosmosdb.SqlDatabaseArgs;
    import com.pulumi.azure.cosmosdb.SqlContainer;
    import com.pulumi.azure.cosmosdb.SqlContainerArgs;
    import com.pulumi.azure.cosmosdb.SqlTrigger;
    import com.pulumi.azure.cosmosdb.SqlTriggerArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = CosmosdbFunctions.getAccount(GetAccountArgs.builder()
                .name("tfex-cosmosdb-account")
                .resourceGroupName("tfex-cosmosdb-account-rg")
                .build());
    
            var exampleSqlDatabase = new SqlDatabase("exampleSqlDatabase", SqlDatabaseArgs.builder()        
                .name("tfex-cosmos-db")
                .resourceGroupName(example.applyValue(getAccountResult -> getAccountResult.resourceGroupName()))
                .accountName(example.applyValue(getAccountResult -> getAccountResult.name()))
                .throughput(400)
                .build());
    
            var exampleSqlContainer = new SqlContainer("exampleSqlContainer", SqlContainerArgs.builder()        
                .name("example-container")
                .resourceGroupName(example.applyValue(getAccountResult -> getAccountResult.resourceGroupName()))
                .accountName(example.applyValue(getAccountResult -> getAccountResult.name()))
                .databaseName(exampleSqlDatabase.name())
                .partitionKeyPath("/id")
                .build());
    
            var exampleSqlTrigger = new SqlTrigger("exampleSqlTrigger", SqlTriggerArgs.builder()        
                .name("test-trigger")
                .containerId(exampleSqlContainer.id())
                .body("function trigger(){}")
                .operation("Delete")
                .type("Post")
                .build());
    
        }
    }
    
    resources:
      exampleSqlDatabase:
        type: azure:cosmosdb:SqlDatabase
        name: example
        properties:
          name: tfex-cosmos-db
          resourceGroupName: ${example.resourceGroupName}
          accountName: ${example.name}
          throughput: 400
      exampleSqlContainer:
        type: azure:cosmosdb:SqlContainer
        name: example
        properties:
          name: example-container
          resourceGroupName: ${example.resourceGroupName}
          accountName: ${example.name}
          databaseName: ${exampleSqlDatabase.name}
          partitionKeyPath: /id
      exampleSqlTrigger:
        type: azure:cosmosdb:SqlTrigger
        name: example
        properties:
          name: test-trigger
          containerId: ${exampleSqlContainer.id}
          body: function trigger(){}
          operation: Delete
          type: Post
    variables:
      example:
        fn::invoke:
          Function: azure:cosmosdb:getAccount
          Arguments:
            name: tfex-cosmosdb-account
            resourceGroupName: tfex-cosmosdb-account-rg
    

    Create SqlTrigger Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new SqlTrigger(name: string, args: SqlTriggerArgs, opts?: CustomResourceOptions);
    @overload
    def SqlTrigger(resource_name: str,
                   args: SqlTriggerArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def SqlTrigger(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   body: Optional[str] = None,
                   container_id: Optional[str] = None,
                   operation: Optional[str] = None,
                   type: Optional[str] = None,
                   name: Optional[str] = None)
    func NewSqlTrigger(ctx *Context, name string, args SqlTriggerArgs, opts ...ResourceOption) (*SqlTrigger, error)
    public SqlTrigger(string name, SqlTriggerArgs args, CustomResourceOptions? opts = null)
    public SqlTrigger(String name, SqlTriggerArgs args)
    public SqlTrigger(String name, SqlTriggerArgs args, CustomResourceOptions options)
    
    type: azure:cosmosdb:SqlTrigger
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SqlTriggerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args SqlTriggerArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args SqlTriggerArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SqlTriggerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SqlTriggerArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var sqlTriggerResource = new Azure.CosmosDB.SqlTrigger("sqlTriggerResource", new()
    {
        Body = "string",
        ContainerId = "string",
        Operation = "string",
        Type = "string",
        Name = "string",
    });
    
    example, err := cosmosdb.NewSqlTrigger(ctx, "sqlTriggerResource", &cosmosdb.SqlTriggerArgs{
    	Body:        pulumi.String("string"),
    	ContainerId: pulumi.String("string"),
    	Operation:   pulumi.String("string"),
    	Type:        pulumi.String("string"),
    	Name:        pulumi.String("string"),
    })
    
    var sqlTriggerResource = new SqlTrigger("sqlTriggerResource", SqlTriggerArgs.builder()        
        .body("string")
        .containerId("string")
        .operation("string")
        .type("string")
        .name("string")
        .build());
    
    sql_trigger_resource = azure.cosmosdb.SqlTrigger("sqlTriggerResource",
        body="string",
        container_id="string",
        operation="string",
        type="string",
        name="string")
    
    const sqlTriggerResource = new azure.cosmosdb.SqlTrigger("sqlTriggerResource", {
        body: "string",
        containerId: "string",
        operation: "string",
        type: "string",
        name: "string",
    });
    
    type: azure:cosmosdb:SqlTrigger
    properties:
        body: string
        containerId: string
        name: string
        operation: string
        type: string
    

    SqlTrigger Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The SqlTrigger resource accepts the following input properties:

    Body string
    Body of the Trigger.
    ContainerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    Operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    Type string
    Type of the Trigger. Possible values are Pre and Post.
    Name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    Body string
    Body of the Trigger.
    ContainerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    Operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    Type string
    Type of the Trigger. Possible values are Pre and Post.
    Name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    body String
    Body of the Trigger.
    containerId String
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    operation String
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type String
    Type of the Trigger. Possible values are Pre and Post.
    name String
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    body string
    Body of the Trigger.
    containerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type string
    Type of the Trigger. Possible values are Pre and Post.
    name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    body str
    Body of the Trigger.
    container_id str
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    operation str
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type str
    Type of the Trigger. Possible values are Pre and Post.
    name str
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    body String
    Body of the Trigger.
    containerId String
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    operation String
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type String
    Type of the Trigger. Possible values are Pre and Post.
    name String
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the SqlTrigger resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing SqlTrigger Resource

    Get an existing SqlTrigger resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: SqlTriggerState, opts?: CustomResourceOptions): SqlTrigger
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            body: Optional[str] = None,
            container_id: Optional[str] = None,
            name: Optional[str] = None,
            operation: Optional[str] = None,
            type: Optional[str] = None) -> SqlTrigger
    func GetSqlTrigger(ctx *Context, name string, id IDInput, state *SqlTriggerState, opts ...ResourceOption) (*SqlTrigger, error)
    public static SqlTrigger Get(string name, Input<string> id, SqlTriggerState? state, CustomResourceOptions? opts = null)
    public static SqlTrigger get(String name, Output<String> id, SqlTriggerState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Body string
    Body of the Trigger.
    ContainerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    Name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    Operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    Type string
    Type of the Trigger. Possible values are Pre and Post.
    Body string
    Body of the Trigger.
    ContainerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    Name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    Operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    Type string
    Type of the Trigger. Possible values are Pre and Post.
    body String
    Body of the Trigger.
    containerId String
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    name String
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    operation String
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type String
    Type of the Trigger. Possible values are Pre and Post.
    body string
    Body of the Trigger.
    containerId string
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    name string
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    operation string
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type string
    Type of the Trigger. Possible values are Pre and Post.
    body str
    Body of the Trigger.
    container_id str
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    name str
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    operation str
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type str
    Type of the Trigger. Possible values are Pre and Post.
    body String
    Body of the Trigger.
    containerId String
    The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
    name String
    The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
    operation String
    The operation the trigger is associated with. Possible values are All, Create, Update, Delete and Replace.
    type String
    Type of the Trigger. Possible values are Pre and Post.

    Import

    SQL Triggers can be imported using the resource id, e.g.

    $ pulumi import azure:cosmosdb/sqlTrigger:SqlTrigger example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Azure Classic v5.73.0 published on Monday, Apr 22, 2024 by Pulumi