title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | |||
---|---|---|---|---|---|---|---|---|---|---|---|
Quickstart: Create an Azure Database for MySQL - Bicep |
In this Quickstart, learn how to create an Azure Database for MySQL server with virtual network integration using Bicep. |
SudheeshGH |
sunaray |
11/26/2024 |
azure-database-mysql |
flexible-server |
quickstart |
|
Azure Database for MySQL is a managed service that you use to run, manage, and scale highly available MySQL databases in the cloud. In this quickstart, you use Bicep to create an Azure Database for MySQL server with virtual network integration. You can create the server in the Azure portal, Azure CLI, or Azure PowerShell.
[!INCLUDE About Bicep]
You need an Azure account with an active subscription. Create one for free.
- If you want to run the code locally, Azure PowerShell.
- If you want to run the code locally, Azure CLI.
You create an Azure Database for MySQL server with a defined set of compute and storage resources. To learn more, see Azure Database for MySQL pricing tiers. You create the server within an Azure resource group.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.dbformysql/managed-mysql-with-vnet/main.bicep":::
The Bicep file defines five Azure resources:
- Microsoft.Network/virtualNetworks
- Microsoft.Network/virtualNetworks/subnets
- Microsoft.DBforMySQL/servers
- Microsoft.DBforMySQL/servers/virtualNetworkRules
- Microsoft.DBforMySQL/servers/firewallRules
-
Save the Bicep file as main.bicep to your local computer.
-
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters serverName=<server-name> administratorLogin=<admin-login>
New-AzResourceGroup -Name exampleRG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -serverName "<server-name>" -administratorLogin "<admin-login>"
[!NOTE]
Replace <server-name> with the server name for Azure database for MySQL. Replace <admin-login> with the database administrator login name. You'll also be prompted to enter administratorLoginPassword. The minimum password length is eight characters.When the deployment finishes, you should see a message indicating the deployment succeeded.
Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.
az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG
When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.
az group delete --name exampleRG
Remove-AzResourceGroup -Name exampleRG
[!div class="nextstepaction"] Quickstart: Create Bicep files with Visual Studio Code