Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse
mssql.getDatabase
Explore with Pulumi AI

Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse
Obtains information about single database.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mssql = Pulumi.Mssql;
return await Deployment.RunAsync(() =>
{
var example = Mssql.GetDatabase.Invoke(new()
{
Name = "example",
});
return new Dictionary<string, object?>
{
["dbId"] = example.Apply(getDatabaseResult => getDatabaseResult.Id),
["dbCollation"] = example.Apply(getDatabaseResult => getDatabaseResult.Collation),
};
});
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-mssql/sdk/go/mssql"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
Name: "example",
}, nil)
if err != nil {
return err
}
ctx.Export("dbId", example.Id)
ctx.Export("dbCollation", example.Collation)
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mssql.MssqlFunctions;
import com.pulumi.mssql.inputs.GetDatabaseArgs;
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 = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
.name("example")
.build());
ctx.export("dbId", example.applyValue(getDatabaseResult -> getDatabaseResult.id()));
ctx.export("dbCollation", example.applyValue(getDatabaseResult -> getDatabaseResult.collation()));
}
}
import pulumi
import pulumi_mssql as mssql
example = mssql.get_database(name="example")
pulumi.export("dbId", example.id)
pulumi.export("dbCollation", example.collation)
import * as pulumi from "@pulumi/pulumi";
import * as mssql from "@pulumi/mssql";
const example = mssql.getDatabase({
name: "example",
});
export const dbId = example.then(example => example.id);
export const dbCollation = example.then(example => example.collation);
variables:
example:
fn::invoke:
Function: mssql:getDatabase
Arguments:
name: example
outputs:
dbId: ${example.id}
dbCollation: ${example.collation}
Using getDatabase
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getDatabase(args: GetDatabaseArgs, opts?: InvokeOptions): Promise<GetDatabaseResult>
function getDatabaseOutput(args: GetDatabaseOutputArgs, opts?: InvokeOptions): Output<GetDatabaseResult>
def get_database(name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetDatabaseResult
def get_database_output(name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseResult]
func LookupDatabase(ctx *Context, args *LookupDatabaseArgs, opts ...InvokeOption) (*LookupDatabaseResult, error)
func LookupDatabaseOutput(ctx *Context, args *LookupDatabaseOutputArgs, opts ...InvokeOption) LookupDatabaseResultOutput
> Note: This function is named LookupDatabase
in the Go SDK.
public static class GetDatabase
{
public static Task<GetDatabaseResult> InvokeAsync(GetDatabaseArgs args, InvokeOptions? opts = null)
public static Output<GetDatabaseResult> Invoke(GetDatabaseInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: mssql:index/getDatabase:getDatabase
arguments:
# arguments dictionary
The following arguments are supported:
- Name string
- Database name. Must follow Regular Identifiers rules.
- Name string
- Database name. Must follow Regular Identifiers rules.
- name String
- Database name. Must follow Regular Identifiers rules.
- name string
- Database name. Must follow Regular Identifiers rules.
- name str
- Database name. Must follow Regular Identifiers rules.
- name String
- Database name. Must follow Regular Identifiers rules.
getDatabase Result
The following output properties are available:
- Collation string
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- Id string
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - Name string
- Database name. Must follow Regular Identifiers rules.
- Collation string
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- Id string
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - Name string
- Database name. Must follow Regular Identifiers rules.
- collation String
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- id String
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - name String
- Database name. Must follow Regular Identifiers rules.
- collation string
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- id string
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - name string
- Database name. Must follow Regular Identifiers rules.
- collation str
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- id str
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - name str
- Database name. Must follow Regular Identifiers rules.
- collation String
- Default collation name. Can be either a Windows collation name or a SQL collation name.
- id String
- Database ID. Can be retrieved using
SELECT DB_ID('<db_name>')
. - name String
- Database name. Must follow Regular Identifiers rules.
Package Details
- Repository
- mssql pulumiverse/pulumi-mssql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
mssql
Terraform Provider.

Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse