We recommend using Azure Native.
azure.mssql.ManagedDatabase
Explore with Pulumi AI
Manages an Azure SQL Azure Managed Database for a SQL Managed Instance.
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 exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new()
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
AddressSpaces = new[]
{
"10.0.0.0/16",
},
});
var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new()
{
ResourceGroupName = exampleResourceGroup.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes = new[]
{
"10.0.2.0/24",
},
});
var exampleManagedInstance = new Azure.MSSql.ManagedInstance("exampleManagedInstance", new()
{
ResourceGroupName = exampleResourceGroup.Name,
Location = exampleResourceGroup.Location,
LicenseType = "BasePrice",
SkuName = "GP_Gen5",
StorageSizeInGb = 32,
SubnetId = exampleSubnet.Id,
Vcores = 4,
AdministratorLogin = "msadministrator",
AdministratorLoginPassword = "thisIsDog11",
});
var exampleManagedDatabase = new Azure.MSSql.ManagedDatabase("exampleManagedDatabase", new()
{
ManagedInstanceId = exampleManagedInstance.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/mssql"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
"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
}
exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
AddressSpaces: pulumi.StringArray{
pulumi.String("10.0.0.0/16"),
},
})
if err != nil {
return err
}
exampleSubnet, err := network.NewSubnet(ctx, "exampleSubnet", &network.SubnetArgs{
ResourceGroupName: exampleResourceGroup.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.0.2.0/24"),
},
})
if err != nil {
return err
}
exampleManagedInstance, err := mssql.NewManagedInstance(ctx, "exampleManagedInstance", &mssql.ManagedInstanceArgs{
ResourceGroupName: exampleResourceGroup.Name,
Location: exampleResourceGroup.Location,
LicenseType: pulumi.String("BasePrice"),
SkuName: pulumi.String("GP_Gen5"),
StorageSizeInGb: pulumi.Int(32),
SubnetId: exampleSubnet.ID(),
Vcores: pulumi.Int(4),
AdministratorLogin: pulumi.String("msadministrator"),
AdministratorLoginPassword: pulumi.String("thisIsDog11"),
})
if err != nil {
return err
}
_, err = mssql.NewManagedDatabase(ctx, "exampleManagedDatabase", &mssql.ManagedDatabaseArgs{
ManagedInstanceId: exampleManagedInstance.ID(),
})
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.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.mssql.ManagedInstance;
import com.pulumi.azure.mssql.ManagedInstanceArgs;
import com.pulumi.azure.mssql.ManagedDatabase;
import com.pulumi.azure.mssql.ManagedDatabaseArgs;
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 exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.addressSpaces("10.0.0.0/16")
.build());
var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var exampleManagedInstance = new ManagedInstance("exampleManagedInstance", ManagedInstanceArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.licenseType("BasePrice")
.skuName("GP_Gen5")
.storageSizeInGb(32)
.subnetId(exampleSubnet.id())
.vcores(4)
.administratorLogin("msadministrator")
.administratorLoginPassword("thisIsDog11")
.build());
var exampleManagedDatabase = new ManagedDatabase("exampleManagedDatabase", ManagedDatabaseArgs.builder()
.managedInstanceId(exampleManagedInstance.id())
.build());
}
}
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
address_spaces=["10.0.0.0/16"])
example_subnet = azure.network.Subnet("exampleSubnet",
resource_group_name=example_resource_group.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.0.2.0/24"])
example_managed_instance = azure.mssql.ManagedInstance("exampleManagedInstance",
resource_group_name=example_resource_group.name,
location=example_resource_group.location,
license_type="BasePrice",
sku_name="GP_Gen5",
storage_size_in_gb=32,
subnet_id=example_subnet.id,
vcores=4,
administrator_login="msadministrator",
administrator_login_password="thisIsDog11")
example_managed_database = azure.mssql.ManagedDatabase("exampleManagedDatabase", managed_instance_id=example_managed_instance.id)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
addressSpaces: ["10.0.0.0/16"],
});
const exampleSubnet = new azure.network.Subnet("exampleSubnet", {
resourceGroupName: exampleResourceGroup.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.0.2.0/24"],
});
const exampleManagedInstance = new azure.mssql.ManagedInstance("exampleManagedInstance", {
resourceGroupName: exampleResourceGroup.name,
location: exampleResourceGroup.location,
licenseType: "BasePrice",
skuName: "GP_Gen5",
storageSizeInGb: 32,
subnetId: exampleSubnet.id,
vcores: 4,
administratorLogin: "msadministrator",
administratorLoginPassword: "thisIsDog11",
});
const exampleManagedDatabase = new azure.mssql.ManagedDatabase("exampleManagedDatabase", {managedInstanceId: exampleManagedInstance.id});
resources:
exampleResourceGroup:
type: azure:core:ResourceGroup
properties:
location: West Europe
exampleVirtualNetwork:
type: azure:network:VirtualNetwork
properties:
location: ${exampleResourceGroup.location}
resourceGroupName: ${exampleResourceGroup.name}
addressSpaces:
- 10.0.0.0/16
exampleSubnet:
type: azure:network:Subnet
properties:
resourceGroupName: ${exampleResourceGroup.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.0.2.0/24
exampleManagedInstance:
type: azure:mssql:ManagedInstance
properties:
resourceGroupName: ${exampleResourceGroup.name}
location: ${exampleResourceGroup.location}
licenseType: BasePrice
skuName: GP_Gen5
storageSizeInGb: 32
subnetId: ${exampleSubnet.id}
vcores: 4
administratorLogin: msadministrator
administratorLoginPassword: thisIsDog11
exampleManagedDatabase:
type: azure:mssql:ManagedDatabase
properties:
managedInstanceId: ${exampleManagedInstance.id}
Create ManagedDatabase Resource
new ManagedDatabase(name: string, args: ManagedDatabaseArgs, opts?: CustomResourceOptions);
@overload
def ManagedDatabase(resource_name: str,
opts: Optional[ResourceOptions] = None,
long_term_retention_policy: Optional[ManagedDatabaseLongTermRetentionPolicyArgs] = None,
managed_instance_id: Optional[str] = None,
name: Optional[str] = None,
short_term_retention_days: Optional[int] = None)
@overload
def ManagedDatabase(resource_name: str,
args: ManagedDatabaseArgs,
opts: Optional[ResourceOptions] = None)
func NewManagedDatabase(ctx *Context, name string, args ManagedDatabaseArgs, opts ...ResourceOption) (*ManagedDatabase, error)
public ManagedDatabase(string name, ManagedDatabaseArgs args, CustomResourceOptions? opts = null)
public ManagedDatabase(String name, ManagedDatabaseArgs args)
public ManagedDatabase(String name, ManagedDatabaseArgs args, CustomResourceOptions options)
type: azure:mssql:ManagedDatabase
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ManagedDatabaseArgs
- 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 ManagedDatabaseArgs
- 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 ManagedDatabaseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ManagedDatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ManagedDatabaseArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ManagedDatabase 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 ManagedDatabase resource accepts the following input properties:
- Managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- Long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- Name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- Short
Term intRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- Managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- Long
Term ManagedRetention Policy Database Long Term Retention Policy Args A
long_term_retention_policy
block as defined below.- Name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- Short
Term intRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- managed
Instance StringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- name String
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term IntegerRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term numberRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- managed_
instance_ strid The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- long_
term_ Managedretention_ policy Database Long Term Retention Policy Args A
long_term_retention_policy
block as defined below.- name str
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short_
term_ intretention_ days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- managed
Instance StringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- long
Term Property MapRetention Policy A
long_term_retention_policy
block as defined below.- name String
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term NumberRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
Outputs
All input properties are implicitly available as output properties. Additionally, the ManagedDatabase 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 ManagedDatabase Resource
Get an existing ManagedDatabase 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?: ManagedDatabaseState, opts?: CustomResourceOptions): ManagedDatabase
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
long_term_retention_policy: Optional[ManagedDatabaseLongTermRetentionPolicyArgs] = None,
managed_instance_id: Optional[str] = None,
name: Optional[str] = None,
short_term_retention_days: Optional[int] = None) -> ManagedDatabase
func GetManagedDatabase(ctx *Context, name string, id IDInput, state *ManagedDatabaseState, opts ...ResourceOption) (*ManagedDatabase, error)
public static ManagedDatabase Get(string name, Input<string> id, ManagedDatabaseState? state, CustomResourceOptions? opts = null)
public static ManagedDatabase get(String name, Output<String> id, ManagedDatabaseState 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.
- Long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- Managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- Name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- Short
Term intRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- Long
Term ManagedRetention Policy Database Long Term Retention Policy Args A
long_term_retention_policy
block as defined below.- Managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- Name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- Short
Term intRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- managed
Instance StringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- name String
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term IntegerRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- long
Term ManagedRetention Policy Database Long Term Retention Policy A
long_term_retention_policy
block as defined below.- managed
Instance stringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- name string
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term numberRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- long_
term_ Managedretention_ policy Database Long Term Retention Policy Args A
long_term_retention_policy
block as defined below.- managed_
instance_ strid The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- name str
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short_
term_ intretention_ days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
- long
Term Property MapRetention Policy A
long_term_retention_policy
block as defined below.- managed
Instance StringId The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
- name String
The name of the Managed Database to create. Changing this forces a new resource to be created.
- short
Term NumberRetention Days The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
Supporting Types
ManagedDatabaseLongTermRetentionPolicy, ManagedDatabaseLongTermRetentionPolicyArgs
- Monthly
Retention string The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- Week
Of intYear The week of year to take the yearly backup. Value has to be between
1
and52
.- Weekly
Retention string The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- Yearly
Retention string The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
- Monthly
Retention string The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- Week
Of intYear The week of year to take the yearly backup. Value has to be between
1
and52
.- Weekly
Retention string The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- Yearly
Retention string The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
- monthly
Retention String The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- week
Of IntegerYear The week of year to take the yearly backup. Value has to be between
1
and52
.- weekly
Retention String The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- yearly
Retention String The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
- monthly
Retention string The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- week
Of numberYear The week of year to take the yearly backup. Value has to be between
1
and52
.- weekly
Retention string The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- yearly
Retention string The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
- monthly_
retention str The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- week_
of_ intyear The week of year to take the yearly backup. Value has to be between
1
and52
.- weekly_
retention str The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- yearly_
retention str The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
- monthly
Retention String The monthly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 120 months. e.g.
P1Y
,P1M
,P4W
orP30D
.- week
Of NumberYear The week of year to take the yearly backup. Value has to be between
1
and52
.- weekly
Retention String The weekly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 520 weeks. e.g.
P1Y
,P1M
,P1W
orP7D
.- yearly
Retention String The yearly retention policy for an LTR backup in an ISO 8601 format. Valid value is between 1 to 10 years. e.g.
P1Y
,P12M
,P52W
orP365D
.
Import
SQL Managed Databases can be imported using the resource id
, e.g.
$ pulumi import azure:mssql/managedDatabase:ManagedDatabase example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/managedInstances/myserver/databases/mydatabase
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
azurerm
Terraform Provider.