Having the right tools can help improve your productivity as you build applications and try to get day-to-day tasks done efficiently. The CLI is the predominantly preferred by developers as a tool for performing everything from one-time tasks to creating automated scripts. To help developers work more efficiently and maximize their productivity, we’ve made many improvements to the Azure Database for MySQL Flexible Servers (Preview) CLI experience.
For example, the new experience includes:
See all Azure Database for MySQL Flexible Server CLI commands to get started.
Flexible Server CLI commands support local context with the az config param-persist command, which locally stores information such as region, resource group, subscription ID, resource name, etc., for every sequential CLI command you run. You can easily turn on local context to store information by using the az config param-persist on command. If local context is turned on, you can see the contextual information by using the az config param-persist show command. You can always turn off local context by using the az config param-persist off command.
jane@Azure: ~$ az config param-persist show
Command group 'config param-persist' is experimental and not covered by customer support.
{"all":
{
"location":"eastus",
"resource_group_name":"mynewproject"
}
}
When creating a MySQL server using our managed database service on Azure, you’ll probably want to get started quickly, especially if you're just trying things out. With the new and improved Azure CLI for Flexible Server on Azure Database for MySQL, you can quickly create a MySQL server inside a virtual network. If you prefer, you can also easily provision a server with firewall rules in a single step. You can also view the progress visually as CLI commands to keep informed about what's going on behind the scenes.
Rather than using separate commands to create a resource group, a virtual network, and a subnet, you can use the az mysql flexible-server create command as shown below to create a secure MySQL Flexible Server inside a new virtual network and have a new subnet delegated to the server.
jane@Azure:~$ az mysql flexible-server create
Local context is turned on. Its information is saved in working directory /home/jane. You can run `az local-context off` to turn it off.
Command argument values from local context: --resource-group: mynewproject, --location: eastus
Command group 'mysql flexible-server' is in preview. It may be changed/removed in a future release.
Checking the existence of the resource group 'mynewproject'...
Resource group 'mynewproject' exists ? : True
Creating new vnet "VNET206094752" in resource group "mynewproject"...
Creating new subnet "Subnet206094752" in resource group "mynewproject" and delegating it to "Microsoft.DBforMySQL/flexibleServers"...
Creating MySQL Server 'server206094752' in group 'mynewproject'...
Your server 'server206094752' is using sku 'Standard_B1ms' (Paid Tier). Please refer to https://aka.ms/mysql-pricing for pricing details
Creating MySQL database 'flexibleserverdb'...
Make a note of your password. If you forget, you would have to reset your password with'az mysql flexible-server update -n server206094752 -g mynewproject -p <new-password>'.
{
"connectionString": "mysql flexibleserverdb --host server206094752.mysql.database.azure.com --user your-username --password='your-password'",
"databaseName": "flexibleserverdb",
"host": "server206094752.mysql.database.azure.com",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/mynewproject/providers/Microsoft.DBforMySQL/flexibleServers/server206094752",
"location": "East US",
"password": "your-password",
"resourceGroup": "mynewproject",
"skuname": "Standard_B1ms",
"subnetId": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/mynewproject/providers/Microsoft.Network/virtualNetworks/VNET206094752/subnets/Subnet206094752",
"username": "your-username",
"version": "5.7"
}
Use the az mysql flexible-server create –public-access all command to create a publicly accessible MySQL server. A publicly accessible server can be accessed from any client computer using the correct username and password. To restrict access only to your IP set, use the --public -access argument to scope it either your <IP – address> or a range of IP addresses, <Start IP address - End IP address>.
jane@Azure:~$ az mysql flexible-server create --public-access all
Local context is turned on. Its information is saved in working directory /home/sunitha. You can run `az local-context off` to turn it off.
Command argument values from local context: --resource-group: mynewproject, --location: eastus
Command group 'mysql flexible-server' is in preview. It may be changed/removed in a future release.
Checking the existence of the resource group 'mynewproject'...
Resource group 'mynewproject' exists ? : True
Creating MySQL Server 'server809097150' in group 'mynewproject'...
Your server 'server809097150' is using sku 'Standard_B1ms' (Paid Tier). Please refer to https://aka.ms/mysql-pricing for pricing details
Configuring server firewall rule to accept connections from '0.0.0.0' to '255.255.255.255'...
Creating MySQL database 'flexibleserverdb'...
Make a note of your password. If you forget, you would have to reset your password with'az mysql flexible-server update -n server809097150 -g mynewproject -p <new-password>'.
{
"connectionString": "mysql flexibleserverdb --host server809097150.mysql.database.azure.com --user your-username --password='your-password'",
"databaseName": "flexibleserverdb",
"firewallName": "AllowAll_2020-11-11_20-59-12",
"host": "server809097150.mysql.database.azure.com",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/mynewproject/providers/Microsoft.DBforMySQL/flexibleServers/server809097150",
"location": "East US",
"password": "your-password",
"resourceGroup": "mynewproject",
"skuname": "Standard_B1ms",
"username": "your-username",
"version": "5.7"
}
Use the az mysql flexible-server delete command to delete any MySQL Flexible Server identified in the local context. In the example below, the command identifies server210976926 in the local context and then tries to delete that server.
jane@Azure:~$ az mysql flexible-server delete
Local context is turned on. Its information is saved in working directory /home/jane. You can run `az local-context off` to turn it off.
Command argument values from local context: --resource-group: mynewproject, --name: server206094752
Command group 'mysql flexible-server' is in preview. It may be changed/removed in a future release.
Are you sure you want to delete the server 'server206094752' in resource group 'mynewproject' (y/n): y
Tuning MySQL database parameters is important when configuring your server to meet your application’s needs, or even to optimize performance. You can use the parameter set command to easily update server parameters with ease . You can view all the server parameter with parameter list and parameter show commands to view the values of a specific server parameter.
jane@Azure:~$ az mysql flexible-server parameter set --name audit_log_enabled --value ON
Local context is turned on. Its information is saved in working directory /home/jane. You can run `az local-context off` to turn it off.
Command argument values from local context: --server-name: server206094752, --resource-group: mynewproject
Command group 'mysql flexible-server parameter' is in preview. It may be changed/removed in a future release.
{- Finished ..
"allowedValues": "ON,OFF",
"dataType": "Enumeration",
"defaultValue": "OFF",
"description": "Allow to audit the log.",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/mynewproject/providers/Microsoft.DBforMySQL/flexibleServers/server206094752/configurations/audit_log_enabled",
"isConfigPendingRestart": "True",
"isDynamicConfig": "True",
"isReadOnly": "False",
"name": "audit_log_enabled",
"resourceGroup": "mynewproject",
"source": "user-override",
"type": "Microsoft.DBforMySQL/flexibleServers/configurations",
"value": "ON"
}
Here are few more powerful things that you can do when using the Azure CLI with MySQL Flexible Server:
These changes have been designed to support the best possible experience for developers when creating and managing their MySQL servers. We’d love for you to try out Azure Database for MySQL Flexible Server CLI commands and share any feedback you might have on the new or existing CLI commands.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.