title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | ms.devlang | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
CLI script - Create and enable public access connectivity |
This Azure CLI sample script shows how to create a Azure Database for MySQL - Flexible Server instance, configure a server-level firewall rule (public access connectivity method), and connect to the server. |
shreyaaithal |
shaithal |
maghan |
06/18/2024 |
mysql |
flexible-server |
sample |
|
azurecli |
Create an Azure Database for MySQL - Flexible Server instance and enable public access connectivity using Azure CLI
[!INCLUDEapplies-to-mysql-flexible-server]
This sample CLI script creates an Azure Database for MySQL - Flexible Server, configures a server-level firewall rule (public access connectivity method) and connects to the server after creation.
Once the script runs successfully, the MySQL Flexible Server will be accessible by all Azure services and the configured IP address, and you will be connected to the server in an interactive mode.
Note
The connectivity method cannot be changed after creating the server. For example, if you create server using Public access (allowed IP addresses), you cannot change to Private access (VNet Integration) after creation. To learn more about connectivity methods, see Networking concepts.
[!INCLUDE quickstarts-free-trial-note]
[!INCLUDE azure-cli-prepare-your-environment.md]
[!INCLUDE cli-launch-cloud-shell-sign-in.md]
:::code language="azurecli" source="~/azure_cli_scripts/mysql/flexible-server/create-server-public-access/create-connect-burstable-server-public-access.sh" id="FullScript":::
[!INCLUDE cli-clean-up-resources.md]
az group delete --name $resourceGroup
This script uses the following commands. Each command in the table links to command specific documentation.
Command | Notes |
---|---|
az group create | Creates a resource group in which all resources are stored |
az mysql flexible-server create | Creates a Flexible Server that hosts the databases. |
az mysql flexible-server firewall-rule create | Creates a firewall rule to allow access to the Flexible Server and its databases from the entered IP address range. |
az mysql flexible-server connect | Connects to a Flexible Server to perform server or database operations. |
az mysql flexible-server delete | Deletes a Flexible Server. |
az group delete | Deletes a resource group including all nested resources. |
- Try additional scripts: Azure CLI samples for Azure Database for MySQL - Flexible Server
- For more information on the Azure CLI, see Azure CLI documentation.