1. Packages
  2. Azure Classic
  3. API Docs
  4. postgresql
  5. Database

We recommend using Azure Native.

Azure Classic v5.57.0 published on Tuesday, Nov 28, 2023 by Pulumi

azure.postgresql.Database

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.57.0 published on Tuesday, Nov 28, 2023 by Pulumi

    Manages a PostgreSQL Database within a PostgreSQL Server

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
        {
            Location = "West Europe",
        });
    
        var exampleServer = new Azure.PostgreSql.Server("exampleServer", new()
        {
            Location = exampleResourceGroup.Location,
            ResourceGroupName = exampleResourceGroup.Name,
            SkuName = "B_Gen5_2",
            StorageMb = 5120,
            BackupRetentionDays = 7,
            GeoRedundantBackupEnabled = false,
            AutoGrowEnabled = true,
            AdministratorLogin = "psqladmin",
            AdministratorLoginPassword = "H@Sh1CoR3!",
            Version = "9.5",
            SslEnforcementEnabled = true,
        });
    
        var exampleDatabase = new Azure.PostgreSql.Database("exampleDatabase", new()
        {
            ResourceGroupName = exampleResourceGroup.Name,
            ServerName = exampleServer.Name,
            Charset = "UTF8",
            Collation = "English_United States.1252",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/postgresql"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleServer, err := postgresql.NewServer(ctx, "exampleServer", &postgresql.ServerArgs{
    			Location:                   exampleResourceGroup.Location,
    			ResourceGroupName:          exampleResourceGroup.Name,
    			SkuName:                    pulumi.String("B_Gen5_2"),
    			StorageMb:                  pulumi.Int(5120),
    			BackupRetentionDays:        pulumi.Int(7),
    			GeoRedundantBackupEnabled:  pulumi.Bool(false),
    			AutoGrowEnabled:            pulumi.Bool(true),
    			AdministratorLogin:         pulumi.String("psqladmin"),
    			AdministratorLoginPassword: pulumi.String("H@Sh1CoR3!"),
    			Version:                    pulumi.String("9.5"),
    			SslEnforcementEnabled:      pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = postgresql.NewDatabase(ctx, "exampleDatabase", &postgresql.DatabaseArgs{
    			ResourceGroupName: exampleResourceGroup.Name,
    			ServerName:        exampleServer.Name,
    			Charset:           pulumi.String("UTF8"),
    			Collation:         pulumi.String("English_United States.1252"),
    		})
    		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.postgresql.Server;
    import com.pulumi.azure.postgresql.ServerArgs;
    import com.pulumi.azure.postgresql.Database;
    import com.pulumi.azure.postgresql.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 exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
                .location("West Europe")
                .build());
    
            var exampleServer = new Server("exampleServer", ServerArgs.builder()        
                .location(exampleResourceGroup.location())
                .resourceGroupName(exampleResourceGroup.name())
                .skuName("B_Gen5_2")
                .storageMb(5120)
                .backupRetentionDays(7)
                .geoRedundantBackupEnabled(false)
                .autoGrowEnabled(true)
                .administratorLogin("psqladmin")
                .administratorLoginPassword("H@Sh1CoR3!")
                .version("9.5")
                .sslEnforcementEnabled(true)
                .build());
    
            var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()        
                .resourceGroupName(exampleResourceGroup.name())
                .serverName(exampleServer.name())
                .charset("UTF8")
                .collation("English_United States.1252")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azure as azure
    
    example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
    example_server = azure.postgresql.Server("exampleServer",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name,
        sku_name="B_Gen5_2",
        storage_mb=5120,
        backup_retention_days=7,
        geo_redundant_backup_enabled=False,
        auto_grow_enabled=True,
        administrator_login="psqladmin",
        administrator_login_password="H@Sh1CoR3!",
        version="9.5",
        ssl_enforcement_enabled=True)
    example_database = azure.postgresql.Database("exampleDatabase",
        resource_group_name=example_resource_group.name,
        server_name=example_server.name,
        charset="UTF8",
        collation="English_United States.1252")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
    const exampleServer = new azure.postgresql.Server("exampleServer", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        skuName: "B_Gen5_2",
        storageMb: 5120,
        backupRetentionDays: 7,
        geoRedundantBackupEnabled: false,
        autoGrowEnabled: true,
        administratorLogin: "psqladmin",
        administratorLoginPassword: "H@Sh1CoR3!",
        version: "9.5",
        sslEnforcementEnabled: true,
    });
    const exampleDatabase = new azure.postgresql.Database("exampleDatabase", {
        resourceGroupName: exampleResourceGroup.name,
        serverName: exampleServer.name,
        charset: "UTF8",
        collation: "English_United States.1252",
    });
    
    resources:
      exampleResourceGroup:
        type: azure:core:ResourceGroup
        properties:
          location: West Europe
      exampleServer:
        type: azure:postgresql:Server
        properties:
          location: ${exampleResourceGroup.location}
          resourceGroupName: ${exampleResourceGroup.name}
          skuName: B_Gen5_2
          storageMb: 5120
          backupRetentionDays: 7
          geoRedundantBackupEnabled: false
          autoGrowEnabled: true
          administratorLogin: psqladmin
          administratorLoginPassword: H@Sh1CoR3!
          version: '9.5'
          sslEnforcementEnabled: true
      exampleDatabase:
        type: azure:postgresql:Database
        properties:
          resourceGroupName: ${exampleResourceGroup.name}
          serverName: ${exampleServer.name}
          charset: UTF8
          collation: English_United States.1252
    

    Create Database Resource

    new Database(name: string, args: DatabaseArgs, opts?: CustomResourceOptions);
    @overload
    def Database(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 charset: Optional[str] = None,
                 collation: Optional[str] = None,
                 name: Optional[str] = None,
                 resource_group_name: Optional[str] = None,
                 server_name: Optional[str] = None)
    @overload
    def Database(resource_name: str,
                 args: DatabaseArgs,
                 opts: Optional[ResourceOptions] = None)
    func NewDatabase(ctx *Context, name string, args DatabaseArgs, opts ...ResourceOption) (*Database, error)
    public Database(string name, DatabaseArgs args, CustomResourceOptions? opts = null)
    public Database(String name, DatabaseArgs args)
    public Database(String name, DatabaseArgs args, CustomResourceOptions options)
    
    type: azure:postgresql:Database
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args DatabaseArgs
    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 DatabaseArgs
    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 DatabaseArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    Charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    Collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    ResourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    ServerName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    Name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    Charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    Collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    ResourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    ServerName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    Name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    charset String

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation String

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    resourceGroupName String

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName String

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    name String

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    resourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    charset str

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation str

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    resource_group_name str

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    server_name str

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    name str

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    charset String

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation String

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    resourceGroupName String

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName String

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    name String

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    Outputs

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

    Get an existing Database 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?: DatabaseState, opts?: CustomResourceOptions): Database
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            charset: Optional[str] = None,
            collation: Optional[str] = None,
            name: Optional[str] = None,
            resource_group_name: Optional[str] = None,
            server_name: Optional[str] = None) -> Database
    func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
    public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
    public static Database get(String name, Output<String> id, DatabaseState 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:
    Charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    Collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    Name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    ResourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    ServerName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    Charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    Collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    Name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    ResourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    ServerName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    charset String

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation String

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    name String

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    resourceGroupName String

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName String

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    charset string

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation string

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    name string

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    resourceGroupName string

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName string

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    charset str

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation str

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    name str

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    resource_group_name str

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    server_name str

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    charset String

    Specifies the Charset for the PostgreSQL Database, which needs to be a valid PostgreSQL Charset. Changing this forces a new resource to be created.

    collation String

    Specifies the Collation for the PostgreSQL Database, which needs to be a valid PostgreSQL Collation. Note that Microsoft uses different notation - en-US instead of en_US. Changing this forces a new resource to be created.

    name String

    Specifies the name of the PostgreSQL Database, which needs to be a valid PostgreSQL identifier. Changing this forces a new resource to be created.

    resourceGroupName String

    The name of the resource group in which the PostgreSQL Server exists. Changing this forces a new resource to be created.

    serverName String

    Specifies the name of the PostgreSQL Server. Changing this forces a new resource to be created.

    Import

    PostgreSQL Database’s can be imported using the resource id, e.g.

     $ pulumi import azure:postgresql/database:Database database1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforPostgreSQL/servers/server1/databases/database1
    

    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.57.0 published on Tuesday, Nov 28, 2023 by Pulumi