Deploy Azure Database for MySQL Single Server

The azure-native:dbformysql:SingleServer resource, part of the Pulumi Azure Native provider, provisions Azure Database for MySQL single servers: their compute tier, storage, administrator credentials, and backup configuration. This guide focuses on three capabilities: creating new servers with storage and backup settings, point-in-time and geo-restore recovery, and read replica configuration.

Servers require an Azure resource group. Restore and replica scenarios reference existing source servers with backups or replication enabled. The examples are intentionally small. Combine them with your own networking, firewall rules, and database provisioning.

Create a new server with storage and backup configuration

Most deployments start by provisioning a server with administrator credentials, compute capacity, and storage settings.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbformysql.SingleServer("singleServer", {
    location: "westus",
    properties: {
        administratorLogin: "cloudsa",
        administratorLoginPassword: "<administratorLoginPassword>",
        createMode: "Default",
        sslEnforcement: azure_native.dbformysql.SslEnforcementEnum.Enabled,
        storageProfile: {
            backupRetentionDays: 7,
            geoRedundantBackup: azure_native.dbformysql.GeoRedundantBackup.Enabled,
            storageMB: 128000,
        },
    },
    resourceGroupName: "testrg",
    serverName: "mysqltestsvc4",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "GP_Gen5_2",
        tier: azure_native.dbformysql.SingleServerSkuTier.GeneralPurpose,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbformysql.SingleServer("singleServer",
    location="westus",
    properties={
        "administrator_login": "cloudsa",
        "administrator_login_password": "<administratorLoginPassword>",
        "create_mode": "Default",
        "ssl_enforcement": azure_native.dbformysql.SslEnforcementEnum.ENABLED,
        "storage_profile": {
            "backup_retention_days": 7,
            "geo_redundant_backup": azure_native.dbformysql.GeoRedundantBackup.ENABLED,
            "storage_mb": 128000,
        },
    },
    resource_group_name="testrg",
    server_name="mysqltestsvc4",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "GP_Gen5_2",
        "tier": azure_native.dbformysql.SingleServerSkuTier.GENERAL_PURPOSE,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbformysql "github.com/pulumi/pulumi-azure-native-sdk/dbformysql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbformysql.NewSingleServer(ctx, "singleServer", &dbformysql.SingleServerArgs{
			Location: pulumi.String("westus"),
			Properties: &dbformysql.ServerPropertiesForDefaultCreateArgs{
				AdministratorLogin:         pulumi.String("cloudsa"),
				AdministratorLoginPassword: pulumi.String("<administratorLoginPassword>"),
				CreateMode:                 pulumi.String("Default"),
				SslEnforcement:             dbformysql.SslEnforcementEnumEnabled,
				StorageProfile: &dbformysql.StorageProfileArgs{
					BackupRetentionDays: pulumi.Int(7),
					GeoRedundantBackup:  pulumi.String(dbformysql.GeoRedundantBackupEnabled),
					StorageMB:           pulumi.Int(128000),
				},
			},
			ResourceGroupName: pulumi.String("testrg"),
			ServerName:        pulumi.String("mysqltestsvc4"),
			Sku: &dbformysql.SkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("GP_Gen5_2"),
				Tier:     pulumi.String(dbformysql.SingleServerSkuTierGeneralPurpose),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforMySQL.SingleServer("singleServer", new()
    {
        Location = "westus",
        Properties = new AzureNative.DBforMySQL.Inputs.ServerPropertiesForDefaultCreateArgs
        {
            AdministratorLogin = "cloudsa",
            AdministratorLoginPassword = "<administratorLoginPassword>",
            CreateMode = "Default",
            SslEnforcement = AzureNative.DBforMySQL.SslEnforcementEnum.Enabled,
            StorageProfile = new AzureNative.DBforMySQL.Inputs.StorageProfileArgs
            {
                BackupRetentionDays = 7,
                GeoRedundantBackup = AzureNative.DBforMySQL.GeoRedundantBackup.Enabled,
                StorageMB = 128000,
            },
        },
        ResourceGroupName = "testrg",
        ServerName = "mysqltestsvc4",
        Sku = new AzureNative.DBforMySQL.Inputs.SkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "GP_Gen5_2",
            Tier = AzureNative.DBforMySQL.SingleServerSkuTier.GeneralPurpose,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbformysql.SingleServer;
import com.pulumi.azurenative.dbformysql.SingleServerArgs;
import com.pulumi.azurenative.dbformysql.inputs.SkuArgs;
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 singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westus")
            .properties(ServerPropertiesForDefaultCreateArgs.builder()
                .administratorLogin("cloudsa")
                .administratorLoginPassword("<administratorLoginPassword>")
                .createMode("Default")
                .sslEnforcement("Enabled")
                .storageProfile(StorageProfileArgs.builder()
                    .backupRetentionDays(7)
                    .geoRedundantBackup("Enabled")
                    .storageMB(128000)
                    .build())
                .build())
            .resourceGroupName("testrg")
            .serverName("mysqltestsvc4")
            .sku(SkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("GP_Gen5_2")
                .tier("GeneralPurpose")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbformysql:SingleServer
    properties:
      location: westus
      properties:
        administratorLogin: cloudsa
        administratorLoginPassword: <administratorLoginPassword>
        createMode: Default
        sslEnforcement: Enabled
        storageProfile:
          backupRetentionDays: 7
          geoRedundantBackup: Enabled
          storageMB: 128000
      resourceGroupName: testrg
      serverName: mysqltestsvc4
      sku:
        capacity: 2
        family: Gen5
        name: GP_Gen5_2
        tier: GeneralPurpose
      tags:
        ElasticServer: '1'

The createMode property set to “Default” indicates a new server creation. The administratorLogin and administratorLoginPassword establish initial access credentials. The sku property defines the compute tier (GeneralPurpose), hardware generation (Gen5), and vCore count (2). The storageProfile configures storage capacity (128 GB), backup retention (7 days), and geo-redundant backups for disaster recovery. The sslEnforcement property requires encrypted connections.

Restore a server from a point in time backup

When recovering from data corruption or testing changes, you can restore servers to a specific timestamp from automatic backups.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbformysql.SingleServer("singleServer", {
    location: "brazilsouth",
    properties: {
        createMode: "PointInTimeRestore",
        restorePointInTime: "2017-12-14T00:00:37.467Z",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
    },
    resourceGroupName: "TargetResourceGroup",
    serverName: "targetserver",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "GP_Gen5_2",
        tier: azure_native.dbformysql.SingleServerSkuTier.GeneralPurpose,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbformysql.SingleServer("singleServer",
    location="brazilsouth",
    properties={
        "create_mode": "PointInTimeRestore",
        "restore_point_in_time": "2017-12-14T00:00:37.467Z",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
    },
    resource_group_name="TargetResourceGroup",
    server_name="targetserver",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "GP_Gen5_2",
        "tier": azure_native.dbformysql.SingleServerSkuTier.GENERAL_PURPOSE,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbformysql "github.com/pulumi/pulumi-azure-native-sdk/dbformysql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbformysql.NewSingleServer(ctx, "singleServer", &dbformysql.SingleServerArgs{
			Location: pulumi.String("brazilsouth"),
			Properties: &dbformysql.ServerPropertiesForRestoreArgs{
				CreateMode:         pulumi.String("PointInTimeRestore"),
				RestorePointInTime: pulumi.String("2017-12-14T00:00:37.467Z"),
				SourceServerId:     pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver"),
			},
			ResourceGroupName: pulumi.String("TargetResourceGroup"),
			ServerName:        pulumi.String("targetserver"),
			Sku: &dbformysql.SkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("GP_Gen5_2"),
				Tier:     pulumi.String(dbformysql.SingleServerSkuTierGeneralPurpose),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforMySQL.SingleServer("singleServer", new()
    {
        Location = "brazilsouth",
        Properties = new AzureNative.DBforMySQL.Inputs.ServerPropertiesForRestoreArgs
        {
            CreateMode = "PointInTimeRestore",
            RestorePointInTime = "2017-12-14T00:00:37.467Z",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
        },
        ResourceGroupName = "TargetResourceGroup",
        ServerName = "targetserver",
        Sku = new AzureNative.DBforMySQL.Inputs.SkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "GP_Gen5_2",
            Tier = AzureNative.DBforMySQL.SingleServerSkuTier.GeneralPurpose,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbformysql.SingleServer;
import com.pulumi.azurenative.dbformysql.SingleServerArgs;
import com.pulumi.azurenative.dbformysql.inputs.SkuArgs;
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 singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("brazilsouth")
            .properties(ServerPropertiesForRestoreArgs.builder()
                .createMode("PointInTimeRestore")
                .restorePointInTime("2017-12-14T00:00:37.467Z")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver")
                .build())
            .resourceGroupName("TargetResourceGroup")
            .serverName("targetserver")
            .sku(SkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("GP_Gen5_2")
                .tier("GeneralPurpose")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbformysql:SingleServer
    properties:
      location: brazilsouth
      properties:
        createMode: PointInTimeRestore
        restorePointInTime: 2017-12-14T00:00:37.467Z
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver
      resourceGroupName: TargetResourceGroup
      serverName: targetserver
      sku:
        capacity: 2
        family: Gen5
        name: GP_Gen5_2
        tier: GeneralPurpose
      tags:
        ElasticServer: '1'

The createMode property set to “PointInTimeRestore” creates a new server from a backup snapshot. The restorePointInTime specifies the exact timestamp to restore from (ISO 8601 format). The sourceServerId references the original server that holds the backup data. The restored server inherits the source server’s configuration but can use a different SKU for different compute capacity.

Create a read replica for scaling read workloads

Applications with heavy read traffic distribute queries across read replicas to reduce load on the primary server.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbformysql.SingleServer("singleServer", {
    location: "westus",
    properties: {
        createMode: "Replica",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver",
    },
    resourceGroupName: "TargetResourceGroup",
    serverName: "targetserver",
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbformysql.SingleServer("singleServer",
    location="westus",
    properties={
        "create_mode": "Replica",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver",
    },
    resource_group_name="TargetResourceGroup",
    server_name="targetserver")
package main

import (
	dbformysql "github.com/pulumi/pulumi-azure-native-sdk/dbformysql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbformysql.NewSingleServer(ctx, "singleServer", &dbformysql.SingleServerArgs{
			Location: pulumi.String("westus"),
			Properties: &dbformysql.ServerPropertiesForReplicaArgs{
				CreateMode:     pulumi.String("Replica"),
				SourceServerId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver"),
			},
			ResourceGroupName: pulumi.String("TargetResourceGroup"),
			ServerName:        pulumi.String("targetserver"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforMySQL.SingleServer("singleServer", new()
    {
        Location = "westus",
        Properties = new AzureNative.DBforMySQL.Inputs.ServerPropertiesForReplicaArgs
        {
            CreateMode = "Replica",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver",
        },
        ResourceGroupName = "TargetResourceGroup",
        ServerName = "targetserver",
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbformysql.SingleServer;
import com.pulumi.azurenative.dbformysql.SingleServerArgs;
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 singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westus")
            .properties(ServerPropertiesForReplicaArgs.builder()
                .createMode("Replica")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver")
                .build())
            .resourceGroupName("TargetResourceGroup")
            .serverName("targetserver")
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbformysql:SingleServer
    properties:
      location: westus
      properties:
        createMode: Replica
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MasterResourceGroup/providers/Microsoft.DBforMySQL/servers/masterserver
      resourceGroupName: TargetResourceGroup
      serverName: targetserver

The createMode property set to “Replica” creates a read-only copy that continuously synchronizes from the source server. The sourceServerId points to the primary server. Replicas inherit the primary server’s SKU and storage configuration automatically, so those properties are omitted. Replicas can be promoted to standalone servers by breaking replication.

Restore a server to a different region for disaster recovery

Disaster recovery plans often include restoring servers to alternate regions when primary regions become unavailable.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbformysql.SingleServer("singleServer", {
    location: "westus",
    properties: {
        createMode: "GeoRestore",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
    },
    resourceGroupName: "TargetResourceGroup",
    serverName: "targetserver",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "GP_Gen5_2",
        tier: azure_native.dbformysql.SingleServerSkuTier.GeneralPurpose,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbformysql.SingleServer("singleServer",
    location="westus",
    properties={
        "create_mode": "GeoRestore",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
    },
    resource_group_name="TargetResourceGroup",
    server_name="targetserver",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "GP_Gen5_2",
        "tier": azure_native.dbformysql.SingleServerSkuTier.GENERAL_PURPOSE,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbformysql "github.com/pulumi/pulumi-azure-native-sdk/dbformysql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbformysql.NewSingleServer(ctx, "singleServer", &dbformysql.SingleServerArgs{
			Location: pulumi.String("westus"),
			Properties: &dbformysql.ServerPropertiesForGeoRestoreArgs{
				CreateMode:     pulumi.String("GeoRestore"),
				SourceServerId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver"),
			},
			ResourceGroupName: pulumi.String("TargetResourceGroup"),
			ServerName:        pulumi.String("targetserver"),
			Sku: &dbformysql.SkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("GP_Gen5_2"),
				Tier:     pulumi.String(dbformysql.SingleServerSkuTierGeneralPurpose),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforMySQL.SingleServer("singleServer", new()
    {
        Location = "westus",
        Properties = new AzureNative.DBforMySQL.Inputs.ServerPropertiesForGeoRestoreArgs
        {
            CreateMode = "GeoRestore",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver",
        },
        ResourceGroupName = "TargetResourceGroup",
        ServerName = "targetserver",
        Sku = new AzureNative.DBforMySQL.Inputs.SkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "GP_Gen5_2",
            Tier = AzureNative.DBforMySQL.SingleServerSkuTier.GeneralPurpose,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbformysql.SingleServer;
import com.pulumi.azurenative.dbformysql.SingleServerArgs;
import com.pulumi.azurenative.dbformysql.inputs.SkuArgs;
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 singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westus")
            .properties(ServerPropertiesForGeoRestoreArgs.builder()
                .createMode("GeoRestore")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver")
                .build())
            .resourceGroupName("TargetResourceGroup")
            .serverName("targetserver")
            .sku(SkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("GP_Gen5_2")
                .tier("GeneralPurpose")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbformysql:SingleServer
    properties:
      location: westus
      properties:
        createMode: GeoRestore
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/servers/sourceserver
      resourceGroupName: TargetResourceGroup
      serverName: targetserver
      sku:
        capacity: 2
        family: Gen5
        name: GP_Gen5_2
        tier: GeneralPurpose
      tags:
        ElasticServer: '1'

The createMode property set to “GeoRestore” creates a server in a new region from geo-redundant backups. The location property specifies the target region (different from the source). The sourceServerId references the original server, which must have geo-redundant backups enabled in its storageProfile. The restored server can use a different SKU than the source.

Beyond these examples

These snippets focus on specific server-level features: server creation with compute and storage configuration, point-in-time and geo-restore recovery, and read replica topology. They’re intentionally minimal rather than full database deployments.

The examples may reference pre-existing infrastructure such as Azure resource groups and source servers for restore and replica scenarios. They focus on configuring the server rather than provisioning networking or databases.

To keep things focused, common server patterns are omitted, including:

  • Azure AD identity configuration (identity property)
  • TLS version enforcement (minimalTlsVersion)
  • Public network access controls (publicNetworkAccess)
  • Private endpoint connections
  • Infrastructure encryption (infrastructureEncryption)

These omissions are intentional: the goal is to illustrate how each server feature is wired, not provide drop-in database modules. See the SingleServer resource reference for all available configuration options.

Let's deploy Azure Database for MySQL Single Server

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Server Creation & Restore
What are the different ways to create a MySQL server?
You can create a server using four createMode values: Default (new server), PointInTimeRestore (restore from backup), Replica (read replica), or GeoRestore (restore from geo-redundant backup). Each mode requires different properties.
How do I restore a MySQL server from a point in time?
Set createMode to PointInTimeRestore, provide the sourceServerId of the original server, and specify restorePointInTime in ISO8601 format (e.g., 2017-12-14T00:00:37.467Z).
How do I create a read replica of my MySQL server?
Set createMode to Replica and provide the sourceServerId of the master server. No administrator credentials are needed for replicas.
What's the difference between geo-restore and point-in-time restore?
Both use sourceServerId, but GeoRestore restores from geo-redundant backups (typically for disaster recovery), while PointInTimeRestore requires a specific restorePointInTime timestamp for precise recovery.
Do I need administrator credentials when creating a replica or restoring a server?
No, administratorLogin and administratorLoginPassword are only required for createMode: Default. Replicas and restores inherit credentials from the source server.
Configuration & Security
How do I enable SSL for my MySQL server?
Set sslEnforcement to Enabled in the server properties. This enforces SSL for all connections.
How do I configure backup retention and geo-redundancy?
Use the storageProfile property with backupRetentionDays (e.g., 7 days), geoRedundantBackup (Enabled/Disabled), and storageMB for storage size.
How do I configure the SKU (pricing tier) for my server?
Specify sku with capacity (vCores), family (e.g., Gen5), name (e.g., GP_Gen5_2), and tier (e.g., GeneralPurpose).
Immutability & Limitations
What properties can't I change after creating the server?
The serverName and resourceGroupName are immutable. Changing these requires recreating the server.
What's the sourceServerId and when do I need it?
The sourceServerId is the full resource ID of an existing server. It’s required for PointInTimeRestore, Replica, and GeoRestore modes to specify which server to restore from or replicate.

Using a different cloud?

Explore database guides for other cloud providers: