|
| 1 | +--- |
| 2 | +title: 'Quickstart: Create an Azure DB for MySQL - Bicep' |
| 3 | +description: In this Quickstart, learn how to create an Azure Database for MySQL server with virtual network integration using Bicep. |
| 4 | +author: schaffererin |
| 5 | +ms.author: v-eschaffer |
| 6 | +ms.service: mysql |
| 7 | +ms.topic: quickstart |
| 8 | +ms.custom: subject-armqs, devx-track-azurepowershell, mode-arm |
| 9 | +ms.date: 05/02/2022 |
| 10 | +--- |
| 11 | + |
| 12 | +# Quickstart: Use Bicep to create an Azure Database for MySQL server |
| 13 | + |
| 14 | +[!INCLUDE[applies-to-mysql-single-server](includes/applies-to-mysql-single-server.md)] |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +[!INCLUDE [About Bicep](../../includes/resource-manager-quickstart-bicep-introduction.md)] |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +You need an Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/). |
| 23 | + |
| 24 | +# [PowerShell](#tab/PowerShell) |
| 25 | + |
| 26 | +* If you want to run the code locally, [Azure PowerShell](/powershell/azure/). |
| 27 | + |
| 28 | +# [CLI](#tab/CLI) |
| 29 | + |
| 30 | +* If you want to run the code locally, [Azure CLI](/cli/azure/). |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Review the Bicep file |
| 35 | + |
| 36 | +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](concepts-pricing-tiers.md). You create the server within an [Azure resource group](../azure-resource-manager/management/overview.md). |
| 37 | + |
| 38 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/managed-mysql-with-vnet/). |
| 39 | + |
| 40 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.dbformysql/managed-mysql-with-vnet/main.bicep"::: |
| 41 | + |
| 42 | +The Bicep file defines five Azure resources: |
| 43 | + |
| 44 | +* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks) |
| 45 | +* [**Microsoft.Network/virtualNetworks/subnets**](/azure/templates/microsoft.network/virtualnetworks/subnets) |
| 46 | +* [**Microsoft.DBforMySQL/servers**](/azure/templates/microsoft.dbformysql/servers) |
| 47 | +* [**Microsoft.DBforMySQL/servers/virtualNetworkRules**](/azure/templates/microsoft.dbformysql/servers/virtualnetworkrules) |
| 48 | +* [**Microsoft.DBforMySQL/servers/firewallRules**](/azure/templates/microsoft.dbformysql/servers/firewallrules) |
| 49 | + |
| 50 | +## Deploy the Bicep file |
| 51 | + |
| 52 | + |
| 53 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 54 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 55 | + |
| 56 | + # [CLI](#tab/CLI) |
| 57 | + |
| 58 | + ```azurecli |
| 59 | + az group create --name exampleRG --location eastus |
| 60 | + az deployment group create --resource-group exampleRG --template-file main.bicep --parameters serverName=<server-name> administratorLogin=<admin-login> |
| 61 | + ``` |
| 62 | +
|
| 63 | + # [PowerShell](#tab/PowerShell) |
| 64 | +
|
| 65 | + ```azurepowershell |
| 66 | + New-AzResourceGroup -Name exampleRG -Location eastus |
| 67 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -serverName "<server-name>" -administratorLogin "<admin-login>" |
| 68 | + ``` |
| 69 | +
|
| 70 | + --- |
| 71 | +
|
| 72 | + > [!NOTE] |
| 73 | + > 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. |
| 74 | +
|
| 75 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 76 | +
|
| 77 | +## Review deployed resources |
| 78 | +
|
| 79 | +Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. |
| 80 | +
|
| 81 | +# [CLI](#tab/CLI) |
| 82 | +
|
| 83 | +```azurecli-interactive |
| 84 | +az resource list --resource-group exampleRG |
| 85 | +``` |
| 86 | + |
| 87 | +# [PowerShell](#tab/PowerShell) |
| 88 | + |
| 89 | +```azurepowershell-interactive |
| 90 | +Get-AzResource -ResourceGroupName exampleRG |
| 91 | +``` |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## Clean up resources |
| 96 | + |
| 97 | +When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources. |
| 98 | + |
| 99 | +# [CLI](#tab/CLI) |
| 100 | + |
| 101 | +```azurecli-interactive |
| 102 | +az group delete --name exampleRG |
| 103 | +``` |
| 104 | + |
| 105 | +# [PowerShell](#tab/PowerShell) |
| 106 | + |
| 107 | +```azurepowershell-interactive |
| 108 | +Remove-AzResourceGroup -Name exampleRG |
| 109 | +``` |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Next steps |
| 114 | + |
| 115 | +For a step-by-step tutorial that guides you through the process of creating a Bicep file with Visual Studio Code, see: |
| 116 | + |
| 117 | +> [!div class="nextstepaction"] |
| 118 | +> [Quickstart: Create Bicep files with Visual Studio Code](../azure-resource-manager/bicep/quickstart-create-bicep-use-visual-studio-code.md) |
0 commit comments