Deploying Azure Database for MySQL

This guide provides comprehensive steps and best practices for deploying Azure Database for MySQL instances, whether you're creating a new server or configuring an existing one.

Creating an Azure Database for MySQL Server

You can deploy Azure Database for MySQL using the Azure portal, Azure CLI, Azure PowerShell, or REST APIs. Below, we'll cover the Azure portal and CLI methods.

Using the Azure Portal

  1. Navigate to the Azure portal.
  2. Search for "Azure Database for MySQL" and select it.
  3. Click "Create".
  4. Select a subscription and resource group.
  5. Provide a unique server name.
  6. Choose a location, version, and workload type (General Purpose, Memory Optimized).
  7. Configure compute + storage: Select vCores, storage size, and backup retention period.
  8. Configure networking: Choose public access (with firewall rules) or private access.
  9. Configure additional settings: Administrator login, password, and high availability options.
  10. Review and create the server.

Using the Azure CLI

Use the az mysql server create command. Ensure you have the Azure CLI installed and logged in.

az mysql server create \
    --resource-group myresourcegroup \
    --name myservername \
    --location eastus \
    --admin-user myadmin \
    --admin-password <your-password> \
    --sku-name Standard_D2s_v3 \
    --tier GeneralPurpose \
    --version 5.7 \
    --storage-size 10240 \
    --backup-retention 7 \
    --geo-redundant-backup Disabled
Note: Replace placeholders like myresourcegroup, myservername, myadmin, and <your-password> with your actual values.

Configuring Firewall Rules

Firewall rules control access to your database server. By default, no connections are allowed.

Azure Portal

  1. Go to your Azure Database for MySQL server in the Azure portal.
  2. Under "Settings", select "Connection security".
  3. Click "Add current client IP" to allow your current IP address.
  4. To add other IP addresses or ranges, click "Add firewall rule" and provide a name, start IP, and end IP address.

Azure CLI

Use the az mysql server firewall-rule create command.

az mysql server firewall-rule create \
    --resource-group myresourcegroup \
    --server myservername \
    --name AllowMyIP \
    --start-ip-address 203.0.113.0 \
    --end-ip-address 203.0.113.1
Tip: For production environments, consider using Private Link for secure and private network access instead of public access.

Virtual Network (VNet) Service Endpoints

VNet service endpoints enhance security by allowing you to restrict database access to specific virtual networks and subnets.

Azure CLI

az mysql server vnet-rule create \
    --resource-group myresourcegroup \
    --server myservername \
    --name MyVnetRule \
    --subnet <your-subnet-resource-id>

Deploying with High Availability

Azure Database for MySQL offers zone-redundant high availability, ensuring your application remains available even if a datacenter experiences an outage.

Warning: Zone-redundant high availability incurs additional costs. Review pricing details before enabling.

Next Steps

After successful deployment and configuration, you can connect to your Azure Database for MySQL instance from your applications or development tools.

Migrate Your Database Monitor Your Server