Azure Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Friday, Jun 10, 2022 by Pulumi

SqlFunction

Manages an SQL User Defined Function.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleAccount = Output.Create(Azure.CosmosDB.GetAccount.InvokeAsync(new Azure.CosmosDB.GetAccountArgs
        {
            Name = "tfex-cosmosdb-account",
            ResourceGroupName = "tfex-cosmosdb-account-rg",
        }));
        var exampleSqlDatabase = new Azure.CosmosDB.SqlDatabase("exampleSqlDatabase", new Azure.CosmosDB.SqlDatabaseArgs
        {
            ResourceGroupName = exampleAccount.Apply(exampleAccount => exampleAccount.ResourceGroupName),
            AccountName = exampleAccount.Apply(exampleAccount => exampleAccount.Name),
            Throughput = 400,
        });
        var exampleSqlContainer = new Azure.CosmosDB.SqlContainer("exampleSqlContainer", new Azure.CosmosDB.SqlContainerArgs
        {
            ResourceGroupName = azurerm_cosmosdb_account.Example.Resource_group_name,
            AccountName = azurerm_cosmosdb_account.Example.Name,
            DatabaseName = exampleSqlDatabase.Name,
            PartitionKeyPath = "/id",
        });
        var exampleSqlFunction = new Azure.CosmosDB.SqlFunction("exampleSqlFunction", new Azure.CosmosDB.SqlFunctionArgs
        {
            ContainerId = exampleSqlContainer.Id,
            Body = "function trigger(){}",
        });
    }

}
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 {
		exampleAccount, 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, "exampleSqlDatabase", &cosmosdb.SqlDatabaseArgs{
			ResourceGroupName: pulumi.String(exampleAccount.ResourceGroupName),
			AccountName:       pulumi.String(exampleAccount.Name),
			Throughput:        pulumi.Int(400),
		})
		if err != nil {
			return err
		}
		exampleSqlContainer, err := cosmosdb.NewSqlContainer(ctx, "exampleSqlContainer", &cosmosdb.SqlContainerArgs{
			ResourceGroupName: pulumi.Any(azurerm_cosmosdb_account.Example.Resource_group_name),
			AccountName:       pulumi.Any(azurerm_cosmosdb_account.Example.Name),
			DatabaseName:      exampleSqlDatabase.Name,
			PartitionKeyPath:  pulumi.String("/id"),
		})
		if err != nil {
			return err
		}
		_, err = cosmosdb.NewSqlFunction(ctx, "exampleSqlFunction", &cosmosdb.SqlFunctionArgs{
			ContainerId: exampleSqlContainer.ID(),
			Body:        pulumi.String("function trigger(){}"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var exampleAccount = Output.of(CosmosdbFunctions.getAccount(GetAccountArgs.builder()
            .name("tfex-cosmosdb-account")
            .resourceGroupName("tfex-cosmosdb-account-rg")
            .build()));

        var exampleSqlDatabase = new SqlDatabase("exampleSqlDatabase", SqlDatabaseArgs.builder()        
            .resourceGroupName(exampleAccount.apply(getAccountResult -> getAccountResult.resourceGroupName()))
            .accountName(exampleAccount.apply(getAccountResult -> getAccountResult.name()))
            .throughput(400)
            .build());

        var exampleSqlContainer = new SqlContainer("exampleSqlContainer", SqlContainerArgs.builder()        
            .resourceGroupName(azurerm_cosmosdb_account.example().resource_group_name())
            .accountName(azurerm_cosmosdb_account.example().name())
            .databaseName(exampleSqlDatabase.name())
            .partitionKeyPath("/id")
            .build());

        var exampleSqlFunction = new SqlFunction("exampleSqlFunction", SqlFunctionArgs.builder()        
            .containerId(exampleSqlContainer.id())
            .body("function trigger(){}")
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example_account = azure.cosmosdb.get_account(name="tfex-cosmosdb-account",
    resource_group_name="tfex-cosmosdb-account-rg")
example_sql_database = azure.cosmosdb.SqlDatabase("exampleSqlDatabase",
    resource_group_name=example_account.resource_group_name,
    account_name=example_account.name,
    throughput=400)
example_sql_container = azure.cosmosdb.SqlContainer("exampleSqlContainer",
    resource_group_name=azurerm_cosmosdb_account["example"]["resource_group_name"],
    account_name=azurerm_cosmosdb_account["example"]["name"],
    database_name=example_sql_database.name,
    partition_key_path="/id")
example_sql_function = azure.cosmosdb.SqlFunction("exampleSqlFunction",
    container_id=example_sql_container.id,
    body="function trigger(){}")
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleAccount = azure.cosmosdb.getAccount({
    name: "tfex-cosmosdb-account",
    resourceGroupName: "tfex-cosmosdb-account-rg",
});
const exampleSqlDatabase = new azure.cosmosdb.SqlDatabase("exampleSqlDatabase", {
    resourceGroupName: exampleAccount.then(exampleAccount => exampleAccount.resourceGroupName),
    accountName: exampleAccount.then(exampleAccount => exampleAccount.name),
    throughput: 400,
});
const exampleSqlContainer = new azure.cosmosdb.SqlContainer("exampleSqlContainer", {
    resourceGroupName: azurerm_cosmosdb_account.example.resource_group_name,
    accountName: azurerm_cosmosdb_account.example.name,
    databaseName: exampleSqlDatabase.name,
    partitionKeyPath: "/id",
});
const exampleSqlFunction = new azure.cosmosdb.SqlFunction("exampleSqlFunction", {
    containerId: exampleSqlContainer.id,
    body: "function trigger(){}",
});
resources:
  exampleSqlDatabase:
    type: azure:cosmosdb:SqlDatabase
    properties:
      resourceGroupName: ${exampleAccount.resourceGroupName}
      accountName: ${exampleAccount.name}
      throughput: 400
  exampleSqlContainer:
    type: azure:cosmosdb:SqlContainer
    properties:
      resourceGroupName: ${azurerm_cosmosdb_account.example.resource_group_name}
      accountName: ${azurerm_cosmosdb_account.example.name}
      databaseName: ${exampleSqlDatabase.name}
      partitionKeyPath: /id
  exampleSqlFunction:
    type: azure:cosmosdb:SqlFunction
    properties:
      containerId: ${exampleSqlContainer.id}
      body: function trigger(){}
variables:
  exampleAccount:
    Fn::Invoke:
      Function: azure:cosmosdb:getAccount
      Arguments:
        name: tfex-cosmosdb-account
        resourceGroupName: tfex-cosmosdb-account-rg

Create a SqlFunction Resource

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

name string
The unique name of the resource.
args SqlFunctionArgs
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 SqlFunctionArgs
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 SqlFunctionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args SqlFunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args SqlFunctionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

SqlFunction 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 SqlFunction resource accepts the following input properties:

Body string

Body of the User Defined Function.

ContainerId string

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.

Name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

Body string

Body of the User Defined Function.

ContainerId string

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.

Name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body String

Body of the User Defined Function.

containerId String

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.

name String

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body string

Body of the User Defined Function.

containerId string

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.

name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body str

Body of the User Defined Function.

container_id str

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.

name str

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body String

Body of the User Defined Function.

containerId String

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.

name String

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

Outputs

All input properties are implicitly available as output properties. Additionally, the SqlFunction 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 an Existing SqlFunction Resource

Get an existing SqlFunction 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?: SqlFunctionState, opts?: CustomResourceOptions): SqlFunction
@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) -> SqlFunction
func GetSqlFunction(ctx *Context, name string, id IDInput, state *SqlFunctionState, opts ...ResourceOption) (*SqlFunction, error)
public static SqlFunction Get(string name, Input<string> id, SqlFunctionState? state, CustomResourceOptions? opts = null)
public static SqlFunction get(String name, Output<String> id, SqlFunctionState 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 User Defined Function.

ContainerId string

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.

Name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

Body string

Body of the User Defined Function.

ContainerId string

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.

Name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body String

Body of the User Defined Function.

containerId String

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.

name String

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body string

Body of the User Defined Function.

containerId string

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.

name string

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body str

Body of the User Defined Function.

container_id str

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.

name str

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

body String

Body of the User Defined Function.

containerId String

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.

name String

The name which should be used for this SQL User Defined Function. Changing this forces a new SQL User Defined Function to be created.

Import

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

 $ pulumi import azure:cosmosdb/sqlFunction:SqlFunction example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.