Azure Database for MySQL APIs

This section details the available APIs for managing and interacting with Azure Database for MySQL resources. These APIs allow you to programmatically create, configure, monitor, and manage your MySQL server instances, databases, firewalls, and more.

Server Management APIs

Create Server

Creates a new Azure Database for MySQL server.

POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers

Request Body Example:

{
  "location": "westus",
  "sku": {
    "name": "B_Gen5_2",
    "tier": "Basic",
    "capacity": 2,
    "family": "Gen5"
  },
  "properties": {
    "version": "5.7",
    "administratorLogin": "myadmin",
    "administratorLoginPassword": "complexPassword123!",
    "storageProfile": {
      "storageMB": 51200,
      "backupRetentionDays": 7,
      "geoRedundantBackup": "Enabled"
    }
  }
}

Response Example (201 Created):

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DBforMySQL/servers/myServer",
  "name": "myServer",
  "location": "westus",
  "sku": {
    "name": "B_Gen5_2",
    "tier": "Basic",
    "capacity": 2,
    "family": "Gen5"
  },
  "properties": {
    "version": "5.7",
    "state": "Creating",
    "administratorLogin": "myadmin",
    "storageProfile": {
      "storageMB": 51200,
      "backupRetentionDays": 7,
      "geoRedundantBackup": "Enabled"
    },
    "creationDate": "2023-10-27T10:00:00Z"
  }
}

Get Server

Retrieves the properties of a specified MySQL server.

GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}

Response Example (200 OK):

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DBforMySQL/servers/myServer",
  "name": "myServer",
  "location": "westus",
  "sku": {
    "name": "B_Gen5_2",
    "tier": "Basic",
    "capacity": 2,
    "family": "Gen5"
  },
  "properties": {
    "version": "5.7",
    "state": "Ready",
    "administratorLogin": "myadmin",
    "storageProfile": {
      "storageMB": 51200,
      "backupRetentionDays": 7,
      "geoRedundantBackup": "Enabled"
    },
    "creationDate": "2023-10-27T10:00:00Z"
  }
}

Update Server

Updates an existing MySQL server's properties. This includes scaling compute or storage.

PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}

Request Body Example:

{
  "sku": {
    "name": "GP_Gen5_4",
    "tier": "GeneralPurpose",
    "capacity": 4,
    "family": "Gen5"
  },
  "properties": {
    "storageProfile": {
      "storageMB": 102400
    }
  }
}

Delete Server

Deletes a MySQL server.

DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}

Firewall Rule Management APIs

Create Firewall Rule

Creates a firewall rule for the server. This allows you to specify IP address ranges that can access the server.

POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/firewallRules/{firewallRuleName}

Request Body Example:

{
  "properties": {
    "startIpAddress": "40.77.160.0",
    "endIpAddress": "40.77.160.255"
  }
}

List Firewall Rules

Retrieves a list of all firewall rules for the server.

GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/firewallRules

Delete Firewall Rule

Deletes a firewall rule.

DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/firewallRules/{firewallRuleName}

Database Management APIs

Create Database

Creates a new database within a MySQL server.

POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/databases/{databaseName}

Request Body Example:

{
  "properties": {
    "charset": "utf8",
    "collation": "SQL_Latin1_General_CP1_CI_AS"
  }
}

List Databases

Retrieves a list of all databases on the server.

GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/databases

Replication APIs

APIs for configuring and managing read replicas for high availability and read scale-out.

Create Read Replica

Creates a read replica for a given server.

POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/replicas/{replicaName}

Request Body Example:

{
  "location": "eastus",
  "sku": {
    "name": "GP_Gen5_2",
    "tier": "GeneralPurpose",
    "capacity": 2,
    "family": "Gen5"
  }
}

For detailed information on API versions, authentication, and specific parameters, please refer to the official Azure REST API documentation.