Az MySql Flexible-server command returns error

I recently started scripting with Azure CLI within my Windows Subsystem for Linux (WSL) environment and tried to create a database on an Azure Database for MySQL Flexible-Server instance and received an error 'flexible-server' is not in the 'az mysql' command group. I also tried to list out the flexible-servers in my subscription, but it also give the same error!
I tried to see if maybe my Azure CLI was out of date, but it was already at the newest version!
As I test, I tried running the command in Microsoft's pre-package Azure CLI Docker container within my WSL Ubuntu environment: (You will need Docker Desktop installed)
~$ docker run -it mcr.microsoft.com/azure-cli
Sure enough, it worked just fine! Something is wrong with my installation of Azure CLI within the WSL environment. It is a relatively new install, so possibly Azure CLI did not install completely when setting up WSL…
Not matter, I found the instructions for reinstalling Azure CLI here… Install the Azure CLI on Linux
- Get packages needed for the install process:
1~$ sudo apt-get update
2~$ sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
- Download and install the Microsoft signing key:
1~$ curl -sL https://packages.microsoft.com/keys/microsoft.asc |
2 gpg --dearmor |
3~$ sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
- Add the Azure CLI software repository:
1~$ AZ_REPO=$(lsb_release -cs)
2~$ echo"deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPOmain"|
3 sudo tee /etc/apt/sources.list.d/azure-cli.list
Note: This step did not work as expected in the WSL Ubuntu environment, lsb_release doesn't return any information, so you have to set AZ_REPO environment variable manually:
- Execute "cat /etc/*release"
- Look for VERSION_CODENAME, or UBUNTU_CODENAME, which in our case is focal
- Now you can continue with the rest of the command:
1~$ AZ_REPO=focal
2~$ echo"deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPOmain"|
3 sudo tee /etc/apt/sources.list.d/azure-cli.list
- Update repository information and install the azure-cli package:
1~$ sudo apt-get update
2~$ sudo apt-get install azure-cli
The az mysql flexible-server module did not light up right away, I had to restart my Ubuntu WSL session. After that, it works fine!