Database

class Database : KotlinCustomResource

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleSqlServer = new azure.sql.SqlServer("example", {
name: "myexamplesqlserver",
resourceGroupName: example.name,
location: example.location,
version: "12.0",
administratorLogin: "4dm1n157r470r",
administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
tags: {
environment: "production",
},
});
const exampleAccount = new azure.storage.Account("example", {
name: "examplesa",
resourceGroupName: example.name,
location: example.location,
accountTier: "Standard",
accountReplicationType: "LRS",
});
const exampleDatabase = new azure.sql.Database("example", {
name: "myexamplesqldatabase",
resourceGroupName: example.name,
location: example.location,
serverName: exampleSqlServer.name,
tags: {
environment: "production",
},
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_sql_server = azure.sql.SqlServer("example",
name="myexamplesqlserver",
resource_group_name=example.name,
location=example.location,
version="12.0",
administrator_login="4dm1n157r470r",
administrator_login_password="4-v3ry-53cr37-p455w0rd",
tags={
"environment": "production",
})
example_account = azure.storage.Account("example",
name="examplesa",
resource_group_name=example.name,
location=example.location,
account_tier="Standard",
account_replication_type="LRS")
example_database = azure.sql.Database("example",
name="myexamplesqldatabase",
resource_group_name=example.name,
location=example.location,
server_name=example_sql_server.name,
tags={
"environment": "production",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleSqlServer = new Azure.Sql.SqlServer("example", new()
{
Name = "myexamplesqlserver",
ResourceGroupName = example.Name,
Location = example.Location,
Version = "12.0",
AdministratorLogin = "4dm1n157r470r",
AdministratorLoginPassword = "4-v3ry-53cr37-p455w0rd",
Tags =
{
{ "environment", "production" },
},
});
var exampleAccount = new Azure.Storage.Account("example", new()
{
Name = "examplesa",
ResourceGroupName = example.Name,
Location = example.Location,
AccountTier = "Standard",
AccountReplicationType = "LRS",
});
var exampleDatabase = new Azure.Sql.Database("example", new()
{
Name = "myexamplesqldatabase",
ResourceGroupName = example.Name,
Location = example.Location,
ServerName = exampleSqlServer.Name,
Tags =
{
{ "environment", "production" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleSqlServer, err := sql.NewSqlServer(ctx, "example", &sql.SqlServerArgs{
Name: pulumi.String("myexamplesqlserver"),
ResourceGroupName: example.Name,
Location: example.Location,
Version: pulumi.String("12.0"),
AdministratorLogin: pulumi.String("4dm1n157r470r"),
AdministratorLoginPassword: pulumi.String("4-v3ry-53cr37-p455w0rd"),
Tags: pulumi.StringMap{
"environment": pulumi.String("production"),
},
})
if err != nil {
return err
}
_, err = storage.NewAccount(ctx, "example", &storage.AccountArgs{
Name: pulumi.String("examplesa"),
ResourceGroupName: example.Name,
Location: example.Location,
AccountTier: pulumi.String("Standard"),
AccountReplicationType: pulumi.String("LRS"),
})
if err != nil {
return err
}
_, err = sql.NewDatabase(ctx, "example", &sql.DatabaseArgs{
Name: pulumi.String("myexamplesqldatabase"),
ResourceGroupName: example.Name,
Location: example.Location,
ServerName: exampleSqlServer.Name,
Tags: pulumi.StringMap{
"environment": pulumi.String("production"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.sql.SqlServer;
import com.pulumi.azure.sql.SqlServerArgs;
import com.pulumi.azure.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.sql.Database;
import com.pulumi.azure.sql.DatabaseArgs;
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) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleSqlServer = new SqlServer("exampleSqlServer", SqlServerArgs.builder()
.name("myexamplesqlserver")
.resourceGroupName(example.name())
.location(example.location())
.version("12.0")
.administratorLogin("4dm1n157r470r")
.administratorLoginPassword("4-v3ry-53cr37-p455w0rd")
.tags(Map.of("environment", "production"))
.build());
var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
.name("examplesa")
.resourceGroupName(example.name())
.location(example.location())
.accountTier("Standard")
.accountReplicationType("LRS")
.build());
var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
.name("myexamplesqldatabase")
.resourceGroupName(example.name())
.location(example.location())
.serverName(exampleSqlServer.name())
.tags(Map.of("environment", "production"))
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleSqlServer:
type: azure:sql:SqlServer
name: example
properties:
name: myexamplesqlserver
resourceGroupName: ${example.name}
location: ${example.location}
version: '12.0'
administratorLogin: 4dm1n157r470r
administratorLoginPassword: 4-v3ry-53cr37-p455w0rd
tags:
environment: production
exampleAccount:
type: azure:storage:Account
name: example
properties:
name: examplesa
resourceGroupName: ${example.name}
location: ${example.location}
accountTier: Standard
accountReplicationType: LRS
exampleDatabase:
type: azure:sql:Database
name: example
properties:
name: myexamplesqldatabase
resourceGroupName: ${example.name}
location: ${example.location}
serverName: ${exampleSqlServer.name}
tags:
environment: production

Import

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

$ pulumi import azure:sql/database:Database database1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver/databases/database1

Properties

Link copied to clipboard
val collation: Output<String>

The name of the collation. Applies only if create_mode is Default. Azure default is SQL_LATIN1_GENERAL_CP1_CI_AS. Changing this forces a new resource to be created.

Link copied to clipboard
val createMode: Output<String>?

Specifies how to create the database. Valid values are: Default, Copy, OnlineSecondary, NonReadableSecondary, PointInTimeRestore, Recovery, Restore or RestoreLongTermRetentionBackup. Must be Default to create a new database. Defaults to Default. Please see Azure SQL Database REST API

Link copied to clipboard
val creationDate: Output<String>

The creation date of the SQL Database.

Link copied to clipboard

The default secondary location of the SQL Database.

Link copied to clipboard
val edition: Output<String>

The edition of the database to be created. Applies only if create_mode is Default. Valid values are: Basic, Standard, Premium, DataWarehouse, Business, BusinessCritical, Free, GeneralPurpose, Hyperscale, Premium, PremiumRS, Standard, Stretch, System, System2, or Web. Please see Azure SQL database models.

Link copied to clipboard
val elasticPoolName: Output<String>

The name of the elastic database pool.

Link copied to clipboard
val encryption: Output<String>
Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val import: Output<DatabaseImport>?

A import block as documented below. create_mode must be set to Default.

Link copied to clipboard
val location: Output<String>

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

Link copied to clipboard
val maxSizeBytes: Output<String>

The maximum size that the database can grow to. Applies only if create_mode is Default. Please see Azure SQL database models.

Link copied to clipboard
val maxSizeGb: Output<String>
Link copied to clipboard
val name: Output<String>

The name of the database. Changing this forces a new resource to be created.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val readScale: Output<Boolean>?

Read-only connections will be redirected to a high-available replica. Please see Use read-only replicas to load-balance read-only query workloads.

Link copied to clipboard

A GUID/UUID corresponding to a configured Service Level Objective for the Azure SQL database which can be used to configure a performance level. .

Link copied to clipboard

The service objective name for the database. Valid values depend on edition and location and may include S0, S1, S2, S3, P1, P2, P4, P6, P11 and ElasticPool. You can list the available names with the CLI: shell az sql db list-editions -l westus -o table. For further information please see Azure CLI - az sql db.

Link copied to clipboard

The name of the resource group in which to create the database. This must be the same as Database Server resource group currently. Changing this forces a new resource to be created.

Link copied to clipboard

The point in time for the restore. Only applies if create_mode is PointInTimeRestore, it should be provided in RFC3339 format, e.g. 2013-11-08T22:00:40Z.

Link copied to clipboard
val serverName: Output<String>

The name of the SQL Server on which to create the database. Changing this forces a new resource to be created.

Link copied to clipboard

The deletion date time of the source database. Only applies to deleted databases where create_mode is PointInTimeRestore.

Link copied to clipboard

The URI of the source database if create_mode value is not Default.

Link copied to clipboard
val tags: Output<Map<String, String>>?

A mapping of tags to assign to the resource.

Link copied to clipboard

Threat detection policy configuration. The threat_detection_policy block supports fields documented below.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val zoneRedundant: Output<Boolean>?

Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.