Skip to content

Commit a82a150

Browse files
Merge pull request #112447 from DennisLee-DennisLee/v-dele-1687537-2
1687537: template quickstart - Azure DB for MySQL
2 parents 1f59e78 + 3df0964 commit a82a150

File tree

3 files changed

+219
-0
lines changed

3 files changed

+219
-0
lines changed

articles/mysql/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
href: quickstart-create-server-up-azure-cli.md
2020
- name: Create DB - Azure PowerShell
2121
href: quickstart-create-mysql-server-database-using-azure-powershell.md
22+
- name: Create DB - ARM template
23+
href: quickstart-create-mysql-server-database-using-arm-template.md
24+
displayName: deploy azure resource manager template
2225
- name: Connect & query
2326
items:
2427
- name: PHP
Loading
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
---
2+
title: Create an Azure DB for MySQL using an ARM template
3+
description: In this article, learn how to create an Azure Database for MySQL server with virtual network integration, by using an Azure Resource Manager template.
4+
services: azure-resource-manager
5+
author: mgblythe
6+
ms.service: mysql
7+
ms.topic: quickstart
8+
ms.custom: subject-armqs
9+
ms.author: mblythe
10+
ms.date: 04/27/2020
11+
---
12+
13+
# Quickstart: Create an Azure Database for MySQL server by using the ARM template
14+
15+
Azure Database for MySQL is a managed service that you use to run, manage, and scale highly available MySQL databases in the cloud. This quickstart shows you how to use a predefined Azure Resource Manager (ARM) template to create an Azure Database for MySQL server with virtual network integration. You can create the server using the Azure portal, Azure CLI, or Azure PowerShell.
16+
17+
[!INCLUDE [About Azure Resource Manager](../../includes/resource-manager-quickstart-introduction.md)]
18+
19+
## Prerequisites
20+
21+
# [Portal](#tab/azure-portal)
22+
23+
An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/).
24+
25+
# [PowerShell](#tab/PowerShell)
26+
27+
* An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/).
28+
* If you want to run the code locally, [Azure PowerShell](/powershell/azure/).
29+
30+
# [CLI](#tab/CLI)
31+
32+
* An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/).
33+
* If you want to run the code locally, [Azure CLI](/cli/azure/).
34+
35+
---
36+
37+
## Create an Azure Database for MySQL server
38+
39+
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).
40+
41+
### Review the template
42+
43+
The template used in this quickstart is from [Azure quickstart templates](https://github.com/Azure/azure-quickstart-templates/tree/master/101-managed-mysql-with-vnet/).
44+
45+
:::code language="json" source="~/quickstart-templates/101-managed-mysql-with-vnet/azuredeploy.json" range="001-231" highlight="149,162,176,199,213":::
46+
47+
The template defines five Azure resources:
48+
49+
* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks)
50+
* [**Microsoft.Network/virtualNetworks/subnets**](/azure/templates/microsoft.network/virtualnetworks/subnets)
51+
* [**Microsoft.DBforMySQL/servers**](/azure/templates/microsoft.dbformysql/servers)
52+
* [**Microsoft.DBforMySQL/servers/virtualNetworkRules**](/azure/templates/microsoft.dbformysql/servers/virtualnetworkrules)
53+
* [**Microsoft.DBforMySQL/servers/firewallRules**](/azure/templates/microsoft.dbformysql/servers/firewallrules)
54+
55+
More Azure Database for MySQL template samples can be found in the [quickstart template gallery](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Dbformysql&pageNumber=1&sort=Popular).
56+
57+
## Deploy the template
58+
59+
# [Portal](#tab/azure-portal)
60+
61+
Select the following link to deploy the Azure Database for MySQL server template in the Azure portal:
62+
63+
[![Deploy to Azure](../media/template-deployments/deploy-to-azure.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fAzure%2fazure-quickstart-templates%2fmaster%2f101-managed-mysql-with-vnet%2fazuredeploy.json)
64+
65+
On the **Deploy Azure Database for MySQL with VNet** page:
66+
67+
1. For **Resource group**, select **Create new**, enter a name for the new resource group, and select **OK**.
68+
69+
2. If you created a new resource group, select a **Location** for the resource group and the new server.
70+
71+
3. Enter a **Server Name**, **Administrator Login**, and **Administrator Login Password**.
72+
73+
![Deploy Azure Database for MySQL with VNet window, Azure quickstart template, Azure portal](./media/quickstart-create-mysql-server-database-using-arm-template/deploy-azure-database-for-mysql-with-vnet.png)
74+
75+
4. Change the other default settings if you want:
76+
77+
* **Subscription**: the Azure subscription you want to use for the server.
78+
* **Sku Capacity**: the vCore capacity, which can be *2* (the default), *4*, *8*, *16*, *32*, or *64*.
79+
* **Sku Name**: the SKU tier prefix, SKU family, and SKU capacity, joined by underscores, such as *B_Gen5_1*, *GP_Gen5_2* (the default), or *MO_Gen5_32*.
80+
* **Sku Size MB**: the storage size, in megabytes, of the Azure Database for MySQL server (default *5120*).
81+
* **Sku Tier**: the deployment tier, such as *Basic*, *GeneralPurpose* (the default), or *MemoryOptimized*.
82+
* **Sku Family**: *Gen4* or *Gen5* (the default), which indicates hardware generation for server deployment.
83+
* **Mysql Version**: the version of MySQL server to deploy, such as *5.6* or *5.7* (the default).
84+
* **Backup Retention Days**: the desired period for geo-redundant backup retention, in days (default *7*).
85+
* **Geo Redundant Backup**: *Enabled* or *Disabled* (the default), depending on geo-disaster recovery (Geo-DR) requirements.
86+
* **Virtual Network Name**: the name of the virtual network (default *azure_mysql_vnet*).
87+
* **Subnet Name**: the name of the subnet (default *azure_mysql_subnet*).
88+
* **Virtual Network Rule Name**: the name of the virtual network rule allowing the subnet (default *AllowSubnet*).
89+
* **Vnet Address Prefix**: the address prefix for the virtual network (default *10.0.0.0/16*).
90+
* **Subnet Prefix**: the address prefix for the subnet (default *10.0.0.0/16*).
91+
92+
5. Read the terms and conditions, and then select **I agree to the terms and conditions stated above**.
93+
94+
6. Select **Purchase**.
95+
96+
# [PowerShell](#tab/PowerShell)
97+
98+
Use the following interactive code to create a new Azure Database for MySQL server using the template. The code prompts you for the new server name, the name and location of a new resource group, and an administrator account name and password.
99+
100+
To run the code in Azure Cloud Shell, select **Try it** at the upper corner of any code block.
101+
102+
```azurepowershell-interactive
103+
$serverName = Read-Host -Prompt "Enter a name for the new Azure Database for MySQL server"
104+
$resourceGroupName = Read-Host -Prompt "Enter a name for the new resource group where the server will exist"
105+
$location = Read-Host -Prompt "Enter an Azure region (for example, centralus) for the resource group"
106+
$adminUser = Read-Host -Prompt "Enter the Azure Database for MySQL server's administrator account name"
107+
$adminPassword = Read-Host -Prompt "Enter the administrator password" -AsSecureString
108+
109+
New-AzResourceGroup -Name $resourceGroupName -Location $location # Use this command when you need to create a new resource group for your deployment
110+
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName `
111+
-TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-managed-mysql-with-vnet/azuredeploy.json `
112+
-serverName $serverName `
113+
-administratorLogin $adminUser `
114+
-administratorLoginPassword $adminPassword
115+
116+
Read-Host -Prompt "Press [ENTER] to continue ..."
117+
```
118+
119+
# [CLI](#tab/CLI)
120+
121+
Use the following interactive code to create a new Azure Database for MySQL server using the template. The code prompts you for the new server name, the name and location of a new resource group, and an administrator account name and password.
122+
123+
To run the code in Azure Cloud Shell, select **Try it** at the upper corner of any code block.
124+
125+
```azurecli-interactive
126+
echo "Enter a name for the new Azure Database for MySQL server:" &&
127+
read serverName &&
128+
echo "Enter a name for the new resource group where the server will exist:" &&
129+
read resourceGroupName &&
130+
echo "Enter an Azure region (for example, centralus) for the resource group:" &&
131+
read location &&
132+
echo "Enter the Azure Database for MySQL server's administrator account name:" &&
133+
read adminUser &&
134+
echo "Enter the administrator password:" &&
135+
read adminPassword &&
136+
params='serverName='$serverName' administratorLogin='$adminUser' administratorLoginPassword='$adminPassword &&
137+
az group create --name $resourceGroupName --location $location &&
138+
az deployment group create --resource-group $resourceGroupName --parameters $params --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-managed-mysql-with-vnet/azuredeploy.json &&
139+
echo "Press [ENTER] to continue ..."
140+
```
141+
142+
---
143+
144+
## Review deployed resources
145+
146+
# [Portal](#tab/azure-portal)
147+
148+
Follow these steps to see an overview of your new Azure Database for MySQL server:
149+
150+
1. In the [Azure portal](https://portal.azure.com), search for and select **Azure Database for MySQL servers**.
151+
152+
2. In the database list, select your new server. The **Overview** page for your new Azure Database for MySQL server appears.
153+
154+
# [PowerShell](#tab/PowerShell)
155+
156+
Run the following interactive code to view details about your Azure Database for MySQL server. You'll have to enter the name of the new server.
157+
158+
```azurepowershell-interactive
159+
$serverName = Read-Host -Prompt "Enter the name of your Azure Database for MySQL server"
160+
Get-AzResource -ResourceType "Microsoft.DBforMySQL/servers" -Name $serverName | ft
161+
Write-Host "Press [ENTER] to continue..."
162+
```
163+
164+
# [CLI](#tab/CLI)
165+
166+
Run the following interactive code to view details about your Azure Database for MySQL server. You'll have to enter the name and the resource group of the new server.
167+
168+
```azurecli-interactive
169+
echo "Enter your Azure Database for MySQL server name:" &&
170+
read serverName &&
171+
echo "Enter the resource group where the Azure Database for MySQL server exists:" &&
172+
read resourcegroupName &&
173+
az resource show --resource-group $resourcegroupName --name $serverName --resource-type "Microsoft.DbForMySQL/servers"
174+
```
175+
176+
---
177+
178+
## Clean up resources
179+
180+
When it's no longer needed, delete the resource group, which deletes the resources in the resource group.
181+
182+
# [Portal](#tab/azure-portal)
183+
184+
1. In the [Azure portal](https://portal.azure.com), search for and select **Resource groups**.
185+
186+
2. In the resource group list, choose the name of your resource group.
187+
188+
3. In the **Overview** page of your resource group, select **Delete resource group**.
189+
190+
4. In the confirmation dialog box, type the name of your resource group, and then select **Delete**.
191+
192+
# [PowerShell](#tab/PowerShell)
193+
194+
```azurepowershell-interactive
195+
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
196+
Remove-AzResourceGroup -Name $resourceGroupName
197+
Write-Host "Press [ENTER] to continue..."
198+
```
199+
200+
# [CLI](#tab/CLI)
201+
202+
```azurecli-interactive
203+
echo "Enter the Resource Group name:" &&
204+
read resourceGroupName &&
205+
az group delete --name $resourceGroupName &&
206+
echo "Press [ENTER] to continue ..."
207+
```
208+
209+
---
210+
211+
## Next steps
212+
213+
For a step-by-step tutorial that guides you through the process of creating a template, see:
214+
215+
> [!div class="nextstepaction"]
216+
> [ Tutorial: Create and deploy your first Azure Resource Manager template](../azure-resource-manager/templates/template-tutorial-create-first-template.md)

0 commit comments

Comments
 (0)