Check! Deploy Azure Database for MySQL with using ARM template

Prologue
I’m glad that Azure Database for MySQL became General Availability(GA).
Immediately I tried to deploy by ARM template, but because the documentation is not enough now, it’s is difficult a little. So I wrote this post, you can deploy Azure Database for MySQL by ARM according to the following information.
If you want to know more details, please refer below documents.
- Microsoft.DBforMySQL/servers — Azure template | Microsoft Docs(This document is not enough now.)
- Azure REST API/MySQL/Servers — Create | Microsoft Docs (This is solve the lack of above page.)
Deploy MySQL with an empty database
I created a sample template to deploy Azure Database for MySQL with an empty database.
You can deploy on Azure Portal, click below link.
And you can deploy by Azure CLI. Download above files and change parameters like password, and execute below commands.
GROUP=<resource group name>
LOCATION=<resource group location>az group create -n ${GROUP} -l ${LOCATION}
az group deployment create -g ${GROUP} --template-file azuredeploy.json --parameters @parameters.json
Tips: Trick of sku name
Above documents show the following naming role of Sku name.
The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.
The tier symbol is like below.
Basic => B
General Purpose => GP
Memory Optimized => MO
There are rules for the combination (each tier x family x cores). Below page’s list helps you to know the combination.
Sample to generate the sku name
With the following code, you can generate the sku name from each parts.
"parameters": {
"databaseForMySqlTier": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"GeneralPurpose",
"MemoryOptimized"
]
},
"databaseForMySqlFamily": {
"type": "string",
"defaultValue": "Gen4",
"allowedValues": [
"Gen4",
"Gen5"
]
},
"databaseForMySqlCores": {
"type": "int",
"defaultValue": 1,
"allowedValues": [
1,
2,
4,
8,
16,
32
]
}
},
Then joined them as a variable.
"variables": {
"databaseForMySqlSku": "[concat(variables('tierSymbol')[parameters('databaseForMySqlTier')], '_', parameters('databaseForMySqlFamily'), '_', parameters('databaseForMySqlCores'))]",
"tierSymbol": {
"Basic": "B",
"GeneralPurpose": "GP",
"MemoryOptimized": "MO"
}
},
Deploy MySQL from a backup
If you want to create Azure Database for MySQL from backup, refer these options.
Epilogue
If I deployed wrong parameters, the operation returned hints to correct parameter. It helped me to fix my template.