az mysql flexible-server show returns null
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
az mysql flexible-server show
### Related command
I have a piece of code that does check if a mysql server exixts and it is at a Ready state.
The `az mysql flexible-server show` that check fo rthe server always returns null. While `az mysql flexible-server list` for the same server returns id value properly. The code I use is as follows:
`
server_status=$(az mysql flexible-server show --resource-group $resourcegroup --name $sername --query "userVisibleState" --output tsv)
if [ -z "$server_status" ]; then
echo "Server [$sername] does not exist."
exit 1
elif [ "$server_status" != "Ready" ]; then
echo "Server [$sername] exists but is not in the 'Ready' state. Current state: $server_status."
exit 1
else
echo "Server [$sername] is in state: $server_status. Proceeding to create database [$dbname]."
`
this code never works because `server_status` is always null.
while this `server_id=$(az mysql flexible-server list --resource-group $resourcegroup --query "[?name=='$sername'].id" --output tsv)` works fine. But I cannot use it to get the state o fthe server.
Seems like a bug with `az mysql flexible-server show`.
### Errors
server_status=$(az mysql flexible-server show --resource-group $resourcegroup --name $sername --query "userVisibleState" --output tsv)
if [ -z "$server_status" ]; then
echo "Server [$sername] does not exist."
exit 1
elif [ "$server_status" != "Ready" ]; then
echo "Server [$sername] exists but is not in the 'Ready' state. Current state: $server_status."
exit 1
else
echo "Server [$sername] is in state: $server_status. Proceeding to create database [$dbname]."
### Issue script & Debug output
server_status=$(az mysql flexible-server show --resource-group $resourcegroup --name $sername --query "userVisibleState" --output tsv)
if [ -z "$server_status" ]; then
echo "Server [$sername] does not exist."
exit 1
elif [ "$server_status" != "Ready" ]; then
echo "Server [$sername] exists but is not in the 'Ready' state. Current state: $server_status."
exit 1
else
echo "Server [$sername] is in state: $server_status. Proceeding to create database [$dbname]."
### Expected behavior
`az mysql flexible-server show` should return details about the server
### Environment Summary
azure-cli 2.69.0
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.