Azure Classic

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

SqlStoredProcedure

Manages a SQL Stored Procedure within a Cosmos DB Account SQL Database.

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 exampleSqlStoredProcedure = new Azure.CosmosDB.SqlStoredProcedure("exampleSqlStoredProcedure", new Azure.CosmosDB.SqlStoredProcedureArgs
        {
            ResourceGroupName = azurerm_cosmosdb_account.Example.Resource_group_name,
            AccountName = azurerm_cosmosdb_account.Example.Name,
            DatabaseName = exampleSqlDatabase.Name,
            ContainerName = exampleSqlContainer.Name,
            Body = @"  	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }
",
        });
    }

}
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.NewSqlStoredProcedure(ctx, "exampleSqlStoredProcedure", &cosmosdb.SqlStoredProcedureArgs{
			ResourceGroupName: pulumi.Any(azurerm_cosmosdb_account.Example.Resource_group_name),
			AccountName:       pulumi.Any(azurerm_cosmosdb_account.Example.Name),
			DatabaseName:      exampleSqlDatabase.Name,
			ContainerName:     exampleSqlContainer.Name,
			Body: pulumi.String("  	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }\n"),
		})
		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 exampleSqlStoredProcedure = new SqlStoredProcedure("exampleSqlStoredProcedure", SqlStoredProcedureArgs.builder()        
            .resourceGroupName(azurerm_cosmosdb_account.example().resource_group_name())
            .accountName(azurerm_cosmosdb_account.example().name())
            .databaseName(exampleSqlDatabase.name())
            .containerName(exampleSqlContainer.name())
            .body("""
  	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }
            """)
            .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_stored_procedure = azure.cosmosdb.SqlStoredProcedure("exampleSqlStoredProcedure",
    resource_group_name=azurerm_cosmosdb_account["example"]["resource_group_name"],
    account_name=azurerm_cosmosdb_account["example"]["name"],
    database_name=example_sql_database.name,
    container_name=example_sql_container.name,
    body="  	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }\n")
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 exampleSqlStoredProcedure = new azure.cosmosdb.SqlStoredProcedure("exampleSqlStoredProcedure", {
    resourceGroupName: azurerm_cosmosdb_account.example.resource_group_name,
    accountName: azurerm_cosmosdb_account.example.name,
    databaseName: exampleSqlDatabase.name,
    containerName: exampleSqlContainer.name,
    body: "  	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }\n",
});
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
  exampleSqlStoredProcedure:
    type: azure:cosmosdb:SqlStoredProcedure
    properties:
      resourceGroupName: ${azurerm_cosmosdb_account.example.resource_group_name}
      accountName: ${azurerm_cosmosdb_account.example.name}
      databaseName: ${exampleSqlDatabase.name}
      containerName: ${exampleSqlContainer.name}
      body: |2
          	function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }
variables:
  exampleAccount:
    Fn::Invoke:
      Function: azure:cosmosdb:getAccount
      Arguments:
        name: tfex-cosmosdb-account
        resourceGroupName: tfex-cosmosdb-account-rg

Create a SqlStoredProcedure Resource

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

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

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

AccountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

Body string

The body of the stored procedure.

ContainerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

DatabaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

Name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

AccountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

Body string

The body of the stored procedure.

ContainerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

DatabaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

Name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

accountName String

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body String

The body of the stored procedure.

containerName String

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName String

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

name String

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

accountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body string

The body of the stored procedure.

containerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

resourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

account_name str

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body str

The body of the stored procedure.

container_name str

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

database_name str

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

resource_group_name str

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

name str

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

accountName String

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body String

The body of the stored procedure.

containerName String

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName String

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

name String

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

Outputs

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

Get an existing SqlStoredProcedure 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?: SqlStoredProcedureState, opts?: CustomResourceOptions): SqlStoredProcedure
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_name: Optional[str] = None,
        body: Optional[str] = None,
        container_name: Optional[str] = None,
        database_name: Optional[str] = None,
        name: Optional[str] = None,
        resource_group_name: Optional[str] = None) -> SqlStoredProcedure
func GetSqlStoredProcedure(ctx *Context, name string, id IDInput, state *SqlStoredProcedureState, opts ...ResourceOption) (*SqlStoredProcedure, error)
public static SqlStoredProcedure Get(string name, Input<string> id, SqlStoredProcedureState? state, CustomResourceOptions? opts = null)
public static SqlStoredProcedure get(String name, Output<String> id, SqlStoredProcedureState 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:
AccountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

Body string

The body of the stored procedure.

ContainerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

DatabaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

Name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

AccountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

Body string

The body of the stored procedure.

ContainerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

DatabaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

Name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

accountName String

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body String

The body of the stored procedure.

containerName String

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName String

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

name String

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

accountName string

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body string

The body of the stored procedure.

containerName string

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName string

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

name string

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

resourceGroupName string

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

account_name str

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body str

The body of the stored procedure.

container_name str

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

database_name str

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

name str

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

resource_group_name str

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

accountName String

The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

body String

The body of the stored procedure.

containerName String

The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

databaseName String

The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

name String

Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

Import

CosmosDB SQL Stored Procedures can be imported using the resource id, e.g.

 $ pulumi import azure:cosmosdb/sqlStoredProcedure:SqlStoredProcedure db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1/containers/c1/storedProcedures/sp1

Package Details

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

This Pulumi package is based on the azurerm Terraform Provider.